Skip to content

Commit

Permalink
Use published date in the category feed view
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Aug 18, 2018
1 parent 3d713fe commit 9beaa61
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libraries/src/MVC/View/CategoryFeedView.php
Expand Up @@ -38,17 +38,20 @@ public function display($tpl = null)
$ucmRow = $ucmType->getTypeByAlias($contentType);
$ucmMapCommon = json_decode($ucmRow->field_mappings)->common;
$createdField = null;
$publishedField = null;
$titleField = null;

if (is_object($ucmMapCommon))
{
$createdField = $ucmMapCommon->core_created_time;
$titleField = $ucmMapCommon->core_title;
$publishedField = $ucmMapCommon->core_publish_up;
}
elseif (is_array($ucmMapCommon))
{
$createdField = $ucmMapCommon[0]->core_created_time;
$titleField = $ucmMapCommon[0]->core_title;
$publishedField = $ucmMapCommon[0]->core_publish_up;
}

$document->link = \JRoute::_(\JHelperRoute::getCategoryRoute($app->input->getInt('id'), $language = 0, $extension));
Expand Down Expand Up @@ -97,7 +100,11 @@ public function display($tpl = null)
$description = $item->description;
$author = $item->created_by_alias ?: $item->author;

if ($createdField)
if ($publishedField && isset($item->$publishedField) && $item->$publishedField !== \JFactory::getDbo()->getNullDate())
{
$date = date('r', strtotime($item->$publishedField));
}
else if ($createdField)
{
$date = isset($item->$createdField) ? date('r', strtotime($item->$createdField)) : '';
}
Expand Down

0 comments on commit 9beaa61

Please sign in to comment.