获取文章创建日期joomla

时间:2012-12-31 23:58:14

标签: joomla

我正在尝试获取文章创建的时间戳或日期,以便我可以使用css格式化它。我在谷歌和论坛上搜索过但是,我对结果感到困惑。

我做到了这一点:

echo $this->article->created;
echo $this->item->created;

并且给我一个空白的结果。

我做错了什么?

3 个答案:

答案 0 :(得分:1)

查看页面布局 https://github.com/joomla/joomla-cms/blob/2.5.x/components/com_content/views/article/tmpl/default.php#L114

第114行,您将看到如何在2.5中呈现日期。

<dd class="create">
<?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', $this->item->created, JText::_('DATE_FORMAT_LC2'))); ?>
</dd>

因此,要设置样式,您只需使用create类,或者可以进行布局覆盖。

这假设你想在文章中找到它。如果你想在列表或其他东西中查看相应的布局。如果您想覆盖日期格式本身,请在布局覆盖中执行此操作。

答案 1 :(得分:0)

您想要的元素似乎是vary by version,因此请确保您所做的任何内容与您的安装相匹配。

答案 2 :(得分:0)

首先,您要尝试显示创建的日期。

1)在普通的文章视图中,例如默认的joomla catgory,博客或任何其他视图。    你应该检查以下内容。

 The article options that available on the right side options of articles the created date is show true.

   Then Also make sure If it assigned to a menu there also these options available there also
   make true.

然后,您将在文章默认视图中获取创建日期。

2)如果你正在尝试使用自定义代码部分,你可以找到这样的代码。

$useDefList = (($params->get('show_author')) OR ($params->get('show_category')) OR ($params->get('show_parent_category'))
    OR ($params->get('show_create_date')) OR ($params->get('show_modify_date')) OR ($params->get('show_publish_date'))
    OR ($params->get('show_hits')));

在joomla的文章默认视图中。在任何版本的joomla中,这些都应该基于文章选项值。

希望这可以帮助你...

相关问题