OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Open new page via plugin

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.

Open new page via plugin

Postby Szdnez » Sat Jan 02, 2010 2:05 pm

Hello,

I want to write my own OJS plugin. The plugin should put a new link in the list of the journal manager and when I click the link, I want to show a new page. The link is not the problem but I am not able to show a new page. Whatever I have tried, the page is always "empty". That is my code:

index.php
Code: Select all
require( 'VgWortZaehlmarkePlugin.inc.php' );
return new VgWortZaehlmarkePlugin();

VgWortZaehlmarkePlugin.inc.php
Code: Select all
import('classes.plugins.GenericPlugin');

class VgWortZaehlmarkePlugin
extends GenericPlugin
{
   function register( $category, $path )
   {
      if ( parent::register( $category, $path ) )
      {
         HookRegistry::register( 'Templates::Manager::Index::ManagementPages', array( &$this, 'callback' ) );
         $this->addLocaleData();
         
         return true;
      }
      
      return false;
   }
   ...
   function callback( $hookName, $args )
   {
      $params =& $args[0];
      $smarty =& $args[1];
      $output =& $args[2];
      $output .= '<li>&#187; <a href="' . Request::url( null, 'VgWortZaehlmarke' ) . '">' . Locale::translate( 'plugins.generic.vgwortzaehlmarke.linkname' ) . '</a></li>';
        
      return false;
   }
}

VgWortZaehlmarkeHandler.inc.php
Code: Select all
class VgWortZaehlmarkeHandler
extends Handler
{
   function index()
   {
      $templateManager =& TemplateManager::getManager();
      $templateManager->display($plugin->getTemplatePath() . 'VgWortZaehlmarke.tpl');
   }
}

VgWortZaehlmarke.tpl
Code: Select all
<p>Test</p>

Do I hve to register something more, or...? It is nearly the same code as e.g. the counter plugin of OJS. I have no more ideas and I can not debug my code because of OJS development under eclipse with pdt.

Thanks a lot!
Szdnez
 
Posts: 17
Joined: Tue Oct 20, 2009 12:48 pm

Re: Open new page via plugin

Postby Szdnez » Sat Jan 02, 2010 2:40 pm

At least I had the right "idea". I forgot to register the handler in the plugin. The extended code of VgWortZaehlmarkePlugin.inc.php
Code: Select all
function register( $category, $path )
   {
      if ( parent::register( $category, $path ) )
      {
         HookRegistry::register( 'Templates::Manager::Index::ManagementPages', array( &$this, 'callback' ) );
         HookRegistry::register( 'LoadHandler', array( &$this, 'handleRequest' ) );
         
         $this->addLocaleData();
         
         return true;
      }
      
      return false;
   }
   ...
   function handleRequest( $hookName, $args )
   {
      $page =& $args[0];
      $op =& $args[1];
      $sourceFile =& $args[2];

      if ( $page === 'VgWortZaehlmarke' )
      {
         $this->addLocaleData();
         $this->import( 'VgWortZaehlmarkeHandler' );
         Registry::set( 'VgWortZaehlmarkePlugIn', $this );
         define( 'HANDLER_CLASS', 'VgWortZaehlmarkeHandler' );
         
         return true;
      }

      return false;
   }
Szdnez
 
Posts: 17
Joined: Tue Oct 20, 2009 12:48 pm

Re: Open new page via plugin

Postby heidelberg » Tue Mar 23, 2010 2:16 am

Hi,

Actually, I am also interesed in a VG Wort Zählmarke - Plugin.
Is there any way that you could make it available to the public?
Or could you let me know if you could get it working properly?

Best wishes,
Steff
heidelberg
 
Posts: 36
Joined: Mon May 04, 2009 2:17 am


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 1 guest