Forum
Get url segment added to perch_custom_content
I have brand guidelines site with sections for each different brand e.g:
/brand-name-one
/brand-name-two
/brand-name-three
then
/brand-name-one/logo/
/brand-name-one/logo/variations
/brand-name-one/colours/
/brand-name-one/colours/usage
etc etc
Each brand index.php has a region for 'brand name', as the site shares templates the identifier is 'brand name' displayed on the page loaded like so:
// Used to identify which section of the site you're in
// Taken from the Brand overview page for each brand
perch_content_custom('Brand name', array(
'page'=> '/BRAND-NAME/index.php',
'filter' => 'brand-name',
'template' => 'brand-name.html'
));
On 'page' how do I get it to add the brand-name from first segment of the url:
'page'=> '/brand-name/index.php',
or is there a better way to do this?
Is it the current page? If so, you don't need to specify the
page
attribute.Not current page, taken from the top level page of the brand section. So it's been pulled from different levels within that section e.g. /brand-name/logo/variations
It would be good to have this also added to the body as a class.
there are 6 brands so wanted to keep things simple and just customise the bits required. e.g. brand name, body class etc
The simplest way to pop it out of the URL is:
Then
$brand
contains your brand name. You could use it like this:That's fantastic, thanks! Works perfectly and I can use if for the body class for css hooks too :o)
Here's how the page template looks: