开发者

joomla API: head data overwritten

开发者 https://www.devze.com 2023-02-28 03:36 出处:网络
I am using the below PHP code to set the page title and the description meta tag within an article $doc =& JFactory::getDocument();

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:

[1] another empty description meta tag is added after mine (which is a problem as I don't know if search engines will process the first or the second).

[2] the <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

0

精彩评论

暂无评论...
验证码 换一张
取 消