0

How to make custom template for entry? Example: site.com/service/repair/ I have 2 entry about repair. iPhone repair & iPad repair So how to make page with url site.com/service/repair/iphone-repair and unique template for this page?

1

Switchee by Mark Croxton would be of use here:

{exp:switchee variable="{segment_3}" parse="inward"}

{!-- Index page. Match empty string or pagination --}
{case value="phone"} 
    phone page
{/case}

{!-- Single entry --}
{case default="yes"}
    pad
{/case}

{/exp:switchee}

If you need to match an empty string or use pagination, use it like this:

{exp:switchee variable="{segment_3}" parse="inward"}

{!-- Index page. Match empty string or pagination --}
{case value="#^P(\d+)$#|''"}
    Index page
{/case}

{!-- Single entry --}
{case default="yes"}
    Single entry
{/case}

{/exp:switchee} 
| improve this answer | |
1

Or you could just make 1 template, with a route of service\repair\{any}. This template then gets all URL's with first 2 segemetns of /service/repair...

Then you cna switch on the segment_3, like so :

{if segment_3 == 'iphone-repair'}
  {embed="partials/iphone-specific"}
{if:elseif segment_3 == 'ipad-repair'}
  {embed="partials/ipad-specific"} 
{if:else}
  {embed="partials/mobile-generic"}
{/if}
| improve this answer | |
0

Another slightly different way, in your "repair" template:

{if segment_3 == ""}
  Your content for service/repair
{if:else}
  Your content for service/repair/iphone-repair (where segment 3 has a url_title)
{/if}
| 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.