OJS 3.1 Get article id and title in tpl

Hello, I am sorry may be my question looks very simple. If I use in plugin this code $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $articles = $publishedArticleDao->getPublishedArticlesByJournalId($journal,null,null);
How can get article ID and title in tpl file? I am trying {foreach from=$popularArticles item=popularArticle} {$popularArticle->getLocalizedTitle()|escape}<br /> {/foreach}
But no results.

i dont know if your solution should work or no, but i get the title and id in the plugin, store it in the array and pass my array to smarty, and it work:

in my plugin class:

$publishedArticleObjects = $publishedArticleDao->getPublishedArticlesByJournalId($journalId, $rangeArticles, $reverse = true);

$latestArticles = array();

while ($publishedArticle = $publishedArticleObjects->next()) {
    $latestArticles[] = array(
      'title' => $publishedArticle->getLocalizedTitle(),
      'id' => $publishedArticle->getBestArticleId()

$smarty->assign('latestArticles', $latestArticles );

and in template:

{foreach from=$latestArticles item=article}
    <p><a href="{url page="article" op="view" path=$article.id}">

Dear Azerilatama,

Thank you! Can you help me with adding $rangeArticles.

its simple, you need only use DBResultRange calss:

 $articleCount = 20;
 $rangeArticles = new DBResultRange($articleCount);

for more detail about this class you can see its implimentation in:

Thanks! I tried find some documentation about OJS Classes, but didn`t found anything.

to the best of my knowledge, unfortunately there is not any technical documentation for ojs3 and the only existing one is produced for ojs 2.1:

but the ojs implementation is almost clear and can understood by reading the source code and the plugins.

Dear Azerilatama,

Sorry for disturb you again. Please help me with class and function for getting submission title by id. Thank you!

you can use PublishedArticleDAO class and its getPublishedArticleById method.

I’m used to working on yii or with pure php. Therefore, ojs for me is not the usual environment. I try different methods of calling the title, but I get nothing. For example:

$publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
$publishedArticleObjects = $publishedArticleDao->getPublishedArticleById($editorChoiceContentLink1);
$templateMgr->assign('editorChoiceContentLink1', $publishedArticleObjects->getLocalizedTitle());

Result: nothing

I suppose, you need to iterate $publishedArticleObjects.

From annotation on getPublishedArticleById method: @return PublishedArticle objects array

I think object. Not array

Ahh, my mistake, you are getting the article by id, so must be a single object, not an array. This part of code looks normal to me.

But i got empty result

May be you can help me with using sql in generic plugin?

use getByArticleId method instead of getPublishedArticleById, and check is it give you the title

i think its is better to ask it in the other topic, so if someone else search for similar issue can find it :wink:

$publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticleObjects = $publishedArticleDao->getByArticleId($editorChoiceContentLink1); $templateMgr->assign('editorChoiceContentLink1', $publishedArticleObjects->getLocalizedTitle());

No result

I used such call of PublishedArticleDAO in several plugins and all worked OK. For example: browsePlugin/BrowsePlugin.inc.php at master · Vitaliy-1/browsePlugin · GitHub

Dear Vitaliy,

I unsterstood your idea and it`s help me. Thank you!