D
D
Dmitry2020-02-25 15:20:04
Yii
Dmitry, 2020-02-25 15:20:04

How to add a class in Yii2 if the page is not the main one for example?

Good afternoon, please tell me how to add a class in Yii2 if the page is not the main one, for example?

Is there a class <div class="header"></div>
how to add a class to the header if we are not on the main page?
to become like this:<div class="header header2"></div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eternalfire, 2020-02-25
@JoneCode

<?php if (\Yii::$app->request->baseUrl == '/'): ?>
    <div class="header"></div>
<?php else: ?>
    <div class="header header2"></div>
<?php endif ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question