CMS site url |
HI,
I working in CMS based website, in that i want show list of articles and magazines. i referred some magazine site, here they are displaying https://www.ttgmedia.com/news/news/just-a-drop-to-host-charity-night-with-wildlife-film-makers https://www.ttgmedia.com/news/news/marriott-to-spend-122bn-on-starwood-hotels-1600 https://www.ttgmedia.com/news/news/fco-urges-brits-to-exercise-caution-following-paris-terror-attacks-1588 they're displaying article headline in the url. how they worked? how to work with the cms site url? Thanks, Muthu
If it is a CI site, the news method in the news controller is collecting the variable which in this case is the url friendly article name.
The news method would then look up the article title in the ULR column of the database, or worse, replace the - with spaces and checking the real title - something like that anyway. Hope that helps, Paul.
@muthu
First, why: https://en.wikipedia.org/wiki/Permalink Search the internet with the word pair CodeIgniter permalink For generation of the corresponding slugs the function url_title() might help you. For slugs derived from non-English, maybe you will have to consider to apply transliteration to ASCII first. Slug generation could be automatic, human touch could be added also. New generated slugs should be checked for uniqueness and modified when it is needed to avoid collision. If your site is going to be multi-lingual, see this discussion: http://stackoverflow.com/questions/21985...e-websites My personal choice is different slugs for translated pages (plus the language segment). About how to store the relations page_id <-> slugs: Most of the solutions I've see rely on manipulation of routes.php. There data could be taken from a preliminary generated file or from database. Other possible way which I use is extension of the CodeIgniter's router class, reading from the database, and implementation of the lookup logic there. Links like https://www.ttgmedia.com/news/news/fco-u...tacks-1588 would simplify the logic, because the page_id is included, but for my needs I avoid them, because I don't consider them as permalinks. I prefer links without page_id like this one: https://www.ttgmedia.com/news/news/just-...ilm-makers Good luck.
@muthu
Since implementation of such feature is relatively complex, explanation practically is not enough. Take this CMS of mine and see how the permalinks/slugs work: https://copy.com/1KhKPIR6NMylTgsI Someday I am going to publish it on GitHub under the MIT license, when I get satisfied with code quality and features. |
Welcome Guest, Not a member yet? Register Sign In |