Jump to content
henriette

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

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Wow! Great answers and help.

I'm implementing according to your approaches right now and it works like a charm.

Thank you very much.

Cheers.

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
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).

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Atlasfreeman
      Hi!
      I want to make a small site, a one page site.
      And i have this idea about doing 2 to 3 diffrent template that i can load into the index / home page.

      I want to do this with an array so that i can keep creating more topics (with the template) id needed.
      <?php include('./head.inc'); // include header markup ?> <?php $children = $page->get('template=onecolmn|twocolumn, sort=sort'); foreach($children as $child) { include($child); } ?> <?php include('./foot.inc'); // include footer markup ?>  
      As you can see i have to template wish i want to control from the backend.
      I know include does not work this way, put what is my other option to make an array that loads the whole page on an other pages.
       
       
    • By iipa
      Hi fellow developers!
      I want to implement following action:
      Admin-priviledged user uploads a spreadsheet file (with many sheets) When page is saved, back end generates repeater items from the sheets We can render spreadsheet data from the repeater field. Profit! Currently I'm trying to find a way to read the uploaded spreadsheet file. ProcessWire doesn't seem to have modules suitable for my needs, but external PHP Library PhpSpreadsheet sounds like it could do the job. However, I can't even try it, because I simply don't understand how I can refer to an external library!
      Folder structure:
      templates _func.php > where I want to refer to the library libraries PhpSpreadsheet bunch of *.php > what I want to refer to I have tried different things varying from their documentation to forum posts and PW API with no luck. I would prefer not to use Composer, since it seems kind of overkill for one library.
      Thanks in advance and have a great day!
    • By nuel
      Hi there
      Basically I want to call code within a ProcessWire page that isn't used as a template. Example: www.mypwpage.com/myphpfile.php
      I have a working PW Website with a couple of pages like /artists, /releases, /videos etc. Now I need a page /download without any editable fields in the backend, just calling some PHP code (that was coded by another guy) containing a form that checks unique download-codes in a second database and starts the download of the desired file. The script is working fine right now as part of a static website, but since I built PW behind the site, this independent «Download Section» of the page doesn't work anymore.
      Right now I have the main file download.php as a page template on a newly created empty page called /download, so until now the form is working (wow). After sending the form containing the download-code, the file check_code.php in a subfolder /site/templates/download is called and that's where I get an error.
      Any help?
    • By matsn0w
      Hey everyone, hope you're all doing well!
      I'm building my first ProcessWire website at the moment, which is of course a very good way to understand all of the possibilities ProcessWire has to offer. But that also means that I'm facing some troubles now and then, and so is the case right now.
      I made a template for a couple of pages, like the homepage, the contact page, etc. I am using Bootstrap 4.0 for the layout. 
      So here's the deal: I want to show an alert box on top of every page, warning the user that the website is still under construction. Of course, I can just include the code and add the fields I made for the alert into the template, but that means I have to do that for every page, which I obviously don't want. So I made a template with the code and fields for the alert. When I did this, I realised that I can create multiple alerts this way, so I made two pages, containing different alerts. (And converted the code into a foreach-loop in the template).
      But now my question; how can I include these pages in a different template? Can I make a field or something to insert a page or is this simply not possible? Or do I have to approach this in a different way?
      I hope I explained my problem clear!
      Thank you in advance,
      matsn0w
    • By modifiedcontent
      I have one central website, with membership registration and content etc., and then several related websites with their own URL/domains, each on Processwire, all on the same server.
      I would like to access the database of the central website from the sister websites. How would I do that?
      You can't bootstrap one PW installation into another. You can include template parts from one in the other by just using the server path, but whatever you try to get/post just comes/goes to the database of the site you are on.
      Could you switch databases by including the config.php from another PW installation somewhere?
      What is the correct, secure way to do this?
×
×
  • Create New...