Block not displaying
Permalink 1 user found helpful
I added a nav block to the footer of a site I am working on. When I am signed in or in edit mode it is visible. When I am signed out it is no where to be found. I have set up the nav through the default pages, set them up on child pages and made sure the permissions are set for users to read. Still nothing shows when logged out. Am I missing something? Here is the site I am working on:www.www.georgialawngrowers.com/development/...
link is updated. missed a letter. I set all the permissions to show, see the original post. That's why I don't get why I'm not seeing it. Your first suggestion might be a better reason it's failing but then why just that block? I'll have to check it out once i get home.
Here is my footer code. I have hard coded the nav now and same result, it appears when logged in and editing but not when logged out.
<code>
<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<div id="footer">
<!--<span class="powered-by"><a href="http://www.concrete5.org" title="<?php echo t('concrete5 - open source content management system for PHP and MySQL')?>"><?php echo t('concrete5 - open source CMS')?></a></span>-->
© <?php echo date('Y')?> <a href="<?php echo DIR_REL?>/"><?php echo SITE?></a>.
<?php echo t('All rights reserved.')?>
<span width="400" align="center" style="padding-left:210px;"><?php
$bt_main =BlockType::getByHandle('autonav');
$bt_main->controller->displayPages = 'top';
$bt_main->controller->orderBy ='display_asc';
$bt_main->controller->displaySubPages ='none';
$bt_main->render('templates/breadcrumb');
?></span>
<?php
$u = new User();
if ($u->isRegistered()) { ?>
<?php
if (Config::get("ENABLE_USER_PROFILES")) {
$userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>';
} else {
$userName = $u->getUserName();
}
?>
<span class="sign-in"><?php echo t('Currently logged in as <b>%s</b>.', $userName)?> <a href="<?php echo $this->url('/login', 'logout')?>"><?php echo t('Sign Out')?></a></span>
<?php } else { ?>
<span class="sign-in"><a href="<?php echo $this->url('/login')?>"><?php echo t('Sign In to Edit this Site')?></a></span>
<?php } ?>
</div>
</div>
<?php Loader::element('footer_required'); ?>
</code>
<code>
<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<div id="footer">
<!--<span class="powered-by"><a href="http://www.concrete5.org" title="<?php echo t('concrete5 - open source content management system for PHP and MySQL')?>"><?php echo t('concrete5 - open source CMS')?></a></span>-->
© <?php echo date('Y')?> <a href="<?php echo DIR_REL?>/"><?php echo SITE?></a>.
<?php echo t('All rights reserved.')?>
<span width="400" align="center" style="padding-left:210px;"><?php
$bt_main =BlockType::getByHandle('autonav');
$bt_main->controller->displayPages = 'top';
$bt_main->controller->orderBy ='display_asc';
$bt_main->controller->displaySubPages ='none';
$bt_main->render('templates/breadcrumb');
?></span>
<?php
$u = new User();
if ($u->isRegistered()) { ?>
<?php
if (Config::get("ENABLE_USER_PROFILES")) {
$userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>';
} else {
$userName = $u->getUserName();
}
?>
<span class="sign-in"><?php echo t('Currently logged in as <b>%s</b>.', $userName)?> <a href="<?php echo $this->url('/login', 'logout')?>"><?php echo t('Sign Out')?></a></span>
<?php } else { ?>
<span class="sign-in"><a href="<?php echo $this->url('/login')?>"><?php echo t('Sign In to Edit this Site')?></a></span>
<?php } ?>
</div>
</div>
<?php Loader::element('footer_required'); ?>
</code>
You're using the breadcrumb template, which only shows pages "above" the cur=
rent page in the sitemap -- so if you're on the home page, for example, noth=
ing will show up.
Try changing this line:
$bt_main->render('templates/breadcrumb');
To this:
$bt_main->render('view');
(It's possible there is some other problem as well, but this is the first th=
ing I would try).
-Jordan
>=20
rent page in the sitemap -- so if you're on the home page, for example, noth=
ing will show up.
Try changing this line:
$bt_main->render('templates/breadcrumb');
To this:
$bt_main->render('view');
(It's possible there is some other problem as well, but this is the first th=
ing I would try).
-Jordan
>=20
Thanks for the suggestion. Tried changing it to $bt_main->render('view'); but no luck. Still shows when logged in but not when logged out. For a closer look if you have other suggestions here is the un:admin and pw:IAysJC78 I appreciate the help.
What are the block permissions? Admin only? (Silly question I know. But it's caught me out a couple of times)
I hard coded it to the footer so would that matter? I have read permissions for everyone but write and delete for me only.
Probably doesn't. I only meant that there is a check box when you edit a nav-block that hides links that other users don't have access too.
Like I said. Silly question ;)
Like I said. Silly question ;)
Yeah, something very strange is going on there. Can you please ZIP the php file of whatever page type that is you're using for the home page and post that here to the forum?
I logged in as the admin and added an autonav block to the page normally (so not hard-coding it) just to see if it worked, and it did with no problems. The code you posted for that hardcoded autonav block doesn't appear to be hiding it at all so I have no idea why it's doing that... but maybe there's something elsewhere in that page type template that is effecting it (which is why you should post it here).
Weird...
-Jordan
I logged in as the admin and added an autonav block to the page normally (so not hard-coding it) just to see if it worked, and it did with no problems. The code you posted for that hardcoded autonav block doesn't appear to be hiding it at all so I have no idea why it's doing that... but maybe there's something elsewhere in that page type template that is effecting it (which is why you should post it here).
Weird...
-Jordan
Sure i can Jordalev, but its happening on all pages and multiple pagetypes are used. Basically, I started using the Plain Yogurt template and was altering it to my needs. So, would it stand to reason if it's happening on all pages with different page types that it's probably not them? But I'll post whatever you think is causing the problem. That info might change your thinking about what's causing it though. Let me know. Thanks in advance for all your help.
you could try
$block->getByName('navigation');
if($block && $block->bID>0)$block->display();
I have added an auto nav to the scrapboook which is where it should grab it from.
This may sound silly but do you have the content within the lagged in area of your footer.php in the elements folder?
ie. not signed in = "Sign in to Edit"
signed in = "Logged in as Username"
maybe near the <span class="sign-in">
I cant load up my dreamweaver at the moment to check how I do it on my site?
Also I would suggest removing your admin account/password from here if you are going to post an account maybe make it a timed account, rather then your super admin account. Its a potential security threat for your site as this is the interwebs and accessible to all.
I know in your post you posted code looks right but what about in your home page type where you call in the footer?
All seems very weird indead
Regards
$block->getByName('navigation');
if($block && $block->bID>0)$block->display();
I have added an auto nav to the scrapboook which is where it should grab it from.
This may sound silly but do you have the content within the lagged in area of your footer.php in the elements folder?
ie. not signed in = "Sign in to Edit"
signed in = "Logged in as Username"
maybe near the <span class="sign-in">
I cant load up my dreamweaver at the moment to check how I do it on my site?
Also I would suggest removing your admin account/password from here if you are going to post an account maybe make it a timed account, rather then your super admin account. Its a potential security threat for your site as this is the interwebs and accessible to all.
I know in your post you posted code looks right but what about in your home page type where you call in the footer?
All seems very weird indead
Regards
I tried your code and got a "Fatal Error". The code is in span tags located before the sign in/out and after the copyright and like I said looks fine logged in. In all honesty I think I'm gonna start from scratch and just build my own template like I should have in the first place. I think Plain Yogurt had a lot of stuff in it I just didn't need. Odd though I just don't get why it won't display.
sorry restarted got my dreamweaver back :) my last code is incorrect this will pull the info in.
$block = Block::getByName('navigation');
if( $block && $block->bID ) $block->display();
Can you also get other content to display?? before the signed in section?
Ie
<?php echo t('Test Content.')?>
$block = Block::getByName('navigation');
if( $block && $block->bID ) $block->display();
Can you also get other content to display?? before the signed in section?
Ie
<?php echo t('Test Content.')?>
WHAT THE FREAKIN' HELL????!!! I put the code back to what you see posted in my original question and it works! Great that it works but why not before???? By the way am changing the admin pw now. Thanks to all of you for your help.
I realized now that this may have actually been a cache issue -- usually that's the first answer anyone gives (Mnkras, where are you when we need you!).
If this comes up again, try clearing the C5 cache in Dashboard -> Sitewide Settings.
Glad it's finally working for you, though.
If this comes up again, try clearing the C5 cache in Dashboard -> Sitewide Settings.
Glad it's finally working for you, though.
This may be a really obvious question (aka "Is it plugged in?"), so apologies if it is. I noticed noone asked to have you double-check if the page you were working on was in publish or preview mode.
Its possible that your were in preview before and when you readded your code you flipped to published.
I bring this up because I've actually done this myself before, and your description sounded just like my previous situations....
Its possible that your were in preview before and when you readded your code you flipped to published.
I bring this up because I've actually done this myself before, and your description sounded just like my previous situations....
Not applicable in this situation -- the block was hard-coded into the template.
Just noticed that, disregard previous message. Thanks.
Another possibility is that the pages that the autonav block is trying to show are not published or don't have permissions to be shown to non-logged-in users (so the autonav block is actually there on the page but it has nothing to display).
BTW, your link doesn't work.