Skip to content

Commit

Permalink
fixed canonical links were not creating the correct url for details v…
Browse files Browse the repository at this point in the history
…iews
  • Loading branch information
pollen8 committed Oct 6, 2015
1 parent 880615c commit bd267e1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion components/com_fabrik/views/form/view.base.php
Expand Up @@ -256,6 +256,12 @@ private function setMessage()
$this->message = $message;
}

/**
* Set the canonical link - this is the definitive URL that Google et all, will use
* to determine if duplicate URLs are the same content
*
* @throws Exception
*/
public function setCanonicalLink()
{
$app = JFactory::getApplication();
Expand All @@ -268,7 +274,10 @@ public function setCanonicalLink()
$data = $model->getData();
$formId = $model->getId();
$rowId = JArrayHelper::getValue($data, 'slug', $model->getRowId());
$url = 'index.php?option=com_' . $package . '&view=form&formid=' . $formId . '&rowid=' . $rowId;
$view = $model->isEditable() ? 'form': 'details';
$url = JRoute::_('index.php?option=com_' . $package . '&view=' . $view . '&formid=' . $formId . '&rowid=' . $rowId);

// Set a flag so that the system plugin can clear out any other canonical links.
JFactory::getSession()->set('fabrik.clearCanonical', true);
JFactory::getDocument()->addCustomTag('<link rel="canonical" href="' . htmlspecialchars($url) . '" />');
}
Expand Down

0 comments on commit bd267e1

Please sign in to comment.