Forum

Thread tagged as: Problem, Runway

Page URL as a variable

I'm trying to get the full page URL as a variable but I'm struggling. I'm using URL patterns, but I can only get the physical pages URL not the URL in the browser bar.

I get this:

https://localhost/watches/brand/group-list/group-items/watch-item

When I want to get

https://localhost/watches/chanel/collections/j12-black/j12-classic-black-h1625

My Pattern is:

watches/[slug:brand]/collections/[slug:group]/[slug:watches]
Chris Comben

Chris Comben 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

How are you retrieving the URL currently?

At the moment I've got

$pageurl = perch_page_url(true);
PerchSystem::set_var('psys_pageurl', '$pageurl');

Although it outputs to the screen, but that's another issue I can fix later.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does this output?

$pageurl = PerchSystem::get_page(true);
PerchSystem::set_var('psys_pageurl', $pageurl);

That outputs

/watches/brand/group-list/group-items/watch-item
Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm, ok. Something else to try:

PerchSystem::set_var('psys_pageurl', $RoutedPage->request_uri);

HA! Nailed it :)

/watches/chanel/collections/j12-black/j12-classic-black-h1625

I'll add

'https://'.$_SERVER["HTTP_HOST"]

That should than get me the full URL, thanks so much!

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'll try and figure out a better way to handle this in the next release!