Determine toolbar shown.

Permalink
Is it possible to determine whether the toolbar is shown? I now use
$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.

View Replies:
tpoth replied on at Permalink Reply
Did you solve your issue?
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
mhawke replied on at Permalink Reply
mhawke
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>";
}
?>
tpoth replied on at Permalink Reply
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:
.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:
<link rel="stylesheet" href="<?php echo $this->getThemePath(); ?>/css/layout.css" />
<?php 
$u = new User();
if ($u->isRegistered()) { ?><link rel="stylesheet" href="<?php echo $this->getThemePath(); ?>/css/layout_edit.css" /><?php } ?>


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
mhawke replied on at Permalink Reply
mhawke
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>
tpoth replied on at Permalink Reply
Good Morning,

this sounds like your solution for my problem ;-)
Thx alot
-Thomas
tpoth replied on at Permalink Reply
OK. this works fine.
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>
mhawke replied on at Permalink Reply
mhawke
Interesting... nice tweak on the #ccm-page-status-bar. I'll stick this in my snippet library.
hereNT replied on at Permalink Reply
hereNT
I like to do this with php and css.

<?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; ?>">


.page-body-wrap header.page-header {
   position: fixed;
   top: 0;
   left: 0;
   width: 100%;
   height: 175px;
   background: url('../../images/bgd_header_wide.png') 0 0 repeat-x;
   z-index: 100;
}
.can-write .page-body-wrap header.page-header {
   top: 49px;
}


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.