I am trying to display the most popular articles block on the journal table of content instead of displaying it on either right or left side .
That’ll require modifying the code; currently it’s only written to appear on the sidebar.
Regards,
Alec Smecher
Public Knowledge Project Team
can you guide me to do so
I’m sorry, but we can’t guide you through modifications to the system. If you are familiar with PHP/MySQL and have specific questions, we should be able to help.
Regards,
Alec Smecher
Public Knowledge Project Team
Yes I am a PHP/MySQL Programmer. How can I apply this knowledge to the aforementioned issue
You’ll need to assign some content to the template manager, then add the template code to present it where you want. The assignment in the block plugin happens in MostPopularArticlesBlockPlugin in the “getContents” function; you’ll need to transplant that into a handler.
The template code is in the plugins’ block.tpl Smarty template. You’ll see that it makes use of the variables assigned in getContents.
As for where you put this code, the table of contents is presented in pages/issue/IssueHandler.inc.php in the “current” (current issue) and “view” functions (other issues). They refer to templates – you can find those files in the templates/ subdirectory.
The OJS technical reference will probably be useful; it’s available from our Documentation page.
Regards,
Alec Smecher
Public Knowledge Project Team
Dear @asmecher
I tried to do so , but always fail to display the returned results
Can you help me more. I need to solve this issue as fast as possible
regards
If you can post your modifications as a fork on github.com, I can have a quick look.
Regards,
Alec Smecher
Public Knowledge Project Team
I put this function in IssueHandler.inc.php
function getContents(&$templateMgr) {
$journal =& Request::getJournal();
if (!$journal) return '';
$mostPopularArticlesDAO =& DAORegistry::getDAO('MostPopularArticlesDAO');
$templateMgr->assign('popularArticles', $mostPopularArticlesDAO->getMostPopularArticles($journal->getJournalId(), 5));
$journalDao =& DAORegistry::getDAO('JournalDAO');
$templateMgr->assign_by_ref('journalDao', $journalDao);
return parent::getContents($templateMgr);
}
and this code in issue.tpl
Hi @Ahmad_Al_Jayousi ,
The Handler classes don’t use a getContents function – that’s only for block plugins. Have a look at the technical reference for some details on how Handler classes work.
Regards,
Alec Smecher
Public Knowledge Project Team