0

I am absolutely confused on what to do here

I have a footer that is meant to be different on each page I setup, I want to edit the link, the image, the paragraph and the header tags to what I choose, the current setup is as follows

<a id="contact"  href="{call_link}">
<footer class="footer">
  <div class="container">

  </div>
  <a href="/">
   <div class="zoom">
    <span class="footertextlarge zoom-image overlay" data-image-src="{footer_image}" ></span>
   </div>
  <footer class="footer container" >
  <h4>{footer_h4}</h4>
  <p>{footer_p}</p>

  </footer>
  </a>

Short of repeating this template and changing the variables etc every time I want to make a new template, how can I make this included template post the different content on different pages?

For example Homepage might have a link to {services page} and an image of {services image} services page might have a link to {contact form} with an image of {contact image}

but I want to be able to use the same template, and principle of changing the footer will go across hundreds of pages hundreds of pages eventually, I can't create a new template each time.

Thanks

  • templaye layouts are the way to go. See my answer here – Jelle Dijkstra Jun 13 '18 at 11:02
0

Expressionengine separates what information displayed on a page from the design of the page.

  • You code up the information to be displayed in one or more channels, with each entry in a channel representing a set of tagged data that you can choose to call up and display on a page.
  • You separately create one or more templates that includes instructions within to tell expressionengine which channel entries you want to display on that page.

The tags in your code snippet (e.g. {footer_h4}) describe fields that you defined to be part of an entry in one or more of your channels. In each entry you can put (within reason) whatever content you like - and so as each entry gets loaded up into the template, the actual information displayed in a browser changes - so it is really easy to have

a link to {services page} and an image of {services image} services page might have a link to {contact form} with an image of {contact image}

all you need to do is define one channel entry with the service image and link, and a second with the contact image an link - then a single template can be used to display them as two different looking pages.

Your question is not clear, but this may be all you are trying to do - in which case you only need to define one template and all of your hundreds of different channel entries can be set up to display different information using just one (i.e. the same) template: no need to create lots of templates.

In most sites the designers want more than one page design, and it is common (at least in EE sites, where it is super-easy to do) to blend information from multiple channels on the same page (so for example a blog entry pulled from one channel, author contact information pulled from another). So you most likely will have to design several templates, but the total number of templates will be much lower than the total number of pages on the site.

EE lets you get much more complicated, and has powerful tools for building really intricate dynamic sites (including for example, defining the footer of the page in a different template from the body, and using things like conditional rules to combine them in neat ways) (which is what Jelle's link points to), but until you've got a handle on simple channel / template mechanism I'd steer clear, you'll only get more confused.

HTH

| improve this answer | |
  • Thanks, I will try to be more clear, - imagine several templates each with an index, every template has the footer above pulled into it, not a problem, let's call one of those templates "portfolio" inside "portfolio" we have "portfolio_item" - all of these templates are using the embedded "footer", the problem is that I want "footer" to display a different image and have different link on EVERY page, obviously this is not a problem per template, but I can't find a way to do it PER POST. – dot voice Jun 14 '18 at 9:42
  • Sorry - being very dim here. If you want to put information into the footer that varies by post then why not simply put that information into the post entry template? If you want the be 'dry' and reuse the same footer template code on every post page, but have more than one post page template, simply put your template code into a template partial and add a link to that partial at the foot of your post template. – JCOGS Design Jun 14 '18 at 10:02
  • Go here, dotvoice.co.uk/draft/services.html, click on Web Design and look at the footer. then go back to the services page and click on graphic design, both are separate templates (with footer embedded), I want to use the same footer embed template but both with different content. I'm having issues because it would be a limit of one post with different content on each page and if I add a second post, it just overwrites the original, it does not 'post' to the other page - see image imgur.com/a/8CChHWl – dot voice Jun 14 '18 at 10:42
  • I think you are making this much more complicated in your mind than it really is. I'll add another answer with some suggestions. – JCOGS Design Jun 14 '18 at 13:24
0

Let's do this by example. Let's suppose we have a simple EE channel called "blog" with just five fields in:

  • Headline {headline}
  • Body Text {body}
  • Blog Image {blog_image}
  • Footer Text {footer_text}
  • Footer Image {footer_image}

If we define a two entries:

  • Entry_1 - {url_title} entry_1, {headline} "Entry 1", {body} "Blah blah", {blog_image} cats.jpg, {footer_text} "Do more with cats", {footer_image} cat_toy.jpg
  • Entry_2 - {url_title} entry_2, {headline} "Entry 2", {body} "Rhubarb", {blog_image} angry_cat.jpg, {footer_text} "Avoid angry cats", {footer_image} cat_spray.jpg

Then a simple template like this will display each entry and the footer will be different in each case (assume URL is of form /{url_title}):

{exp:channel:entries channel="blog" url_title="{segment_1}" dynamic="no"}
<h4>{headline}</h4>
<p>{body}</p>
<img src="{blog_image}">
<hr>
<h2>Footer</h2>
<p>{footer_text}</p>
<img src="{footer_image}">
{/exp:channel:entries}

Feed this template with the URL /entry_1 and you'll get something like this...

Entry 1
Blah Blah
[cat picture]


Footer
Do more with Cats
[cat toy picture]

Feed this template with the URL /entry_2 and you'll get something like this...

Entry 2
Rhubarb
[angry cat picture]


Footer
Avoid angry cats
[cat spray picture]

This appears to be all that you are trying to achieve - in your example links the page templates appear to be identical in material terms - so you could have used the same template for both there.

If you want to get bonus marks, you could put the template code for the footer into a template partial entry - let's suppose we move the footer code to a template partial called 'footer' thusly

Template Partial Name - footer
Template Partial Code - 
    <hr>
    <h2>Footer</h2>
    <p>{footer_text}</p>
    <img src="{footer_image}">

We could then modify the template generating our page to be a bit simpler - like this:

{exp:channel:entries channel="blog" url_title="{segment_1}" dynamic="no"}
<h4>{headline}</h4>
<p>{body}</p>
<img src="{blog_image}">
{footer}
{/exp:channel:entries}

This would give identical output, but you've moved the footer code elsewhere (and so could include it on other templates simply by adding {footer} to them).

Separately it is straightforward to access more than one entry in a single template, but explaining that is certainly outside scope of this question...

HTH

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.