How To: Auto-fill News URL field

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
cjcollen
Forum Members
Forum Members
Posts: 36
Joined: Sat Aug 04, 2018 4:20 pm
Location: Shropshire, UK

How To: Auto-fill News URL field

Post 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.
User avatar
Charles Butcher
Forum Members
Forum Members
Posts: 102
Joined: Sat Jul 05, 2008 8:25 pm
Location: Norfolk, UK

Re: How To: Auto-fill News URL field

Post 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.
cjcollen
Forum Members
Forum Members
Posts: 36
Joined: Sat Aug 04, 2018 4:20 pm
Location: Shropshire, UK

Re: How To: Auto-fill News URL field

Post 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 )
User avatar
Charles Butcher
Forum Members
Forum Members
Posts: 102
Joined: Sat Jul 05, 2008 8:25 pm
Location: Norfolk, UK

Re: How To: Auto-fill News URL field

Post 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>
cjcollen
Forum Members
Forum Members
Posts: 36
Joined: Sat Aug 04, 2018 4:20 pm
Location: Shropshire, UK

Re: How To: Auto-fill News URL field

Post 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 )
User avatar
Charles Butcher
Forum Members
Forum Members
Posts: 102
Joined: Sat Jul 05, 2008 8:25 pm
Location: Norfolk, UK

Re: How To: Auto-fill News URL field

Post 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.
Post Reply

Return to “Tips and Tricks”