Determine toolbar shown.
Permalink
Is it possible to determine whether the toolbar is shown? I now use
but when a user has access to only certain dashboard pages and cannot edit a page this does not work.
$cp = new Permissions($c); if($cp->canWrite()){
but when a user has access to only certain dashboard pages and cannot edit a page this does not work.
Try adding this code just below your <body> tag:
<?php $pageObject = Page::getCurrentPage(); $p = new Permissions($pageObject); if ($p->canWrite()){ echo "<div style=\"height:49px;clear:both;\"> </div>"; } ?>
Good Morning,
and thx for your answer.
Yesterday i found the following that work's for me:
1st i created a new stylesheet (layout_edit.css), with the new top position for my top bar:
so the top bar is 50px beneath the toolbar of c5.
2nd i put the following snippet to my head section:
So at te moment this works for me.
I count on it to get side effects, hopefully not.
A better solution would be to check wether the toolbox is shown or not.
Another approach could be to check for a couple of groups, the logged in user is part of.
For the second approach i surely find a way to do it.
The first one could maybe a javascript solution, but i'm not a real js crack. So i don't know how to get it and do a clean solution
Just to mention, i started to c5 before about 5 days. There's just a lot to study about it ;-)
I'm happy to hear from you guys.
-Thomas
and thx for your answer.
Yesterday i found the following that work's for me:
1st i created a new stylesheet (layout_edit.css), with the new top position for my top bar:
.top_bar { top: 50px !important; }
so the top bar is 50px beneath the toolbar of c5.
2nd i put the following snippet to my head section:
So at te moment this works for me.
I count on it to get side effects, hopefully not.
A better solution would be to check wether the toolbox is shown or not.
Another approach could be to check for a couple of groups, the logged in user is part of.
For the second approach i surely find a way to do it.
The first one could maybe a javascript solution, but i'm not a real js crack. So i don't know how to get it and do a clean solution
Just to mention, i started to c5 before about 5 days. There's just a lot to study about it ;-)
I'm happy to hear from you guys.
-Thomas
Here's something generic that uses jQuery to detect if the toolbar exists in the DOM. Stick this code in your footer and play around with it:
<script type="text/javascript"> $(document).ready(function() { if ($('#ccm-toolbar').length) { alert('Toolbar Exists'); //Put code here to move your top <div> or your page wrapper <div> down: $('#header').css('margin-top','49px'); } }); </script>
Good Morning,
this sounds like your solution for my problem ;-)
Thx alot
-Thomas
this sounds like your solution for my problem ;-)
Thx alot
-Thomas
OK. this works fine.
I've just implemented my solution as follows:
I've just implemented my solution as follows:
<script type="text/javascript"> // This script checks if the ccm-toolbar is visible at this time $(document).ready(function() { if ($('#ccm-toolbar').length) { var tbheight = $('#ccm-toolbar').outerHeight(true); if ($('#ccm-page-status-bar').length) { var sbheight = $('#ccm-page-status-bar').outerHeight(true); tbheight = tbheight + sbheight; } $('.top_bar').css('margin-top',tbheight + 'px'); } }); </script> </body> </html>
Interesting... nice tweak on the #ccm-page-status-bar. I'll stick this in my snippet library.
I like to do this with php and css.
You can also adjust things for edit mode this way too. Using canViewToolbar() is better, too. Then if someone can change permissions, or access the dashboard, but not edit the page, you still make the adjustment.
<?php $c = Page::getCurrentPage(); $p = new Permissions($c); if ($p->canViewToolbar()) { $canWrite = " can-write"; } else { $canWrite = " no-write"; } $isEditMode = $c->isEditMode(); if ($isEditMode) { $edit = " edit-active"; } else { $edit = ""; }?> <body class="<?php echo $c->getCollectionTypeHandle(); ?><?php echo $canWrite . $edit; ?>">
You can also adjust things for edit mode this way too. Using canViewToolbar() is better, too. Then if someone can change permissions, or access the dashboard, but not edit the page, you still make the adjustment.
Here's the business:
All the above & adds ".ccm-page" + ".ccm-{template}" + ".ccm-{page_type}", also ".ccm-toolbar-visible" & ".ccm-edit-mode" as relevant.
Style ".ccm-edit-mode" & ".ccm-toolbar-visible" as required.
The toolbar is "48px" + "box-shadow: 0 2px 2px rgba(90,90,90,0.1);"
All the above & adds ".ccm-page" + ".ccm-{template}" + ".ccm-{page_type}", also ".ccm-toolbar-visible" & ".ccm-edit-mode" as relevant.
<?php // get page & page wrapper classes $c = Page::getCurrentPage(); $pageClasses[] = $c->getPageWrapperClass(); // toolbar visible $p = new Permissions($c); if ($p->canViewToolbar()) { $pageClasses[] = 'ccm-toolbar-visible'; } // edit mode if ($c->isEditMode()) { $pageClasses[] = 'ccm-edit-mode'; } ?> <div class="<?= implode(' ', $pageClasses); ?>">
Style ".ccm-edit-mode" & ".ccm-toolbar-visible" as required.
The toolbar is "48px" + "box-shadow: 0 2px 2px rgba(90,90,90,0.1);"
I've nearly the same challenge in my current project, which has a top bar pinned at absolute position top 0. So if the c5 toolbar is shown, my top bar goes away.
I tried the following:
A check if the page is in edit mode, but this only works, when the edit Button is just pressed.
I'd like to to switch my top bar position, right if the toolbar appears.
Any idea so far?
Thx
-Thomas