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?
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}
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}
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}