Forum
remove slash from current route for use with css
I have setup a template that enables me to set variables from current route not page, so that I can dynmically change content etc all from the same template based on the route. I'm trying to use it also to add a class to the body tag to allow unique style changes based on route but it adds a slash at the start.
In the template I can remove the slash like so:
<perch:content id="current_route" replace="/|">
But how do I remove the slash for this code?
// Set system variable based on current route, this can then be accessed by perch templates
// perch_template.html = <perch:content id="current_route">
PerchSystem::set_var('current_route', perch_get(0));
// Set variable based on current route.
$currentroute = perch_get(0);
// Loads the global header template /admin/templates/layouts
// Dynamically Loads page title from the Page Details in the CMS
// Applies 'page' class to body tag in header from current URL
perch_layout('global.header', array(
'title' => perch_page_title(true),
'page' => $currentroute,
));
Current output is:
<body class="/name-of-current-route-in-url">
I need without slash:
<body class="name-of-current-route-in-url">
Thanks
Hello Mark,
You can use PHP's
ltrim()
:Thanks Hussein, but this now doesn't output anything?
Outputs:
Any other ideas or have I implemented it incorrectly?
Sorry it should be the other way around:
That did the trick ! Thank you Hussein
https://downloader.vip/whatsapp/ https://messenger.red/ https://hotstar.onl/ done