php - Display different data if the page URL matches address's in an array? -
i have html table has various data in upon reaching address, need display different data.
now, easy enough when checking against 1 url following data have setup as:
{$page_details.url} but scenario come need apply change of data on collection of page urls , without writing lots of {if} {else} statements hoping there way of achieving this?
i thinking of along these lines...
having array stored on template has urls stored within , write 1 {if} statement checking see if of values in array true , apply new data so:
{assign var="pages" value=[url-1,url-2,url-3]} {if $pages} {* display special data *} {else} {* display normal data *} {/if} and if landed on web page url of of values in array, ie. /url-3/ display special data instead.
could possible smarty, or php?
any appreciated. thanks
i believe you're looking this: http://php.net/manual/en/reserved.variables.server.php
i imagine urls same domain script? in case can current page's path with:
var current_page = $_server['request_uri']; // "/index.html" then based on example following display special data:
if in_array(current_page, $pages) you use javascript inside table:
var currentpage = document.url; var pages = [url1, url2, url2]; if (pages.indexof(currentpage) != -1) { document.write('your special data'); } else { document.write('your normal data'); }
Comments
Post a Comment