User Tools

Site Tools


Sidebar

tutorials:design_adv:examples:region_specific_html

Subdomain or Region Specific HTML

<tip c n>Note: Support does not do any html, php or smarty code tutoring. The code below is only designed to get you started. If you need additional tutoring or debugging for html, php or smarty you will need to consult with an external developer or purchase developer time through sales</tip>

Due to the flexibility of the Smarty template system you can determine specific html based on specific variables available within any page template of your custom template design. One of the most popular requests have to do with generating html specific to a region choice the client may have chosen for a region in the Geographic Navigation Filter addon feature. These specific code examples only work when the Geographic Navigation addon is installed, enabled and in use on your site. By way of example, suppose you wanted to set up region specific html for regions with subdomains like "us" and "ca". You could replace the code you want to be "region dependent" in the html template of your custom template set with Smarty loops like the ones below. That would display specific html based on the region choice in the geographic navigation choice. The first example will use the subdomain value from the url when the Geographic Navigation Subdomains feature is in use within your software:

{if $geographic_navigation_subdomain == 'us'}
     <!-- place html here specific to the us subdomain -->
{elseif $geographic_navigation_subdomain == 'ca'}
     <!-- place html here specific to the ca subdomain -->
{else}
     <!-- place html here that will be used when there are no regions in url or doesn't match one of the choices you create above-->
{/if}

If you weren't using the subdomains feature of the geographic navigation addon you can still create region specific html by testing against the region id within your Smarty loop. Something like:

{if $geographic_navigation_region == '123'}
     <!-- place html here specific to the '123' subdomain -->
{elseif $geographic_navigation_region == '124'}
     <!-- place html here specific to the '124' subdomain -->
{else}
     <!-- place html here that will be used when there are no regions in url or doesn't match one of the choices you create above-->
{/if}

You can find the region id for any region within the GEOGRAPHIC SETUP > REGIONS admin tool. You'll see the region id next to the region name.

The changes above or just a start. You would need to add a "elseif condition" for each region you wish to have specific html display for. What your html could be could be a block of html, displaying a specific <img> tag or something as simple as displaying specific text in a specific spot. What you do with it is up to your skills and imagination. Reference the smarty documentation site for any Smarty code help.

tutorials/design_adv/examples/region_specific_html.txt · Last modified: 2014/09/25 16:55 (external edit)