Page 1 of 1

How To: Auto-fill News URL field

Posted: Mon Apr 06, 2020 8:43 am
by cjcollen
I have written an article on how to auto-fill the News URL field from the News title at the click of a button. The button functionality includes replacing spaces with hyphens, setting to lower case etc. This removes the need for re-typing into the URL field.

For example, the News title "How to auto-fill News item URL field" becomes "how-to-auto-fill-news-item-url-field" which is stored in the News URL field.

The article is part of the collection of CMSMS articles that I am writing for my website.

https://ccbswebservices.co.uk/cms-made- ... -url-field

I welcome your feedback.

Re: How To: Auto-fill News URL field

Posted: Mon Apr 06, 2020 5:07 pm
by Charles Butcher
Hi Christine, I haven't tried your method but this looks to be a worthwhile thing to do, and the article seems to explain the process clearly.

FWIW my own pretty URLs don't have the "/d,news-detail" bit at the end. I can live with the numbers in the middle.

Re: How To: Auto-fill News URL field

Posted: Tue Apr 07, 2020 8:56 am
by cjcollen
Charles Butcher wrote:Hi Christine, I haven't tried your method but this looks to be a worthwhile thing to do, and the article seems to explain the process clearly.

FWIW my own pretty URLs don't have the "/d,news-detail" bit at the end. I can live with the numbers in the middle.
Hiya Charles. Thanks for taking a look and for your comment.

I took a look at a news item on your site stanhoe.org and see that its url does not include that "/d,news-detail" bit at the end. I am wondering how you have done that and what I have missed in my own set-up.

I will have to investigate further as I don't like unknowns : O )

Re: How To: Auto-fill News URL field

Posted: Tue Apr 07, 2020 9:26 am
by Charles Butcher
Honestly I've no idea why it's like that. The site has been going for ten years and has changed hosting company twice in that time. I set up pretty URLs right at the start and it's always worked well.

With mod_rewrite:

Code: Select all

<ifModule rewrite_module>
	RewriteEngine on
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^(.+)$ /index.php?page=$1 [QSA, L]
</ifModule>

Re: How To: Auto-fill News URL field

Posted: Tue Apr 07, 2020 12:47 pm
by cjcollen
Hi Charles.

I found out why I was getting d,news-detail added to my News url.

In Design Manager, if you set a default template for News detail then you don't need to add the detailtemplate parameter to the News tag.

This was my News tag:

{News summarytemplate="news-summary-main" detailtemplate="news-detail" category="web design" pagelimit="2"}

which, although I had set a default in Design Manager, this tag outputs d,news-detail at end of URL.

So, changing it to this:

{News category="web design" pagelimit="2"}

drops this from the News url.

Mystery solved!

And thank you for pointing out your site's situation which forced me to take another look at mine : o )

Re: How To: Auto-fill News URL field

Posted: Tue Apr 07, 2020 3:21 pm
by Charles Butcher
Glad to be of help! Never did I think that an experienced CMSMS user could learn from me.

Your approach still has value for producing absolutely clean URLs. That would be good for blogging, I should think.