Getting the url for a plugin

OJS development discussion, enhancement requests, third-party patches and plug-ins.

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

Forum rules
The Public Knowledge Project Support Forum is moving to

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.
Posts: 22
Joined: Mon Jan 09, 2006 12:04 am
Location: Grahamstown, South Africa

Getting the url for a plugin

Postby christo » Tue Aug 21, 2007 12:49 am


How does one go about getting the baseurl for a plugin.

In particular, my problem: I have a sitewide plugin, but as far as i can tell, the manage() function of the plugin class is only called from a journal specific url: eg:{journalPath}/manager/plugin/generic/{pluginName}/{verb}/{args}

it is {journalpath} that is causing the problems since i do not always have a journal specified when i might want to link to my plugin management functions; and replacing {journalpath} with index doesnt work either...

now, if i want to send someone to somewhere when no journal has been selected, i cant use Journal::getPath() ... because we are not currently on a journal path. and it is not ideal to have to randomly select a journal from the database simply to get a url that will work.

I have looked, but i dont see a function such as $plugin->getBaseUrl() ... there is $plugin->getTemplatePath(), but that is not what i am looking for...

What is the best way to do this?

Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Re: Getting the url for a plugin

Postby asmecher » Tue Aug 21, 2007 8:56 am

Hi Christo,

The best way to do this is use the LoadHandler hook to intercept incoming requests and create a new URL with which the plugin can be invoked. The LoadHandler hook is invoked from OJS's index.php wrapper. You'll be able to use the regular {url ...} function to create URLs to invoke it.

Alec Smecher
Public Knowledge Project Team

Return to “OJS Development”

Who is online

Users browsing this forum: No registered users and 2 guests