I am using the Google Analytics module to retrieve the most popular articles on my site during the past day to populate a 'trending' block.
The problem is that the PageTitle
field comes from the meta data and includes a pipe and the site name. I would like to strip that off the end of the string, but I can't figure out how to do it within the view using rewrite results
.
I created a views-view-field--pageTitle.tpl.php file and edited it to this:
<?php
$output = str_replace(" | My Site", "", $output);
print $output;
?>
this doesn't seem to work...
Using the a preprocessor into the template.php will definitely works. There is other options to change the page, but it depends of what modules and what set up you are using to generate that title, clearly is using a patter define somewhere, so without know that my advice is use a preprocessor like this