DiscussionController->_tpl_vars not found
Encountered this problem after changing my template from Smarty to PHP (mentioned in another post, but probably lost in the thread of a separate conversation). The pages all work apart from when I drill down to the post itself, and then this error pops up.
DiscussionController->_tpl_vars not found
Assuming it means a required template variable isn't being passed along properly. Another symptom which tells me this is the case is that my PHP code:
<?php if ($this->_tpl_vars['User']['SignedIn']): ?> <?php echo Gdn_Theme::Module('MeModule', array('CssClass' => "hidden-xs"));?> <?php else: ?> <li><a href="<?php echo Url('/'); ?>register" class="">Register</a></li> <li><a href="<?php echo Url('/'); ?>signin" class="">Sign In</a></li> <?php endif; ?>
… always shows the Register / Login links regardless of whether I am logged in or not.
I'm including the necessary head / footer assests, firing the AfterBody event and checking the code, the header and footer assets appear (no source code for the AfterBody event, but no idea whether that's supposed to. I'm calling them within my template in the following way:
<?php $this->RenderAsset('Head'); ?> <?php $this->RenderAsset('Foot'); ?> <?php $this->FireEvent('AfterBody'); ?>
Does this seem correct? Where do I need to start digging around for where _tpl_vars are defined?
Cheers.
Comments
_tpl_vars is a property of the Smarty class object. Since you aren't using Smarty, you have to use the underlying information. Smarty templates are rendered through the
Gdn_Smarty::Render()
method. All data available to the Smarty templates is in there.You will find something like this:
So, Smarty:
{if $User.SignedIn}
translates to PHP:if(Gdn::Session()->IsValid())
.Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Ah, I see. Thanks - that's got it working now.