Claudiu
Claudiu

Reputation: 35

joomla com_content override

I need to make some changes in com_content/views/article/view.html.php

That file contains a class:

class ContentViewArticle extends JViewLegacy{

}

How can I override this class, because on some categories I need to set the meta description in another way than it is now?

I copied the core source file in: templates/my_template_name/code/com_content/views/article/view.html.php

I made some changes but it doesn`t work.

I think it doesn`t use the new file. I am using Joomla 2.5.7

Upvotes: 1

Views: 1588

Answers (2)

Riccardo Zorn
Riccardo Zorn

Reputation: 5615

You don't need to override the view.html but only the com_content/views/article/tmpl/default.php. Simply make a copy of it in

/templates/your_template/html/com_content/article/default.php

and edit the copy. You can then use

$document = JFactory::getDocument();
$document->setMetaData(...

to alter the meta fields. Ultimately they will be rendered by the template so you won't need to output the metadata yourself.

You can do the above anywhere in the component or the template, but not in the modules.

Upvotes: 4

George Wilson
George Wilson

Reputation: 5705

You can't do template overrides on the view.html.php file - you have to edit the core file if you're going to do that. Don't forget you can set the meta description of the article within the article parameters (it's within the accordion on the edit/new article view).

Finally update your Joomla version to 2.5.9 before you make these changes - as you should update but you'll loose changes to view.html.php with the update

Upvotes: 1

Related Questions