BcBaserHelper::afterRender PHP Method

afterRender() public method

After Render
public afterRender ( string $viewFile )
$viewFile string
    public function afterRender($viewFile)
    {
        parent::afterRender($viewFile);
        if (BcUtil::isAdminSystem()) {
            return;
        }
        if (empty($this->request->params['Site'])) {
            return;
        }
        if (isset($this->request->params['Site']['name']) && is_null($this->request->params['Site']['name'])) {
            return;
        }
        if (isset($this->request->params['Site']['device']) && $this->request->params['Site']['device'] != '') {
            return;
        }
        // 別URLの場合、alternateを出力(スマートフォンのみ対応)
        $pureUrl = $this->BcContents->getPureUrl($this->request->url, $this->request->params['Site']['id']);
        $agent = BcAgent::find('smartphone');
        $subSite = BcSite::findCurrentSub(false, $agent);
        if (!$subSite) {
            return;
        }
        $url = $subSite->makeUrl(new CakeRequest($pureUrl));
        $this->_View->set('meta', $this->BcHtml->meta('canonical', $this->BcHtml->url($url, true), ['rel' => 'canonical', 'media' => 'only screen and (max-width: 640px)', 'type' => null, 'title' => null, 'inline' => false]));
    }