How To Hide A Div In Main.php In Login Page And Show It In Remaining Pages

I have a div in main.php in layout directory. How can I hide from login page and make it available for the rest of the pages like menu bar.

Below is the div




<div style="height: 100px; width:100%;border-style: solid;

       border-color: #ccc" id="dashboard">                    

         <button class="box pos-demo" style="background-color: #BCF5A9" onclick="location.href='index.php?r=Messagesintable/admin'">Messages in table</button>

         <button class="box pos-demo1" style="background-color: #BCF5A9" onclick="location.href='index.php?r=Messagesintable/admin'">Scheduled Messages</button>

         <button class="box pos-demo2" style="background-color: #BCF5A9" onclick="location.href='index.php?approval=0&r=apartmentSettings%2Fadmin'">Unapproved Birthday Templates</button>

         <button class="box pos-demo3" style="background-color: #BCF5A9" onclick="location.href='index.php?r=Messagesintable/admin'">Not Reviewed Messages</button>

         <button class="box pos-demo4" style="background-color: #BCF5A9" onclick="location.href='index.php?r=Messagesintable/admin'">Unapprove Contact Templates</button>


       </div>




Now this is available as buttons in all pages. I want to avoid this in login page and make it visible in all pages. How can I do this

create second layout (main2.php) without that div and use this new layout only for login action ($this->layout=‘main2’; )

You can use your yii::app()->controller and I controller the drivers you use and depending on the contoller you show or hide


if (Yii::app()->control->action->id !== 'login') {

   //insert above

}

Yes… this will work… but it is the worst solution I have ever heard. It is against MVC principles to put logic that depends on controller or action name in views or layouts.

I think you are wrong. Take a look at the ‘visible’ attribute in CMenu::items of the main layout. However, you could set/pass a variable in the action to the view to switch what is shown.

But to each there own :)

‘visible’ is rather for checking user privileges to target URLs like ‘Yii::app()->user->checkAccess(…)’ or user/application state (‘Yii::app()->user->isGuest’ or ‘$model->status==xxx’) but not for referring to controller id or action id.

Solution with variable passed to view or with additional attribute in base ‘Controller’ class is much better and prettier :)