Skip to main content
Topic: bootstrap.php causes error in Theme.php (Read 1794 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

bootstrap.php causes error in Theme.php

Testing a custom add-on in 1.1 RC2.  It calls a php function via javascript from the Display page.  First line is require(appropriate path/SSI.php) .   SSI.php then does require_once(appropriate path/bootstrap.php).

This eventually calls setupThemeContext() which produces the following error.

PHP Notice:  Undefined index: default_forum_action in forum/themes/default/Theme.php on line 737

This didn't happen in 1.0.x

Re: bootstrap.php causes error in Theme.php

Reply #1
hmm...
That should do for the moment.
In bootstrap.php search for:
Code: [Select]
else
{
setupThemeContext();
}
and change it to:
Code: [Select]
else
{
if (!empty($modSettings['front_page']) && is_callable(array($modSettings['front_page'], 'frontPageHook')))
{
$modSettings['default_forum_action'] = '?action=forum;';
}
else
{
$modSettings['default_forum_action'] = '';
}

setupThemeContext();
}
I would prefer to have this code somewhere else, but honestly I can't see a good place for it at the moment.
Bugs creator.
Features destroyer.
Template killer.

Re: bootstrap.php causes error in Theme.php

Reply #2
Thanks.  (Wasn't sure where you wanted that fix.)

Re: bootstrap.php causes error in Theme.php

Reply #3
I'm not sure either. xD
To be honest, at that point I'm not sure the code belongs to the dispatcher to begin with.
Bugs creator.
Features destroyer.
Template killer.

Re: bootstrap.php causes error in Theme.php

Reply #4
I'm not sure what the actual point of creating bootstrap is, but given it's name I would think both SSI and the dispatcher should call it for common start up.

Re: bootstrap.php causes error in Theme.php

Reply #5
The idea behind bootstrap is to extract from the SSI the logic that allows to start Elk and make it standalone.
SSI would become then just a sort of "demo" of how to use bootstrap, providing few functions as goodie.
In an ideal world I would use bootstrap at the beginning of index.php too, but... there are few differences that I didn't want to tackle.

The missing index here, instead is part of the "new feature" in 1.1 that allows controllers to be able to acts as the "home page" and is a sort of hack I had to put together in order to fix an issue.
So, when I introduced this index I put it in the dispatcher because it seemed to work well, but now I'm not sure any more.
Bugs creator.
Features destroyer.
Template killer.

Re: bootstrap.php causes error in Theme.php

Reply #6
This doesn't seem exterminated.  Or at least I don't know how to use the new system.  I set ssi_layers in my front page and I still get the same error with your change.  Not surprising as your change is in an else clause after if(isset($ssi_layers)). 

I added $modSettings['default_forum_action'] = '' to the if statement.

Code: [Select]
// Load the stuff like the menu bar, etc.
if (isset($ssi_layers))
{
******************************************************************
Added this to make SSI happy
$modSettings['default_forum_action'] = '';
******************************************************************
$template_layers = Template_Layers::instance();
$template_layers->removeAll();
foreach ($ssi_layers as $layer)
{
$template_layers->addBegin($layer);
}
template_header();
}
else
{
if (!empty($modSettings['front_page']) && is_callable(array($modSettings['front_page'], 'frontPageHook')))
{
$modSettings['default_forum_action'] = '?action=forum;';
}
else
{
$modSettings['default_forum_action'] = '';
}

setupThemeContext();
}


 

Re: bootstrap.php causes error in Theme.php

Reply #8
That version works.  :)