Re: clean url in news module
If anyone knows how I can clean the URLs I much appreciate your help
Thanks
Re: clean url in news module
Hello,
There is an option "Enable auto_item" in the "Settings" menu that removes the items/ or events/ part.
Your URL will be
http://mysite.com/news/example-news.html
instead of
http://mysite.com/news/items/example-news.html
But I don't know how to get to http://mysite.com/example-news.html, sorry.
Re: clean url in news module
The only way to do the latter is to use a combination of the "generateFrontendUrl" and "getPageIdFromUrl" hooks to rewrite the URLs on the fly, and then direct them to the appropriate place. I believe there are examples already on the forum.
But this is messy and prone to error. "news/" specifically is very important in helping Contao route requests to the appropriate page. "items/" is also important, but can be removed reliably with the right logic (as it's done in the auto_item parameter mentioned before).
"/news/items/example-news.html" is interpreted by the system as "/news?items=example-news". That last part is important in telling Contao which news item to display. But the "news" part is equally important in telling Contao which page to display.
If you remove everything and just have "/example-news.html", how does Contao know how to interpret it? Is "example-news" a page, an article, a news item, an event? Which table does it go to retrieve the appropriate record? And which Object does it instantiate and plug that record into?
This isn't a problem with some other CMS's out there like Wordpress because they shove ALL of the content into the same table, regardless of what type it is -- a page, post, event, whatever. And big picture wise, that's not a great way to do it for a number of reasons, but it's necessary for how those systems are designed.
I get into this discussion with my SEO-happy colleague every project, so I wanted to share... :)