Answer the question
In order to leave comments, you need to log in
How to display all articles of the author?
the bottom line is this: there is a user profile, you need to display all the articles of this user on the profile page, I tried to get by with a crutch:
<?php
if(!class_exists('ContentModelArticle')) require_once JPATH_ROOT.'/components/com_content/models/article.php';
$article = new ContentModelArticle;
$articleId=70;
while($articleId<400){
$youArticle = $article->getItem($articleId);
if($youArticle->created_by==JUserHelper::getProfile()->id){
echo $youArticle->title;
echo $youArticle->hits;
echo $youArticle->created;
echo $youArticle->introtext;
echo "<p class='readmore'><a href='index.php?option=com_content&view=article&id=".$youArticle->id."'> Подробнее... </a></p>";
}else{
echo "У вас пока нет ни одной статьи ";
echo " <a href='index.php/submit-an-article'> Написать </a></p>";
}
$articleId++;
}
?>
Answer the question
In order to leave comments, you need to log in
More or less like this:
$articles = JModelLegacy::getInstance("Articles", "ContentModel", array("ignore_request" => true));
$articles->setState("params", JFactory::getApplication()->getParams());
$articles->setState("filter.published", 1); // Только опубликованные
$articles->setState("filter.category_id", $this->category->id); // Фильтруем по определенной категории (если надо)
$articles->setState("filter.subcategories", true); // и всем подкатегориям
foreach ($articles->getItems() as $item) { // Получаем все материалы
if ($item->created_by == $user_id) { // Если это нужный автор, то
echo $item->title; // выводим все что нужно
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question