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, michael, jheckman, barbarah, btbell, bdgregg, 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: 7
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: 5925
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: 7
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: 5925
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: 7
Joined: Mon Jul 16, 2012 1:18 am


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron