Jump to content

How to create an generic editable footer in my template for users


henriette
 Share

Recommended Posts

Hello,

First of all, i like Processwire very much!

Here's my question.

How can i create a footer in Processwire that resembles my attached image.

The user must have the possibility to change the blocks in the footer (title, text) and the footer is included, so the changes are shown across the complete site.

- i would like to have a seperate section for generic block, so i could create an extra menu item in the backend, besides pages, called "generic blocks"?

- or do i have to simple create a page and attach it to a template called footer and not make it visible in the menu?

Anyways, could somebody tell me the best practice?

Maybe this is already dicussed in the forum, i couldn't find it, but if so, please redirect me.

Thanks in advance!

post-868-0-46312600-1355072790_thumb.jpg

Link to comment
Share on other sites

Hi Henriette

I have done a similar thing on a site I am currently working on.

There are a lot of ways you can do this. Here is a very basic version:

Create the fields for your three blocks - call them Block Title 1, 2 & 3 and Block Body 1, 2 and 3.

Create a template that includes these fields.

Now create a new page Called "My front Blocks" (I am being really predictable here) and use your template.

Go to Settings on the page and make it hidden (it should be published, however).

Now fill in your information.

That has given you the block content. You now need to call it into your footer.

In each position You need to call in the fields from My Front Blocks:

<?=$pages->get("/my-front-blocks/")->block_title_1 ?>
<?=$pages->get("/my-front-blocks/")->block_body_1 ?>

And so on.

I leave the layout to you!

You can do the same thing with a lot of other info while you are about. I create a page called Site Settings (with a matching template) and I put things like meta keywords, banner, blocks, site title, reusable phone number, anything that I may want to use all over the place. And then just call them into a template.

Getting really clever

If you want to go completely mad, you can create blocks template ( and associated blocks.php template file) and then create lots of blocks as pages, preferably as children to a hidden page like "blocks"

In your Site Settings template or where ever, you can then create a Page field type for each block (choose single and null on the details tab) and set the parent to Blocks and the field to select - a drop down, basically.

Now, one your Site Settings page, you can use the dropdown to choose which block you want for each position.

Your blocks.php template file will take care of the layout of the block information, you just need to call the pages fields into your footer.

For instance:

<?php echo $pages->get("/site-settings/")->name_of_pages_field->render(); ?>

The render() will then render the entire contents of the blocks page.

Does that help?

Joss

  • Like 4
Link to comment
Share on other sites

Welcome henriette.

There's several ways to archive what you want. Your ideas are on the right track, you definately want to create some "/footer/" page where you could enter the content for your footer then output the content of that page.

http://processwire.c...-settings-page/

Single page approach:

If you create a template "footer" and in the php file you just would output the markup and data of the page. You can make this page "hidden" to not show up in navigation.

Then in your main template, where you would include you just render the "/footer/" page like this.

echo $pages->get("/footer/")->render();

and the footer page template would be this (just example.

<div id="footer">
<?php
 echo "<h3>$page->title</h3>";
 echo $page->body;
?>
</div>

Subpages or repeater approach:

You could use repeaters or just subpages to create the 3 blocks. Repeater module is a great way to "repeat" a set of fields. It is not installed by default. See infos here: http://modules.proce...dtype-repeater/

If using subpages you would create children pages under maybe a page "/footer/". Then output them like this.

$blocks = $pages->get("/footer/")->children('sort=sort');
foreach($blocks as $block) echo $block->render();

If using repeater, it would be slightly different, but the repeater field is like a field that holds pages, but since you can't use render you'd have to output markup too. If repeater field is named "footer_blocks" with title and body field inside you'd do it like the following:

$footer = $pages->get("/footer/");
foreach($footer->footer_blocks as $block) {
 echo "<h3>$block->title</h3>";
 echo "<div class='footer-body'>$block->body</div>";
}
  • Like 4
Link to comment
Share on other sites

In a simple site these things can also go on the homepage template. Imagine, for example, a blog where the homepage doesn't have any content of it's own. You can simply populate it's template with fields for the footer, sidebars, and whatever else that would be global on the site.

  • Like 2
Link to comment
Share on other sites

If you are using bootstrap, you can get extra, idiotically clever.

You can call in your blocks into a bootstrap row as children in your template, and loop through them, limiting them to 4 results, perhaps.

Then set the container for each block to style="span3".

Now, in your pages list in admins it will take the top four blocks in the list and put them horizontally across your row (though this is responsive). Since you can move pages around you can choose which is the first four.

OR

You can create a page field to include in whatever template and use AsmSelect setting (on the input tab). That will allow you to multi select blocks AND reorder them from a list.

So basically, you can do what you like - the API is very versatile, or perhaps I should say, it is very non-committal and therefore allows YOU to be very versatile.

Joss

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

I always put these kind of things into the home template. If there are a lot of fields for a header or footer that I want a client to manage I stick them in a /FieldsetTabOpen/close set.

So you end up with tabs in the home page edit screen with something like this:

Content | Header | Footer | Children | Settings | View

  • Like 4
Link to comment
Share on other sites

  • 4 weeks later...
So you end up with tabs in the home page edit screen with something like this:

Content | Header | Footer | Children | Settings | View

PW newbie here: could you explain a bit more about how you make that happen?

Link to comment
Share on other sites

PW newbie here: could you explain a bit more about how you make that happen?

There is a 'special' field, called "FieldsetTabOpen". When you add to your template, it actually (unlike other fields) adds 2 items into your list - "FieldsetTabOpenName" and "FieldsetTabOpenName_END". This then creates new tab in your editor (when you edit page). So, if you want some fields on different tab, you create this field (the tab basically), and move all field you want to have on this tab between the opening end the _END item (in your template's field editor).

Link to comment
Share on other sites

Greetings everyone,

This is a terrific technique. I am playing with a kind of expansion of the idea and wanted to bounce it around here for discussion.

I want to have a single form called "header_footer" with two fieldset tabs: "header" and "footer." Then users could manager both parts in one form. In my various site pages, I would call the header and footer fields in their right places on the page.

I'm thinking the way to go is to create "header.inc" and "footer.inc" files that pull the relevant fields from the "header_footer" page with the $pages method. These ".inc" files are called in the usual way in all site pages.

Of course, it's not a bjg deal to ask users to handle two forms for the header and footer. But I'm looking at this as a general concept that could go beyond just the header and footer. For example, I imagine this becoming a way to create a single "control_panel" form where users can set all "universal" information in one place.

Thanks,

Matthew

Link to comment
Share on other sites

Hey Everyone,

Thanks for thr links Soma. I have seen some of this (you cited a good one earlier in this discussion).

I just wanted to put the general concept out to there -- discuss and show off possibilities and bounce around particular variations. It's pretty amazing how with ProcessWirw we can cook up such "control panel" features so intuitively.

Thanks,

Matthew

Link to comment
Share on other sites

There is a 'special' field, called "FieldsetTabOpen". When you add to your template, it actually (unlike other fields) adds 2 items into your list - "FieldsetTabOpenName" and "FieldsetTabOpenName_END". This then creates new tab in your editor (when you edit page). So, if you want some fields on different tab, you create this field (the tab basically), and move all field you want to have on this tab between the opening end the _END item (in your template's field editor).

Thanks. I'll check this out next time I'm working on a PW site.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...