Dynamic Assets with Friendly URLs
By combining the asset system and the site guide system you can setup friendly-url pages to display your assets. This can be used to create urls that your content managers can use to easlier create new SEO friendly pages such as products or job listings.
For example, the url “onesite.com/product/*” can search for assets with the url “*”.
For example, a single-sign-on asset could live at “onesite.com/product/single-sign-on”.
The Asset should have a “URL” field where the content manager can specify the url to load the asset on. This field should be of the type “input box”.
Site Guide Setup
For the site guide route, we will be using the controller “listing” and the action “find”. This action searches the database for a value that matches a certain field on the asset.
The route setup can be completed under the “URL” section of the site guide.
For “Route Name”, place the base url of the asset type you are trying to load. For example, “product”.
For “Route Path”, place the base url and “/([^/]+)”. This is a regex to search the url for the string after the base url. For example, “product/([^/]+)”.
For “Route Reverse”, place the base url and “/$1”. This maps the regex from the route path to the first argument. For example, “product/$1”.
Controller & Action
For the “Controller” field, put “listing”. For the “Action” field, put “find”.
This maps the url route to the “Listing/Find” action.
For “Argument Map”, put “1=char_value”. This maps the $1 “Route Reverse” to the “char_value” get parameter.
For “Argument Defaults”, you will need the identifier of your asset and the url field. In addition, here is where you will place your smarty theme to display the asset.
For example: “field_id=2&listing_id=1234&setTheme=one:myTheme”.