Based on requests from our latest journal installation, we changed the OJS code to implement the 'Browse By' a setting name (e.g types, disciplines etc.). Currently I am working to develop this functionality as a plugin in order to contribute it to the community, but I have some problems (maybe I should mention that this is my first OJS plugin
First of all I should mention that I work with OJS 2.3.5 and I install the plugin manually: I created a folder in plugins/generic/browse and put all the code there. Also, I manually added the browsePlugin in versions Table and the plugin is enabled.
So, the register function in BrowsePlugin.inc.php is the following:
- Code: Select all
function register($category, $path) {
if (parent::register($category, $path)) {
$this->addLocaleData();
if ($this->getEnabled()) {
$this->import('BrowseDAO');
$BrowseDAO = &new BrowseDAO();
$returner = &DAORegistry::registerDAO('BrowseDAO', $BrowseDAO);
// Handler for public thesis abstract pages
HookRegistry::register('LoadHandler', array($this, 'handleRequest'));
}
return true;
}
return false;
}
Then, the handler is loaded:
- Code: Select all
function handleRequest($hookName, $args) {
$page =& $args[0];
$op =& $args[1];
$sourceFile =& $args[2];
// If the request is for the log analyzer itself, handle it.
if ($page === 'browse') {
$this->import('BrowseHandler');
Registry::set('plugin', $this);
define('HANDLER_CLASS', 'BrowseHandler');
return true;
}
return false;
}
In BrowseHandler.inc.php, I have specified index(), which loads a simple test.tpl (this template justs prints a test paragraph):
- Code: Select all
function index()
{
$templateManager =& TemplateManager::getManager();
$templateManager->display('test.tpl');
}
So, the URL: http://www.myJournalUrl.../index.php/{journal_initials}/browse should show the test paragraph, but instead it displays 404 error
- Code: Select all
Stack Trace:
File: C:\xampp\htdocs\ojs_2.3.5_onlinereader\lib\pkp\classes\core\PKPPageRouter.inc.php line 230
Function: Dispatcher->handle404()
File: C:\xampp\htdocs\ojs_2.3.5_onlinereader\lib\pkp\classes\core\Dispatcher.inc.php line 129
Function: PKPPageRouter->route(Object(Request))
File: C:\xampp\htdocs\ojs_2.3.5_onlinereader\lib\pkp\classes\core\PKPApplication.inc.php line 180
Function: Dispatcher->dispatch(Object(Request))
File: C:\xampp\htdocs\ojs_2.3.5_onlinereader\index.php line 65
Function: PKPApplication->execute()
What am I doing wrong? I have tried various ways to do this, based on other generic plugins and still the same problem!
Also, how can I specify to load different functions based on the URL? (e.g. if the URL is browse/types, it should load the function types() from BrowseHandler.inc.php)
Can someone please help me with this.
Thank you in advance,
Rania
