#1
So, on to my 2nd Trongate website - exciting times!

For this, a revamp of an existing website, I need urls in the format of: websitename.co.uk/product/fancy-product-seo-url

(and also: websitename.co.uk/category/fancy-category-seo-url etc.)

This fails, because there is no method called fancy-product-seo-url.

I have got it working by adding some edits around line of 204 of the ServeController function in Core.php:



Is this the only way or am I missing anything else?

I obviously don't want to add 10,000 custom urls to the custom_routing.php file. But maybe code can be added there, rather than in Core??
#2
Hello

For this, a revamp of an existing website, I need urls in the format of: websitename.co.uk/product/fancy-product-seo-url
For this when database is created a column called "url string" is what you are looking for.
Then use the 3rd segment in building your url
Dan
#3
Thanks for your reply Dan.

It is the second segment that I am using though. The segment that Trongate assumes is the function in the module.

I have it working perfectly but was wondering if there is a better solution, without having to edit the core code.
#4
It's quite easy. There's no need to mess with the engine folder. Custom routing is your best friend.

Here's some sample code for custom routing:



And here's some sample PHP code for a hypothetical 'product' controller:



So, now if you go to a URL like:



...then your site will behave as though the user has navigated to:

#5
That's great, thank you David.

Possibly, need another example in the docs to show a shorter custom url with two wildcards. (Because both examples still showed a second segment in the url, I didn't think it was possible).

Something for others to consider/remember, if trying a similar thing, is that the segments are based on the actual url rather than the displayed (custom) url so, in my case:

segment 1 stayed the same
segment 2 was `display` (the function part that I had hidden from the url)
segment 3 is the `url_string`
segment 4 is an optional `product_id`

The variables for the wildcards also have to be named: $1, $2 etc. I made the mistake of renaming these to (e.g to $seo_url) which didn't work.

And because I have an optional `product_id` segment, I had to create two custom routes, which had to be in this order. (Or at least I think something did not work as expected when they were not in this order):



And lastly, the final thing I did wrong was use the wildcard (:int) rather than (:num). (:int) does not work! Therefore, checking if the wildcard is an integer does not work - because it is a string.

Now all working with a lovely `seo_urls` table and `url` mod - to redirect old, or mis-typed urls - and a redirect to a store search if the url is still not found. So easy with Trongate!
#6
That's awesome.

The funny thing is... what you've asked for (and now done) is perfectly reasonable. However, I've never heard a request for that kind of thing before.

Anyway, well done!