Add editable block to footer.php

Permalink 4 users found helpful
First Ill say what we're trying to do and hopefully someone will have an idea of how best to get to that goal.

We would like to add an element to the templates that can be managed within concrete gui. For example, a footer are with links, or images, etc. We would like to hard code a reference to the html content managed within concrete5 into the footer.php file.

I have been given code for autonav, but that's navigation and not referencing a specific block/snippet/scrapbook etc.

I just want to make it easy for the client to modify something that is displayed on every template without them needed to add that element to every template and page.

View Replies: View Best Answer
jgarcia replied on at Permalink Reply
The code I sent you via twitter actually hardcodes the block in a non-editable way. If you want it to appear on every page and be able to edit it, you would need to add it to a page type default. Let me know if you need clarification on that.
baskettcase replied on at Permalink Reply
Yes please :) Thanks!
jgarcia replied on at Permalink Reply
From the Dashboard go to Pages and Themes and then click "Page Types". On that page you will see a list of the Page Types within your site. What you will need to do is edit the Defaults for whichever page types your particular pages will be, and add the auto-nav in there. Then, whenever you create pages of that Page Type, they will automatically have the auto-nav block.
baskettcase replied on at Permalink Reply
Ok, yeah that's what is done currently. My client just wanted it hard coded into the template footer so that way whenever a new template is created it is automatically included. So it sounds like there is no way to call a non navigation block in the footer.php file?
jgarcia replied on at Permalink Reply
If you put it in the page type default, it WILL be automatically included. If want it hard-coded (which is different), than that is the code I sent you on twitter the other day. You can do this with any block - not just auto-nav.
baskettcase replied on at Permalink Reply
Im still new to concrete so I have a feeling Im not understanding how this works. Blocks I thought were unique "sections" that you can add to each page. So content block, php block, etc etc. So I could add a block to an area on a particular page through the gui, but I can't create a, for example, "scrapbook" item that I can then call by hard coding it within the footer.php file.

For example, a couple links and a couple graphics, a twitter icon, facebook icon, etc as a scrapbook item, or somewhere else? that I call directly within the footer.php file so it's automatically added to all template types that calls the footer. This also allows my client to edit the scrapbook item to change that footer content.

Maybe you are answering that question, but due to my lack of knowledge it's going over my head :)
jgarcia replied on at Permalink Reply
What you say about blocks is correct. 99% of the time you will add them through the CMS interface. However, you can also hardcode them into a template.

If there is something that you know for sure will be on every page and it will look exactly the same on every page, in my opinion, the best solution is to just stick it in the template.

So for example, if you want the auto-nav block in every page on your site, then you could hard-code it into the template using the code I sent you. The upside of this is that it will appear on every page in the same way. The downside (which may not even be a downside) is that you can't configure it via the C5 any changes would have to be done in the PHP code in the template.
juliankauai replied on at Permalink Reply
i am finding this a very interesting thread. for me there should be a nav menu at the top for a whole site. in the theme yogurt there are 5 page types. each page type has its own header that you can alter. you can create pages from these 5 different page types then once you are 500 pages into a site if you want to change the nav in the header you have to change each page. you can use aliases and perhaps put those into each of the 5 page types default page but that still means you have to change it in 5 areas not just one. also since i have tried it i have ended up 2 menus or menus with different fonts.

it seems much easier to have one place for a header nav just like the place for the logo.

also the footer is universal and it seem that that is hardcoded in yogurt but it is not accessible by the user for editing only.

i would like to allow other users to edit these (header and footer) without having to resort to hardcoded pages.

i am aware of the scrapbook which is a good thing but i don't think it really solves this need for a universal header and footer.

a couple more points that i have wanted to get out there. page types why have them? why not a pagetype called unbounded that has no banner and lets you do what you want on a page. now that you can use layouts to do columns you can do any sort of layout you want like right column, left column, full, with banner and without all from one page type. there seems no reason for page types unless you want to structure things for users or have a particular look. layouts have sets for that. that is one of the problems with wordpress. every page in wordpress looks like wordpress. why have concrete be limited like that by page types? why not have it be more unbounded?

it seems to me that concrete5 is moving in the direction of the unboundedness of hypercard (if you remember that) but for the web. hypercard for the web is very needed. something that allows non programmers to create pages with buttons and images and scripts to allow it (a site) to look like you want and behave the way you like. like hypercard you click new and you get a blank page. then you decide on a layout and drop in the items you want. beginners can work on the surface level and progress to making scripts with experts making blocks (like the old xmcd's) and modifying the underlying code.

concrete5 is great but if concrete5 could be hypercard for the web it would be huge. excuse me if i got kind of carried away philosophically. :)
andrew replied on at Permalink Reply
Nice, thoughtful post there.

