我需要在com_content / views / article / view.html.php
中进行一些更改该文件是一个类:
class ContentViewArticle extends JViewLegacy{
}
所以如何覆盖这个类,因为在某些类别中我需要以另一种方式设置元描述。
我将核心源文件复制到: templates / my_template_name / code / com_content / views / article / view.html.php
我做了一些改动,但它不起作用。
我认为它不会使用新文件。 我正在使用joomla 2.5.7
谢谢
答案 0 :(得分:4)
您不需要覆盖view.html,只需要覆盖com_content / views / article / tmpl / default.php。只需在
中复制一份/templates/your_template/html/com_content/article/default.php
并编辑副本。然后你可以使用
$document = JFactory::getDocument();
$document->setMetaData(...
更改元字段。最终它们将由模板呈现,因此您不需要自己输出元数据。
您可以在组件或模板中的任何位置执行上述操作,但不能在模块中执行上述操作。
答案 1 :(得分:1)
您无法在view.html.php
文件上执行模板覆盖 - 如果要执行此操作,则必须编辑核心文件。不要忘记你可以在文章参数中设置文章的元描述(它在编辑/新文章视图的手风琴中)。
在您进行这些更改之前,最后将您的Joomla版本更新为2.5.9 - 因为您应该更新,但您将更新view.html.php
更新