Search code examples
expressionengine

Expression Engine Template Re-use


I am building a site with EE and was wondering what peoples thoughts are on the situation I have.

Basically I have 3 different channels with similar data that when viewed need to be shown on the same template. So I have a channel for news, artists, and products. When I click on an item in any one of those channels I need to show that data in the same template regardless.

There are 2 ways I can think of to do this but was wondering if anyone had a more elegant solution.

  1. Check the URL and open my entries tag with the appropriate channel and then only use the correct custom fields for that channel in the template. (But this would mean I would need to duplicate the code per channel).
  2. Open my entries tag with all channels supplied and then put all 3 custom fields at the point in which I need them in the template.

Thanks


Solution

  • Typically you would either embed templates or use snippets to overcome this.

    For my solutions I have a template group named global_embeds which serves as a container for template views I'd like to reuse. This could be the head part and footer part of my general page layout.

    Then a snippet for some of the more trivial stuff (like item displaying).