Hi @Farhan_Abbas,
We would like to get browsing by section out soon, but it probably won’t make it into OJS 3.1. To build something like this yourself, I’d recommend you create a plugin. Here’s a very quick example on how you could create a custom URL and deliver whatever you’d like to that.
First, you’ll need to create a new plugin. The theme guide includes useful information on necessary parts of a plugin, but you should put your plugin into the generic
directory, not the theme
directory.
In your plugin file, you need to hook into the LoadHandler
hook to load your own page handler:
import('lib.pkp.classes.plugins.GenericPlugin');
class ExamplePlugin extends GenericPlugin {
/**
* @copydoc Plugin::getDisplayName()
*/
public function getDisplayName() {
return 'Example plugin';
}
/**
* @copydoc Plugin::getDescription()
*/
public function getDescription() {
return 'Example plugin description';
}
/**
* @copydoc Plugin::register()
*/
public function register($category, $path) {
$success = parent::register($category, $path);
if (!Config::getVar('general', 'installed') || defined('RUNNING_UPGRADE')) return $success;
if ($success && $this->getEnabled()) {
HookRegistry::register('LoadHandler', array($this, 'setPageHandler'));
}
return $success;
}
/**
* Route requests for the citation styles to custom page handler
*
* @see PKPPageRouter::route()
* @param $hookName string
* @param $params array
*/
public function setPageHandler($hookName, $params) {
$page = $params[0];
if ($this->getEnabled() && $page === 'examplePage') {
$this->import('ExamplePageHandler');
define('HANDLER_CLASS', 'ExamplePageHandler');
return true;
}
return false;
}
}
You’ll be loading an ExamplePageHandler.inc.php
class that you’ll create like this:
import('classes.handler.Handler');
class CitationStyleLanguageHandler extends Handler {
/**
* @param $args array
* @param $request PKPRequest
* @return null|JSONMessage
*/
public function exampleOp($args, $request) {
// Fetch the published articles in a section
$publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
$articles = $publishedArticleDao->getPublishedArticlesBySectionId($sectionId, $issueId);
// Call your own template file
$templateMgr = TemplateManager::getManager();
$templateMgr->assign(array(
'articles' => $articles
));
$templateMgr->display($this->getTemplatePath() . '/example-page-template.tpl');
}
}
You can then create the URL to match this in templatess like this:
{url page="examplePage" op="exampleOp"}
You can look around at other examples to figure out how to pass additional args, like a section ID, then retrieve that information and pull it into the database. But hopefully that gets you started.