如果页面URL与数组中的地址匹配,则显示不同的数据?

I have a HTML table which has various data in but upon reaching a certain address, I need to display some different data.

Now, this is easy enough when just checking against 1 URL with the following data I have setup as:

{$page_details.URL}

But a scenario as come up where I need to apply this change of data on a collection of page URLS and without writing lots of {if} {else} statements I am hoping there is another way of achieving this?

I was thinking of something along these lines...

Having an array stored on the template which has the URLs stored within and then write 1 {if} statement checking to see if any of the values in the array is true and then apply the new data like so:

{assign var="pages" value=[URL-1,URL-2,URL-3]}

{if $pages}
    {* display special data *}
{else}
    {* Display normal data *}
{/if}

And if you landed on the web page with an URL of any of the values in the array, ie. /URL-3/ it would display the special data instead.

Could this be possible with Smarty, Or PHP?

Any help would be greatly appreciated. Thanks

I believe what you're looking for is this: http://php.net/manual/en/reserved.variables.server.php

I imagine all the URLs are all for the same domain as the script? In which case you can get the current page's path with:

var current_page = $_SERVER['REQUEST_URI']; // would be something like "/index.html"

Then based on your example you could do the following to display your special data:

if in_array(current_page, $pages)

You could always just use this javascript inside the 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');
}