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
redguy
(Maciej Lizewski)
April 10, 2014, 1:58pm
2
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
jkofsky
(Jkofsky)
April 13, 2014, 3:03am
4
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
if (Yii::app()->control->action->id !== 'login') {
//insert above
}
redguy
(Maciej Lizewski)
April 13, 2014, 11:22am
5
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.
jkofsky
(Jkofsky)
April 13, 2014, 8:53pm
6
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
redguy
(Maciej Lizewski)
April 14, 2014, 9:57am
7
‘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