OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Use of $journalDescription on About us page

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

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

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Use of $journalDescription on About us page

Postby jakemc » Mon Jun 04, 2012 9:10 am

Hello. I hope I'm in the correct forum for template advice.

I want the "about" page to display the journal description. However, the variable $journalDescription is not recognised on the about page. How can I access it from here?

Thanks.
jakemc
 
Posts: 9
Joined: Wed May 09, 2012 6:27 am

Re: Use of $journalDescription on About us page

Postby JasonNugent » Mon Jun 04, 2012 9:50 am

Hi Jakemc,

Not all variables are available in all templates. What you'd have to do in this case is edit the pages/about/AboutHandler.inc.php file and find the necessary op function that generates the page you want. Generally, this is easy -- just search for the template name or look at the URL. Something like /about/index would be loaded in the index() function, and something like /about/contact would be in the contact() function.

Each of those functions would have template variables assigned via the $templateMgr variable. You'd just need to add something for the journal description:

Code: Select all
$templateMgr->assign('journalDescription', $journal->getSetting('journalDescription'));


You'd want to make sure that there is a valid $journal object in that function before that line of code. Once you do that, you'd have the variable you want in your template.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 871
Joined: Tue Jan 10, 2006 6:20 am

Re: Use of $journalDescription on About us page

Postby jakemc » Wed Jun 06, 2012 1:27 am

That's very helpful, thanks Jason.
However,
Code: Select all
{if $journal}
   {$templateMgr->assign('journalDescription', $journal->getSetting('journalDescription')); }
   {$journalDescription}
{else}
   <p>no description</p>
{/if}


yields the {else} output. Is it possible to access the $journal variable from the about page?
jakemc
 
Posts: 9
Joined: Wed May 09, 2012 6:27 am

Re: Use of $journalDescription on About us page

Postby JasonNugent » Wed Jun 06, 2012 3:45 am

Hi jakemc,

The code I originally posted doesn't go in the template -- it would go in the PHP handler (AboutHandler.inc.php). All you'd need in the actual Smarty template is a reference to {$journalDescription}.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 871
Joined: Tue Jan 10, 2006 6:20 am

Re: Use of $journalDescription on About us page

Postby jakemc » Wed Jun 06, 2012 10:03 am

Apologies for the misunderstanding Jason, and thanks for your patience.

In AboutHandler.inc.php I now have:
Code: Select all
   function index() {
      $this->validate();
      $this->setupTemplate();

      $templateMgr =& TemplateManager::getManager();
      $journalDao =& DAORegistry::getDAO('JournalDAO');
      $journalPath = Request::getRequestedJournalPath();

      if ($journalPath != 'index' && $journalDao->journalExistsByPath($journalPath)) {
         $journal =& Request::getJournal();

         // code snipped
      
         if ($journal) {
            $templateMgr->assign('journalDescription', $journal->getSetting('journalDescription'));
         }

      } else {
         // code snipped
      }
   }


and in the smarty template:

Code: Select all
{if $journalDescription}
   {$journalDescription}
{/if}


However, I'm still not getting a positive result. Can you help further?
jakemc
 
Posts: 9
Joined: Wed May 09, 2012 6:27 am

Re: Use of $journalDescription on About us page

Postby JasonNugent » Wed Jun 06, 2012 11:44 am

Hi Jake,

I guess my next suggestion would be to look in the OJS database table called 'journal_settings' and see if there is a value in the setting with a setting_name of 'journalDescription' for that particular journal. The code may be doing what is is supposed to, but perhaps there is nothing to display.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 871
Joined: Tue Jan 10, 2006 6:20 am

Re: Use of $journalDescription on About us page

Postby jakemc » Thu Jun 07, 2012 12:59 pm

Thanks Jason. However, the site is hosted by PKP so I don't have direct access to the database, though I have entered some dummy text in the journal description field in the journal manager so there should be something. Am I missing something?
jakemc
 
Posts: 9
Joined: Wed May 09, 2012 6:27 am

Re: Use of $journalDescription on About us page

Postby asmecher » Thu Jun 07, 2012 2:09 pm

Hi all,

OTOH that is a localized setting (meaning it should be available in multiple languages), so you should probably use $journal->getLocalizedSetting(...) instead of $journal->getSetting(...).

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

Re: Use of $journalDescription on About us page

Postby JasonNugent » Thu Jun 07, 2012 4:26 pm

Doh, yes, Alec is totally right.
JasonNugent
Site Admin
 
Posts: 871
Joined: Tue Jan 10, 2006 6:20 am

Re: Use of $journalDescription on About us page

Postby jakemc » Fri Jun 08, 2012 1:14 am

Thanks Alec and Jason, but this is still not displaying the journal description.

Could it be because the journalDescription is attached to the homepage, rather than being a sitewide setting? If so, how do I access homepage data?

Thanks again.
jakemc
 
Posts: 9
Joined: Wed May 09, 2012 6:27 am

Re: Use of $journalDescription on About us page

Postby JasonNugent » Fri Jun 08, 2012 3:43 am

Hi Jake,

What is the exact URL you're looking to display it on? With that, I can tell you what context is available.

Cheers,
Jason
JasonNugent
Site Admin
 
Posts: 871
Joined: Tue Jan 10, 2006 6:20 am

Re: Use of $journalDescription on About us page

Postby jakemc » Fri Jun 08, 2012 4:57 am

jakemc
 
Posts: 9
Joined: Wed May 09, 2012 6:27 am

Re: Use of $journalDescription on About us page

Postby JasonNugent » Sat Jun 09, 2012 7:51 am

Hi Jake,

Based on that URL, you're definitely hitting the templates/about/index.tpl template. Is that the file you've been adding the {$journalDescription} smarty variable to?

Cheers,
Jason
JasonNugent
Site Admin
 
Posts: 871
Joined: Tue Jan 10, 2006 6:20 am

Re: Use of $journalDescription on About us page

Postby jakemc » Mon Jun 11, 2012 1:32 am

Yes it is.
jakemc
 
Posts: 9
Joined: Wed May 09, 2012 6:27 am

Re: Use of $journalDescription on About us page

Postby JasonNugent » Tue Jun 12, 2012 5:51 am

Hi Jake,

I've been looking at this a bit, and if your journal is on the server I think it is, I'm not sure you're editing the file in question. If you want, just send me a PM with the address you FTP or SSH to (I don't need the username or password, I just want to check something) and also the path to the file or your home directory. Again, I don't need any login credentials. At this point I am just curious. The files I've looked at have not been modified.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 871
Joined: Tue Jan 10, 2006 6:20 am

Next

Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 2 guests