Permalink
Browse files

Fix article tag and view

  • Loading branch information...
redaxmedia committed Jul 22, 2018
1 parent dd10095 commit f3fdd4eb1c540123358601f8f94bf2bd82eed184
Showing with 19 additions and 6 deletions.
  1. +3 −2 includes/Template/Tag.php
  2. +14 −2 includes/View/Article.php
  3. +1 −1 templates/default/content.phtml
  4. +1 −1 templates/skeleton/content.phtml
@@ -206,16 +206,17 @@ protected static function _renderContent()
* @since 4.0.0
*
* @param int $categoryId identifier of the category
* @param int $articleId identifier of the article
* @param array $optionArray options of the content
*
* @return string|null
*/
public static function article(int $categoryId = null, array $optionArray = [])
public static function article(int $categoryId = null, int $articleId = null, array $optionArray = [])
{
$article = new View\Article(Registry::getInstance(), Request::getInstance(), Language::getInstance(), Config::getInstance());
$article->init($optionArray);
return $article->render($categoryId);
return $article->render($categoryId, $articleId);
}
/**
View
@@ -113,11 +113,12 @@ public function init(array $optionArray = [])
* @since 4.0.0
*
* @param int $categoryId identifier of the category
* @param int $articleId identifier of the article
*
* @return string
*/
public function render(int $categoryId = null) : string
public function render(int $categoryId = null, int $articleId = null) : string
{
$output = Module\Hook::trigger('articleStart');
$accessValidator = new Validator\Access();
@@ -154,7 +155,18 @@ public function render(int $categoryId = null) : string
/* query articles */
$articles = $categoryId ? $articleModel->getByCategoryAndLanguage($categoryId, $language) : $articleModel->getByLanguage($language);
if ($articleId)
{
$articles = $articleModel->getByIdAndLanguage($articleId, $language);
}
else if ($categoryId)
{
$articles = $articleModel->getByCategoryAndLanguage($categoryId, $language);
}
else
{
$articles = $articleModel->getByLanguage();
}
/* process articles */
@@ -5,5 +5,5 @@
<article id="content" class="rs-content">
<?php echo Tag::breadcrumb(); ?>
<?php $content = Tag::content(); ?>
<?php echo $content ? $content : Tag::article() . Tag::partial('default/comment.phtml'); ?>
<?php echo $content ? $content : Tag::article(Helper::getRegistry('categoryId'), Helper::getRegistry('articleId')) . Tag::partial('default/comment.phtml'); ?>
</article>
@@ -5,6 +5,6 @@
<article id="content" class="rs-content">
<?php echo Tag::breadcrumb(); ?>
<?php $content = Tag::content(); ?>
<?php echo $content ? $content : Tag::article() . Tag::partial('default/comment.phtml'); ?>
<?php echo $content ? $content : Tag::article(Helper::getRegistry('categoryId'), Helper::getRegistry('articleId')) . Tag::partial('default/comment.phtml'); ?>
</article>

0 comments on commit f3fdd4e

Please sign in to comment.