<meta name="viewport" content="width=device-width, initial-scale=1">
    <?php 
echo Html::csrfMetaTags();
?>
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <?php 
$this->head();
?>

    <!-- here comes hreflang tag output with alternative languages for this page -->
    <?php 
echo \DevGroup\Multilingual\widgets\HrefLang::widget();
?>
</head>
<body>
<?php 
$this->beginBody();
?>
<div class="blog-masthead">
    <div class="container">
        <div class="pull-right">
            <div class="pull-left lang-label">Language:</div>
            <?php 
echo DevGroup\Multilingual\widgets\LanguageSelector::widget(['blockClass' => 'b-language-selector dropdown pull-left']);
?>
        </div>
        <?php 
Пример #2
0
    public function testHreflang()
    {
        /** @var \DevGroup\Multilingual\Multilingual $multilingual */
        $multilingual = Yii::$app->multilingual;
        // test good domain
        $_SERVER['SERVER_NAME'] = 'example.ru';
        $_SERVER['REQUEST_URI'] = '/site/index';
        Yii::$app->trigger(Application::EVENT_BEFORE_REQUEST);
        $this->resolve();
        Yii::$app->handleRequest(Yii::$app->request);
        $this->assertEquals(2, $multilingual->language_id_geo);
        $this->assertEquals(2, $multilingual->language_id);
        Yii::$app->controller = Yii::$app->createController('/site')[0];
        $expected = '<link href="http://example.com/en/" rel="alternate" hreflang="en">
<link href="http://example.com/de/" rel="alternate" hreflang="de">
';
        $this->assertEquals($expected, HrefLang::widget());
        // test another url
        $_SERVER['REQUEST_URI'] = '/site/about';
        $this->resolve();
        Yii::$app->handleRequest(Yii::$app->request);
        $this->assertEquals(2, $multilingual->language_id_geo);
        $this->assertEquals(2, $multilingual->language_id);
        $expected = '<link href="http://example.com/en/site/about" rel="alternate" hreflang="en">
<link href="http://example.com/de/site/about" rel="alternate" hreflang="de">
';
        $this->assertEquals($expected, HrefLang::widget());
    }
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <meta http-equiv="content-language" content="<?php 
echo Yii::$app->language;
?>
">
    <meta name="generator" content="DotPlant CMS">

    <?php 
echo Html::csrfMetaTags();
?>
    <?php 
echo HrefLang::widget();
?>
    <?php 
$this->head();
?>

</head>
<body itemscope itemtype="http://schema.org/WebPage">
<?php 
$this->beginBody();
?>
<div class="m-wrapper <?php 
echo $mods;
?>
">
<?php