0

I am experimenting with the template partials approach and try to figure out how to let the client choose a template for the entry he is publishing/editing. Adrienne Travis mentions Blueprints in conjunction with Structure. But thats another $100 for just getting to choose a template from the CP.

So I was wondering if there are any other ways to go. I have been playing a bit with Low Variables and Template & Snippet Select but no matter how I turn there is alwasy some parseorder thing to have me grounded.

So... any ideas?

/David

Oh, and this is what my wrapper-template looks like and I am hoping to replace the first line with contents from the layoutfield on the publishform.

{embed="_wrappers/homepage"}

{exp:channel:entries channel="ch-archive" limit="1"}
{exp:stash:set name="title"}<h1>{title}</h1>
{/exp:stash:set}
{exp:stash:set name="content"}
<p>{body}</p>
{/exp:stash:set}
{/exp:channel:entries}  
1

A simple solution for this would be to simply add a select dropdown to the publish page with each of your wrapper templates listed. So for example, if your select dropdown field is called {wrapper_template}, your template code would look like this:

{exp:channel:entries channel="ch-archive" limit="1"}
  {embed="{wrapper_template}"}

  {exp:stash:set name="title"}
    <h1>{title}</h1>
  {/exp:stash:set}
  {exp:stash:set name="content"}
    <p>{body}</p>
  {/exp:stash:set}
{/exp:channel:entries}  

This should work since the embed is parsed at the very end of the parse order. But this method should only be attempted with a single channel entry like you have it set here (limit="1"). Otherwise you could end up embedding multiple wrapper templates.

| improve this answer | |
  • Thanks! And sorry for not getting back earlier. Your solution is close to what I reconed but I insisted on leaving the wrapperembed outside the entriesloop (yeah I know, dont say it!). And then all the family had to endure this years issue of the unpleasant winter****** desease. – David S Mar 21 '13 at 18:48
1

One possible option might be to add a variable on the wrapper embed, which passes a value for the template being accessed. Within your wrapper, switchee could be used to adjust markup. Using your sample above:

{embed="_wrappers/homepage" template="templateA"}

Within your wrapper, it could then be utilized such as this:

{exp:switchee variable="{embed:template}" parse="inward"}
   {case value="Value1"}
      Content to show
   {/case}
   {case value="Value2" default="yes"}
      Default format
   {/case}
{/exp:switchee}

If you're using the pages module (or perhaps structure), the template selection could also be more user-friendly in the control panel using an add-on such as Better Pages or 'Plates.

| improve this answer | |
0

I'm a Structure man myself. But have you looked at Better Pages?

http://devot-ee.com/add-ons/better-pages

| improve this answer | |
  • Thanks for the tip. I have not looked at Better Pages for a long time but I had to try it now that you mention it. But I cant figure out how to contents of that field to the wrapper-template. – David S Mar 12 '13 at 20:08
0

I have used Plates before for this reason, and it works well. You can choose which of the templates they can choose from, and include thumbnails if you desire. You just need to have the Pages module installed, and you need to be sure you have the Templates field BEFORE the Plates field (by customizing the Publish Layout). I put it at the top of the main Publish page, then hide it. http://devot-ee.com/add-ons/plates

| improve this answer | |
  • I am afraid I will have to ask for a walkthrough on how to do this. I havent tried Plates but I tried BetterPages as Mark suggests but I simply dont know how to bring contents of that field to the template in the right stage of parsing. – David S Mar 12 '13 at 20:05
0

You could use a plugin, but it's pretty easy to do with {if} statements as well. Here's one of the ways we set this up for a client. There are other's but it was fairly simple.

Problem: Client needed the ability to create various lists that were basically collections of articles from their site or sometimes from other resources. But the lists were occasionally, single-column format, top 10 (in reverse order 10 ->1) top 10 (1-> 10), top 5, bullet list, image as bullet list, etc.

Solution:

  • Create a template for each format option. Displayed is a partial list of the various template options.

Template Options: List of Templates

  • Added a New Field. In the field_group related to the publish form, we added a new field, with the select template format option.

  • Create a 'filter' template. The filter template will determine from the post, which display template to use. The code we use looks like

    {exp:channel:entries channel="my_channel" limit="1" status="not Closed" require_entry="yes"}

    {if no_results}
        {redirect="archives/404"}
    {/if} 
    
    
    {if series_format=="two_column"}
        {embed="series/_two_column"}    
    
    {if:elseif series_format=="numbered"}
        {embed="series/_numbered"}  
    
    {if:elseif series_format=="top_five"}
        {embed="series/_top_five"}
    
    {if:elseif series_format=="top_ten"}
        {embed="series/_top_ten"}   
    
    {if:else}
        {embed="series/_single"}
    
    {/if}
    

    {/exp:channel:entries}

    The 'filter' template has no styles or other details, but they could. In this case, we left all the formatting on the 'option' templates. We also embedded some secondary stylesheets, to handle reverse count list displays, and the selection of 'image' options, if the selected the bullet as image template.

But otherwise, new template designs can be added at any time. Once the new template is created, we basically update the drop down menu field, which contains the template options, and the 'filter' template that contains the {if}{if:else} statements.

No plugins required.

| 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.