Dynamic Page URL

Permalink
I am building a site for searching Apartments accross the U.S. When landing on a property page, I need it to dynamically include the State and City attribute in the page URL. Is this easily doable? And how would I go about it? I am quite adept in customizing C5 but have never had to modify the URL of a page like this.

Example:
Current path shows ashttp://www.mywebsite.com/properties/test-property/...
What I need ishttp://www.mywebsite.com/properties/state/city/name_of_property/...

Any help out there?

 
JohntheFish replied on at Permalink Reply
JohntheFish
Simplest is to create the pages in that structure

/whatever/statename/cityname/

eg
/whatever/california/losangeles/
/whatever/california/sanfrancisco/
/whatever/florida/miami/

Alternatively, you could create a single page and have a single page controller that takes parameters from the path. Below is pseudocode, not complete compilable code
class Whatever extends Controller{
function view($statename, $cityname){
}
}

If you opt for that, you will need to design the whole system about that single page controller.
aaronmarp replied on at Permalink Reply
I wish it was that easy. The main issue is that multiple "Property Owners" will be creating their own properties via Composer in the Dashboard. So I am looking for a way to automatically associate their listing by the address they enter in the Address Attribute. And then reflect that in the URL of the property when viewed.

Even if it was possible to create a new page for a city that doesn't exsist if a property is created with that city. In essence, create the city category page automatically if it didn't already exsist. Then add that property to it.
JohntheFish replied on at Permalink Reply
JohntheFish
You would need to re-write the url slug translating code.
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi aaronmarp,

I believe this might be an example of the code JohntheFish is referring to.
http://andrewembler.com/2015/05/auto-generate-page-locations-based-...

This code is on my todo list and I have not tried it yet, but I think it might work for your situation.

In the PageHandler class placePost() method, instead of using year and month for the path, you could use a state attribute and city attribute.