OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Help with Generic Plugin and templates

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.

Help with Generic Plugin and templates

Postby juli » Wed Jan 23, 2013 4:51 pm

Hi all!

I'm working i a new generic plugin to display the issues archive in a list inside the journal index (first page).

I would like to make a plugin to insert a code after the main content and before the footer. I have show in the templates/index/journal.tpl some variables like additionaHomeContent, but I cannot set a value to it. Also I tryed to copy the code of announcementFeed and piwik module to get similar working but I haven't any result.

I think that I must use a Hook but I not understand wichone, the Template::manager::... and templateManager::... seems to be appropiate but no one works for me.

Also the technical reference examples and hook list not solves this problem.

Please, any help will be great.

thanks a lot
juli
 
Posts: 13
Joined: Mon Jul 16, 2012 1:18 am

Re: Help with Generic Plugin and templates

Postby asmecher » Wed Jan 23, 2013 4:57 pm

Hi Juli,

You probably just need to register the plugin with the system; see e.g. http://pkp.sfu.ca/support/forum/viewtopic.php?f=9&t=7909#p30755.

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

Re: Help with Generic Plugin and templates

Postby juli » Thu Jan 24, 2013 12:47 am

Hi Alec,

thanks a lot for your fast reply. I have tryed with the
Code: Select all
php tools/upgrade.php upgrade


And also I have cleaned the data and template cache. Any more ideas?

this is my code:

Code: Select all
import('lib.pkp.classes.plugins.GenericPlugin');

class IssueCarouselPlugin extends GenericPlugin {
  function register($category, $path) {
    if (parent::register($category, $path)) {
      if ($this->getEnabled()) {
        HookRegistry::register('TemplateManager::display',array(&$this, 'callbackAddLinks'));
      }
      return true;
    }
    return false;
  }

  function getDisplayName() {
    return Locale::translate('plugins.generic.issuecarousel.displayName');
  }
  function getDescription() {
    return Locale::translate('plugins.generic.issuecarousel.description');
  }
  function callbackAddLinks($hookName, $args) {
    if ($this->getEnabled()) {
      $templateManager =& $args[0];
      $requestedPage = Request::getRequestedPage();

      // if we have a journal selected, append feed meta-links into the header
      $additionalHeadData = $templateManager->get_template_vars('additionalHomeContent');
      $templateManager->assign('additionalHomeContent', $additionalHomeData."\n\t TEST");
    }
    return false;
  }
}


Any help will be realy useful. Thanks a lot.
juli
 
Posts: 13
Joined: Mon Jul 16, 2012 1:18 am

Re: Help with Generic Plugin and templates

Postby asmecher » Thu Jan 24, 2013 9:41 am

Hi Juli,

I would suggest using "die()" calls to test whether certain parts of your code are getting called. For example, is the "register" function getting called? Is the hook getting registered? Is the callback getting called?

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

Re: Help with Generic Plugin and templates

Postby juli » Fri Jan 25, 2013 2:42 am

Hi folks,

My error was that I forgot the version.xml file. I added it, called upgrade (php tools/upgrade.php upgrade), clear caches and get it working.

thanks a lot, when I finis I will release it!
juli
 
Posts: 13
Joined: Mon Jul 16, 2012 1:18 am

Re: Help with Generic Plugin and templates

Postby ramon » Tue Jul 02, 2013 4:15 pm

Hello all,

How would I go about registering a plugin that is loaded in all pages when enabled?
How to set it to just for site admin access?
This plugin is intended to add javascript code to all pages...

_______________________________
Ramón Martins Sodoma da Fonseca
Analista em C&T
Coordenação de Tecnologias de Informação
Instituto Brasileiro de Informação em Ciência e Tecnologia - IBICT
Ministério da Ciência e Tecnologia - MCT
ramon
 
Posts: 931
Joined: Wed Oct 15, 2003 6:15 am
Location: Brasí­lia/DF - Brasil

Re: Help with Generic Plugin and templates

Postby asmecher » Wed Jul 03, 2013 8:25 am

Hi Ramón,

Plugins in the "generic" category are loaded (when enabled) on all pages. If you want to restrict administration to site administrators, you'll probably want to make it a site-wide plugin (see PKPPlugin::isSitePlugin). See for example the backup plugin or translator plugin -- plugins/generic/backup and plugins/generic/translator for relevant examples.

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

Re: Help with Generic Plugin and templates

Postby ramon » Wed Jul 03, 2013 10:30 am

Hello Alec!

Thank you!
I'll check them out.
For the current purposes, though, we're going for something simpler, loading OJS in lightbox view instead of iFrames...

_______________________________
Ramón Martins Sodoma da Fonseca
Analista em C&T
Coordenação de Tecnologias de Informação
Instituto Brasileiro de Informação em Ciência e Tecnologia - IBICT
Ministério da Ciência e Tecnologia - MCT
ramon
 
Posts: 931
Joined: Wed Oct 15, 2003 6:15 am
Location: Brasí­lia/DF - Brasil

Re: Help with Generic Plugin and templates

Postby juli » Wed Sep 18, 2013 5:48 am

Hi all,

as I posted in the Plugin Gallery forum (viewtopic.php?f=28&t=10597) we have finished this module! You can show it working on http://papers.uab.cat/ and also get the code on github: https://github.com/ictineo/ojs-issueCarousel

I hope that will be helpful for somebody.
juli
 
Posts: 13
Joined: Mon Jul 16, 2012 1:18 am


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 3 guests