1

I am trying to display a rel="canonical" link in the header of a joomla 1.5 site when there is no translation for the main content.

I have succeeded in adding rel="alternative" pointing to the other languages by modifying the language selector module.

What I need to know is where in the joomfish code I can check to see if the main content is translated and and my code for the header.

I have looked in plugins->missing translation.php, and added the following code:

$doc=&JFactory::getDocument(); 
$getVars = JRequest::get( 'GET' );
$getVars['lang']='en';
$newURL = http_build_query($getVars);
$alternative=JRoute::_($newURL);
$customrel='<link rel="canonical" href="'.$alternative.'" />';
$doc->addCustomTag( $customrel );

The tag gets displayed in the head, but multiple times. I think this is to do with no translation results for menu items, modules and so on, so the code gets executed for each item. I just want it to execute for the main content item (be it com_content, or another component)

Thanks in advance

patterncatcher
  • 275
  • 2
  • 9
  • I found a way to do this in the missing translation, basically I wrote some conditional statements to discover if this row was the main content (checked view and id from request against the row), and to check it was not the default language before building the canonical url and displying the tag. I had to check for each component type on the system (content, my custom component etc) – patterncatcher Feb 19 '14 at 16:41

0 Answers0