OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



How to get user role along with name in login Box

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

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

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

How to get user role along with name in login Box

Postby rameshnispaara » Fri Apr 23, 2010 3:25 am

Hi,

After login, I want ti display the like this 'You are logged in as sanjana: author'.
but I tried this code which in index.tpl of user in user block.tpl. The code is below

{assign var="journalId" value=$journal->getJournalId()}
{section name=role loop=$userRoles[$journalId]}
{if $userRoles[$journalId][role]->getRolePath() != 'reader'}
<li>&#187; <a href="{url journal=$journal->getPath() page=$userRoles[$journalId][role]->getRolePath()}">{translate key=$userRoles[$journalId][role]->getRoleName()}</a></li>
{/if}
{/section}

But I git below Error.

Fatal error: Call to a member function getJournalId() on a non-object.



Any one would help me.
Thanks in advance.
rameshnispaara
 
Posts: 1
Joined: Fri Apr 23, 2010 3:14 am

Re: How to get user role along with name in login Box

Postby mcrider » Fri Apr 30, 2010 10:45 am

Hi rameshnispaara,

It looks like journal object is not available to the template you are using--you'll have to assign it by putting something like
Code: Select all
$journal =& Request::getJournal();
$templateMgr->assign_by_ref('journal', $journal);

In the getContents() function of the UserBlockPlugin.inc.php file.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC


Return to OJS Development

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests