News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

odd php behavior

Started by ESFclandoteu, April 02, 2010, 06:22:42 PM

Previous topic - Next topic

ESFclandoteu

Hi all

I'm having a very strange issue when I try to add the following to a block
<?php ssi_showPoll(); ?>

In this case I'm trying to show the poll in topic 669 so, <?php ssi_showPoll(669); ?>.

When I'm within the admin section and non forum parts of my site, the poll displays fine, but as soon as I'm out and viewing the forums it returns an error;

"Fatal error: Call to undefined function ssi_showPoll() in /home/xxxxxxxx/public_html/includefile.php(24) : eval()'d code on line 2"
This error also stops my forums from displaying.

What's more bizarre is that on the pages that don't return the error, the block I put the code in becomes unnecessarily stretched and with the poll right at the bottom of the block, this also happens if I insert the code within a page. See the attached image to understand what I mean.

I've not got an ounce of knowledge about php or ssi's apart from what I've read at ssi_examples.php within my smf installation.

If anyone could shed any light on this it would be very much appreciated.

Arantor

You don't have a require or include statement calling SSI.php first.

ESFclandoteu

as I previously mentioned I'm a php noob. I don't know what either of those things are??

MultiformeIngegno

What do you mean by "block"? Are you using a portal?
RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

ESFclandoteu


MultiformeIngegno

In this case if you're using a php block I don't think you need the php tags..
RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

Orstio

QuoteIn this case I'm trying to show the poll in topic 669 so, <?php ssi_showPoll(669); ?>.

When I'm within the admin section and non forum parts of my site, the poll displays fine, but as soon as I'm out and viewing the forums it returns an error;


You can't have SSI and SMF on the same page.  SSI won't load if SMF is already running.

Arantor

QuoteSSI won't load if SMF is already running.

Well, that's not entirely correct... you can include the file and use the functions in it, as some portals do actually do.

Orstio

#8
Quote from: Arantor on April 03, 2010, 12:31:32 PM
QuoteSSI won't load if SMF is already running.

Well, that's not entirely correct... you can include the file and use the functions in it, as some portals do actually do.

SSI.php, lines 25-27:

// Don't do anything if SMF is already loaded.
if (defined('SMF'))
return true;


So, yes, it is entirely correct.


Arantor

Then how come you can invoke SSI.php and the functions still get defined?

Orstio


Arantor

I've seen it done where it's been included in index.template.php to use SSI functions in the theme. It was even submitted as a mod a bit back to use ssi_recentTopics.

Orstio

Then I suggest you try it. :P

Arantor

I modified 2.0 RC3 fresh install like so:

function template_html_below()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

global $boarddir;
include($boarddir . '/SSI.php');
ssi_recentTopics();
echo !empty($settings['forum_width']) ? '
</div>' : '', '
</body></html>';
}


As you can see, bringing the variable in to scope to get path, then calling SSI recent topics.

I would attach it but the server runs out of memory and whitescreens on me if I do, so instead... http://www.wordowl.com/misc/smf/ssi_recent_topics.png

Now tell me it doesn't work.

Orstio

And your SSI.php is not modified in any way?

Arantor

Nope. Is a 2.0 RC3 fresh install just to be sure.

I suggest you try it.

Orstio

Can you change it slightly to this?

function template_html_below(){
global $context, $settings, $options, $scripturl, $txt, $modSettings;
global $boarddir;
echo SMF;
include($boarddir . '/SSI.php');
echo SMF;
ssi_recentTopics();
echo !empty($settings['forum_width']) ? '</div>' : '', '</body></html>';
}

Arantor


Orstio

Well, as I expect, I get absolutely no results except for the "11".

http://www.everything-science.com/forum/

Arantor

OK, so let's get down and dirty.

I'm using PHP 5.2.6 on Windows + Apache 2.2.something. Related?

Advertisement: