Integrate ssi functions from smf forum

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Integrate ssi functions from smf forum

Post by Timbalu » Wed Dec 08, 2010 6:09 pm

This isn't easy, while we are using smartified templates.
Using php code directly is disabled as of security reasons.

We could have taken the other plugin, Garvin mentioned, but this is for sidebar output too and isn't smartified, so this should not help us according to your wishes.

OK, this is what I would try, if you want the topics in the page footer section only.
If you use a modern template like bulletproof or anything like it, you can find a config.inc.php file in your template folder. Open it and add (underneath the dont hack part):

Code: Select all

<?php
if (IN_serendipity !== true) {
  die ("Don't hack!");
}

// get the smf framework
require("/home/daxueyin/public_html/forum/SSI.php");

// assign a smarty variable to the topics
$serendipity['smarty']->assign('ssi_recentTopics', ssi_recentTopics()); 

...
Now you can open the templates index.tpl file, find the footer section and pass

Code: Select all

{$ssi_recentTopics}
to a good place. Now, if everything is all right with your forum settings, every page should have the topics in your footer part. I can't reproduce this here, but maybe this is a way to go. (Anyone reading this and know this is wrong, please correct!)

HTH,
Ian

hdiaz36
Regular
Posts: 57
Joined: Wed Feb 21, 2007 6:57 pm
Location: China (Yes, really)

Re: Integrate ssi functions from smf forum

Post by hdiaz36 » Wed Dec 08, 2010 6:39 pm

I'm using the default template. I think it's carl contest? Anyway, I can't find any config.inc.php file. :(
Image

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Integrate ssi functions from smf forum

Post by Timbalu » Wed Dec 08, 2010 6:58 pm

I'm not sure when this thing with a parsed config.inc.php was added to serendipty, but you could give it a try and just add one like this

Code: Select all

<?php
if (IN_serendipity !== true) {
  die ("Don't hack!");
}

// get the smf framework
require("/home/daxueyin/public_html/forum/SSI.php");

// assign a smarty variable to the topics
$serendipity['smarty']->assign('ssi_recentTopics', ssi_recentTopics());

?>
to carl_contest.
If you get it working there - everything is fine, if not, please tell us your php version and if you are able to upgrade. If not, we could hack at least the include/genpage.inc.php file of your blog, which is possible until you upgrade the blog.

Ian

hdiaz36
Regular
Posts: 57
Joined: Wed Feb 21, 2007 6:57 pm
Location: China (Yes, really)

Re: Integrate ssi functions from smf forum

Post by hdiaz36 » Wed Dec 08, 2010 7:17 pm

Adding a config.inc.php file with the code you specified to the carl contest template folder seems to have destroyed my blog. Haha, I just get a blank page. Removed the file and everything was fine.

EDIT: And how do I determine my version of php?
Image

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Integrate ssi functions from smf forum

Post by Timbalu » Wed Dec 08, 2010 7:29 pm

if you login, you can see it in the footer of the login page
eg 'xxx with Serendipity 1.5.4 and PHP 5.3.3'

Under blog/include you will find the genpage.inc.php file. Open it and append

Code: Select all

// get the smf framework
require("/home/daxueyin/public_html/forum/SSI.php");

// assign a smarty variable to the topics
$serendipity['smarty']->assign('ssi_recentTopics', ssi_recentTopics());

to the very end just before the closing ?> (if any) or the /* vim: set sts=4 ts=4 expandtab : */ part.
Adding the

Code: Select all

{$ssi_recentTopics}
to the footer part of your templates/index.tpl the topics should work now.

Sorry this took so long to find out... :)
Ian

hdiaz36
Regular
Posts: 57
Joined: Wed Feb 21, 2007 6:57 pm
Location: China (Yes, really)

Re: Integrate ssi functions from smf forum

Post by hdiaz36 » Wed Dec 08, 2010 7:54 pm

Sorry? Haha, are you kidding me? Sorry I consumed so much of your time!

Well, the strange thing is that I didn't get around to editing templates/index.tpl but everything already seemed to be working...

Thanks so much, I might have some more questions later concerning centering or small tweaks, but for now I am quite happy!

Hmm, actually I have one question. Originally I wanted to change the number of recent topics. I was told I could use something like

Code: Select all

<?php ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo'); ?>
and change the 8 to my desired amount.

How would I get this done inside serendipity? I mean what code changes would I need to make to either the genpage.inc.php or templates/index.tpl files?
Image

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Integrate ssi functions from smf forum

Post by Timbalu » Wed Dec 08, 2010 8:12 pm

Well, I could have asked earlier... ;-)
hdiaz36 wrote:Well, the strange thing is that I didn't get around to editing templates/index.tpl but everything already seemed to be working...
Very strange...! Are you sure?
Did you kill all other files and plugins we edited?

Amount change here, assuming you want 12, in genpage...

Code: Select all

// assign a smarty variable to the topics
$serendipity['smarty']->assign('ssi_recentTopics', ssi_recentTopics(12));
You don't need all the other stuff ($exclude_boards is null already, $include_boards must be a old version of SMF - see function ssi_recentTopics inside SSI.php - and the $output_method is 'echo' by default). This means the output is already formated by SMF. If you want to format the output on your own you have to write something like

Code: Select all

// assign a smarty variable to the topics
$serendipity['smarty']->assign('ssi_recentTopics', ssi_recentTopics(12, null, 'array'));
and change the {$ssi_recentTopics} to a smarty foreach loop with some markup tags.

About the tweaks and so on, it would be much easier for me, if I could visualize your blog...

Ian

Post Reply