I'm trying to build a Joomla article to display a photo the user selects. I'm using the Regular Labs Sourcerer plugin to place the required PHP code into my article.
I want to set various tags within the head of the document using PHP. So far I've been able to set the keywords and the description meta tags using the following code:
$document = JFactory::getDocument(); $document->setDescription("Your meta description"); $document->setMetaData('keywords', "keyword1,keyword2");
However, I can't set the title tag using the following similar code:
$document = JFactory::getDocument(); $document->setTitle("Your Title");
In this case Joomla displays the Browser Page Title from the article's menu item, and ignores the title I'm trying to set. Leaving the Browser Page Title blank doesn't help- a default value based on the menu item title is used.
I only require to set the title tag for one article on my site, so I'd prefer to use the PHP / Sourcerer method if possible, rather than edit template files.
Is it possible to set the title tag using PHP and Sourcerer, and if so, how is it done?