I agree to having some misgivings about the way the header nav is handled. Not necessarily about the autonav or menuing blocks that we have, or about the idea of areas in general - or EVEN about master templates, which we have used in many situations (and I'll get to more later) but the fact that, when adding new add-ons to your site, which create new page types, add new sections to your site (e.g. the discussion forums add-on, or the eCommerce add-on) there is no header menu added by default. It'd be really nice if there were some way to designate a block as the preferred method by which a header nav or anything in an area gets displayed, and then have it show up that way across the entire site, even so that new add-ons that aren't coded to look for it specifically will still show the correct block.

Regarding page types: you are completely free to create your site without page types ;-) . Prior to 5.4 we didn't have layouts, so it wasn't as though we could create one large default page and give users the ability to split them into columns. But even now I don't know that I'd dispense with them. Small to medium web shops are some of the biggest users of concrete5, and its with them in mind that we've created page types and their associated templates in their theme's folder. When they do a design for a client, there are typically several different templates and form factors in use on a given site. Page Types gives them a way to easily translate those HTML templates into reusable concrete5 templates, locked down enough to keep their site consistent but still with the nice editing that concrete5 provides.
shooftie replied on at Permalink Reply
Hi, I followed your thread to the very bottom and it seems to be the closest to my problem but I am still unsure.

I have a content block in my footer.php... I populated this content block on the home page and was hoping that because this same footer.php is being used across the whole site, the content would be present [and still editable] on every new page that is added.

It's not! The block is there waiting but doesn't hold any of the content that I have put in.

Does the 'twittered' code that you speak of do this for me?

I am a newbie to Concrete5, less of a newbie to PHP...
jaredquinn replied on at Permalink Reply
The parameter given to the 'display' method of the Area object allows you to specify which page to get the content for the area from.

You can utilise this to always read the content from a specific page (in this example, we're using Page 1 - the Home page).

$dp = $c->getCollectionID() == 1 ? $c : Page::getByID(1,'ACTIVE');
$a = new Area('Footer');

The result of this is that your block will only be editable on the Home page, but the same content wherever that code gets executed (every page, if it's in your footer).

andrew replied on at Permalink Reply
I use this pattern a lot, myself. I think we might try and make a slightly more elegant version of this available in the core through some simple API methods, so it's not quite as much of a hack. Works well, though
whirlwind replied on at Permalink Reply
Thanks you for that nice snippet, it helped me alot in get my theme exactly how I wanted it

tacktack replied on at Permalink Reply
Thank you ! that's exactly what I was looking.
allcomm21 replied on at Permalink Reply
Please forgive a stupid question, but do you put this in the footer.php?
snagy replied on at Permalink Reply
Could you please send me the code I need to add to the footer.php so that I can make that area editable.
jordanlev replied on at Permalink Best Answer Reply
The code that person seems to be referencing (over a year ago) is for adding blocks that are *not* editable. If you want something in your footer that is editable (and you want it so edits will apply across all pages of your site automatically), the best thing to do is hardcode a global scrapbook block into your footer, like this:
<?php Block::getByName('Name of your scrapbook block')->display(); ?>

...Then go to Dashboard -> Scrapbook, create a new "global" scrapbook (if it doesn't already exist), add a content block there, and after you've added the block, edit its name to whatever name you used in the code above. For example, if the code was this:
<?php Block::getByName('Footer Content')->display(); ?>

...then you would name that scrapbook block "Footer Content".
Agetis replied on at Permalink Reply

I've tried your approach and it didn't work totally. I'm using a couple of block in the footer and when I applied your code to the footer.php the block text did show up, but the functionality of the block was broken.
Like for example I use the Email Newsletter form and when a user puts inside an email address that is already singed up he gets an error. With your approach I don't get this error feedback.
And even the css styling on some pages didn't work correctly.

Even hard coding the HTML into the footer.php didn't resolve the broken functionality of the Email Newsletter block.

Is really the only way to make a permanent footer on all my pages to copy the srapbook blocks to every page, even every blog page?

Need some support!?

thank you
jordanlev replied on at Permalink Reply
Yeah, some blocks unfortunately don't work well when they're placed on pages other than their original page. You might have better luck with the "Global Areas" addon (free in the marketplace). Designate one page to be the "central repository" for footer content, then put a Global Area block in the Page Defaults and point it to the one central page's footer area, and then use "Setup on Child Pages" to add it to every page *except* the one page you designated as the central one.

Hope that helps.
russellii replied on at Permalink Reply
I suppose this is a silly question but why is the footer treated as a special case, the nice thing about this cms is that editing is just click on the block and start, but for footers we have to edit the php code.
JohntheFish replied on at Permalink Reply
It all depends on the theme. The default themes have coded footers. Some of the other themes in the marketplace have editable areas for footers.
russellii replied on at Permalink Reply
Thanks, any themes you recommend I look at?