OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Problems and questions developing first plugin

The Plugin Gallery is a venue for users of PKP software to share their plugins.

Moderators: jmacgreg, michael, John

Forum rules
If you post a plugin here, please include information on which versions of which applications it is compatible with. Attach a tarball of the plugin (e.g. tar cvzf myPlugin-0.1.tar.gz plugins/generic/myPlugin). Thanks for contributing!

Problems and questions developing first plugin

Postby Garant » Wed Oct 24, 2012 5:21 am

Hi!
I don't have any experience in developing plugins for OJS additionally there are very few information about how to write your custom plugin.
The task is to output last article's data in the home page.
I took a CustomBlock Plugin as a example. Rewrote SQL and block.tpl to suit my needs.
The problems with which I've encountered are:
1). There is no any control buttons in Block Plugins area.
2). The plugin shows itself and loads only when I access Block Plugins menu. It's better to make that plugin should load only accessing home page.
3). I don't need a sidebar block as it works now. I need to place block.tpl in the home page area.
Can you please guide me through fixing these issues ?
P.S. I've attached the semi working project
Attachments
latestArticle.rar
(3.75 KiB) Downloaded 134 times
Garant
 
Posts: 228
Joined: Wed May 30, 2012 8:53 am

Re: Problems and questions developing first plugin

Postby Garant » Thu Oct 25, 2012 4:01 am

So, no one will help?
Garant
 
Posts: 228
Joined: Wed May 30, 2012 8:53 am

Re: Problems and questions developing first plugin

Postby Garant » Thu Oct 25, 2012 12:29 pm

If I'm right - the third problem could be done using:
Code: Select all
   function getBlockContext() {
       return BLOCK_CONTEXT_HOMEPAGE;
   }

But of problem nr.2 can't check it.
Garant
 
Posts: 228
Joined: Wed May 30, 2012 8:53 am

Re: Problems and questions developing first plugin

Postby asmecher » Thu Oct 25, 2012 2:45 pm

Hi Garant,

I don't think homepage blocks are currently implemented. Your best bet will be to make your plugin a generic plugin, and look at the hooks in the template files. (Look e.g. at the Templates::Index::journal hook, specified in templates/index/journal.tpl.)

As for why the plugin is only appearing on certain pages, have a look at http://pkp.sfu.ca/wiki/index.php/Writing_a_Block_Plugin, specifically the part about registering the plugin with the database.

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

Re: Problems and questions developing first plugin

Postby Garant » Fri Oct 26, 2012 1:24 am

Hi, asmecher !
Thank you for you reply!
I'll examine this!
Last edited by Garant on Fri Oct 26, 2012 3:18 am, edited 1 time in total.
Garant
 
Posts: 228
Joined: Wed May 30, 2012 8:53 am

Re: Problems and questions developing first plugin

Postby Garant » Fri Oct 26, 2012 3:18 am

Done!
Thank you!
Garant
 
Posts: 228
Joined: Wed May 30, 2012 8:53 am

Re: Problems and questions developing first plugin

Postby fivos » Wed Mar 19, 2014 5:55 am

Hi,

I have a similar goal and problem. I want to display each article's metadata in the equivalent 'article/view' page.
I have implemented a Block plugin that displays the metadata, but they are displayed in the sidebar. I want the metadata to be displayed in the center of the page.
Can this be achieved through a Block plugin?
If not, how could i achieve this?



Thank you in advance,
Fivos
fivos
 
Posts: 19
Joined: Thu Mar 06, 2014 4:12 am

Re: Problems and questions developing first plugin

Postby JasonNugent » Wed Mar 19, 2014 7:48 am

Hi Fivos,

Block plugins appear in the sidebars, not in the center part of the page. You could do what you wanted by writing a plugin that hooked into the TemplateManager::display hook and examined the requested page or template, and then modified the content and returned the new template. Or perhaps hook Templates::Article::Footer::PageFooter which would only show when viewing the article footer.

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

Re: Problems and questions developing first plugin

Postby fivos » Thu Mar 20, 2014 3:36 am

Thank you very much for your answer Jason! I will try it that way!
So what i am trying to implement is a generic plugin?
fivos
 
Posts: 19
Joined: Thu Mar 06, 2014 4:12 am

Re: Problems and questions developing first plugin

Postby fivos » Mon Mar 24, 2014 8:34 am

Hi,

eventually i implemented a generic plugin, and used the hook (Templates::Article::Footer::PageFooter) that you suggested, Jason!
As soon as i complete the full implementation of the generic plugin i will post it in the Plugin Gallery.

Thank you!
fivos
 
Posts: 19
Joined: Thu Mar 06, 2014 4:12 am


Return to Plugin Gallery

Who is online

Users browsing this forum: No registered users and 0 guests