Our site has this call at the beginning to find the page’s name (e.g. product.html, product = name) and adds ‘-tabs’ to it to produce the variable $block_name:
<? $current_url = $_SERVER['REQUEST_URI']; // this will return everything after the http://www.domain.xx including preceding "/"
$block_name = preg_replace ("/^(?:.*)\/(.*).html$/", "$1-tabs" , $current_url); ?>
The variable is then used to call a static block later with this:
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId($block_name)->toHtml() ?>
It works fine if someone goes to http://example.com/product.html, but if I use any url tracking, like Analytics, and the url has this at the end:
http://example.com/product.html?utm_source=newsletter&utm_campaign=product_launch&utm_medium=email
Then the variable isn’t created properly and the static block doesn’t load.
Is there a way to ignore anything after the .html so that any tracking appending doesn’t impact the static block loading?
Thanks!
preg_replace("/^(?:.*)\/(.*).html\??.*$/", "$1-tabs" , $current_url)