I am using the below PHP code to set the page title and the description meta tag within an article
$doc =& JFactory::getDocument();
$options = $doc->getHeadData();
$options['metaTags']['standar开发者_JAVA百科d']['description'] = "test description";
$options['title'] = "my title";
echo '<pre>'; print_r($options); echo '</pre>';
$doc->setHeadData($options);
Thanks for to my print_r
I can see they are properly set. However the head data gets overwritten by Joomla after setHeadData
and this is what I get in my page:
<title>
tag gets simply overwritten with the article title value.
[Q1] Is there anything I can do to prevent Joomla from overwriting the head data that I set? (maybe inserting my code inside a plugin or module would allow me adding data after joomla has added its own?)
Your code needs to be in a plugin that executes late in the process. Here is the documentation on all of the global system events that are automatically triggered by the framework -
http://docs.joomla.org/Reference:System_Events_for_Plugin_System
Here is the documentation on the API order of execution -
http://docs.joomla.org/API_Execution_Order
精彩评论