You are viewing the PKP Support Forum | PKP Home Wiki

Header Modification

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

Header Modification

Postby cjpetrov » Mon Jun 23, 2014 1:58 am

I have a problem with the following code:
Code: Select all
{if $userSession->getSessionVar('signedInAs')}
   <a href="{url page="login" op="signOutAsUser"}"><span>Log out as user</span></a>

It's part from the user plugin. My goal is to insert this if statement in the header, but when I do this i have this error message:


So I've looked in the t_compile file for header.tpl.php, but I can't figure it out.

Thanks in advance,
Tsvetan Petrov,
Medical University of Varna, Bulgaria
Posts: 22
Joined: Tue Apr 15, 2014 9:50 am
Location: Varna, Bulgaria

Re: Header Modification

Postby asmecher » Mon Jun 23, 2014 8:50 am

Hi Tsvetan,

You're getting that error message because the userSession variable hasn't been assigned to the template manager at the time the header template output is generated. Have a look at the controller for the sidebar block code you've used as an example (plugins/blocks/user/UserBlockPlugin.inc.php) and you'll see...
Code: Select all
$session =& Request::getSession();
$templateMgr->assign_by_ref('userSession', $session);
To use the userSession variable in the header template, you'll need to make a similar assignment. I think classes/template/TemplateManager.inc.php would probably be a logical place.

Alec Smecher
Public Knowledge Project Team
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Return to OJS Development

Who is online

Users browsing this forum: No registered users and 3 guests