Каноникал дублирует сайт, что делать?

// add canonical
if ($this->app->system->document instanceof JDocumentHTML) {
$this->app->system->document->addHeadLink(JRoute::_($this->app->route->item($this->item, false), true, -1), 'canonical');
}

Это в зоо, кто поможет разобраться?

Вот фрагмент файла, мур прав, это зоо, что у меня не так?

Код:
<?php
/**
* @package   com_zoo
* @author    YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
*/

/*
    Class: DefaultController
        Site controller class
*/
class DefaultController extends AppController {

    public $application;

     /*
        Function: Constructor

        Parameters:
            $default - Array

        Returns:
            DefaultController
    */
    public function __construct($default = array()) {
        parent::__construct($default);

        // get application
        $this->application = $this->app->zoo->getApplication();

        // get Joomla application
        $this->joomla = $this->app->system->application;

        // get params
        $this->params = $this->joomla->getParams();

        // get pathway
        $this->pathway = $this->joomla->getPathway();

        // registers tasks
        $this->registerTask('frontpage', 'category');
    }

    /*
         Function: display
            View method for MVC based architecture

        Returns:
            Void
    */
    public function display() {

        // execute task
        $taskmap = $this->app->joomla->isVersion('1.5') ? '_taskMap' : 'taskMap';
        $this->{$taskmap}['display'] = null;
        $this->{$taskmap}['__default'] = null;
        $this->execute($this->app->request->getCmd('view'));
    }

    /*
         Function: callElement
            Element callback method

        Returns:
            Void
    */
    public function callElement() {

        // get request vars
        $element = $this->app->request->getCmd('element', '');
        $method  = $this->app->request->getCmd('method', '');
        $args    = $this->app->request->getVar('args', array(), 'default', 'array');
        $item_id = (int) $this->app->request->getInt('item_id', 0);

        // get user
        $user = $this->app->user->get();

        // get item
        $item = $this->app->table->item->get($item_id);

        // raise warning when item can not be accessed
        if (empty($item->id) || !$item->canAccess($user)) {
            $this->app->error->raiseError(500, JText::_('Unable to access item'));
            return;
        }

        // raise warning when item is not published
        if (!$item->isPublished()) {
            $this->app->error->raiseError(404, JText::_('Item not published'));
            return;
        }

        // get element and execute callback method
        if ($element = $item->getElement($element)) {
            $element->callback($method, $args);
        }
    }

    public function item() {

        // get request vars
        $item_id = (int) $this->app->request->getInt('item_id', $this->params->get('item_id', 0));

        // get item
        $this->item = $this->app->table->item->get($item_id);

        // get user
        $user = $this->app->user->get();

        // raise warning when item can not be accessed
        if (empty($this->item->id)) {
            $this->app->error->raiseError(500, JText::_('Unable to access item'));
            return;
        }

        // redirect to login if the user is not logged in and he cannot see the item
        if(!$user->id && !$this->item->canAccess($user)){

            $return = urlencode(base64_encode($this->app->route->item($this->item, false)));
            $link   = JRoute::_(sprintf('index.php?option=com_user%s&view=login&return=%s', ($this->app->joomla->isVersion('1.5') ? '' : 's'), $return), false);

            $this->setRedirect($link, JText::_('Unable to access item'), 'error');
            $this->redirect();
            return;
        }

        // Show error message if logged in and cannot access item
        if($user->id && !$this->item->canAccess($user)){
            $this->app->error->raiseWarning(403, JText::_('Unable to access item'));
            return;
        }

        // add canonical
        if ($this->app->system->document instanceof JDocumentHTML) {
            $this->app->system->document->addHeadLink(JRoute::_($this->app->route->item($this->item, false), true, -1), 'canonical');
        }
 
Последнее редактирование модератором:
Назад
Сверху