Page 1 of 1

[SOLVED] Problem with spaces in a link

Posted: Wed Dec 09, 2015 10:45 am
by ColonelBlimp
Hi,

Using 2.0.1.1, PHP 5.5.12

I have a problem with the link from a 'moreurl' for a news item. The front page of the site shows the summary with a link to 'Read more...' The link works okay, but the template name at the end of the link has non-escaped spaces.

Here is an example:

Code: Select all

https://thesite.org/news/6/1/Latest-news/d,News Detail.html
I would like to have the spaces at least translated to '%20' (without the quotes). Can anyone advise me as to what I am doing wrong?

The template code that is producing the summary is as follows:

Code: Select all

<article class="news">
  <h1>{$entry->title|cms_escape:htmlall}</h1>
{$entry->summary}
  <p>&nbsp;<a href="{$entry->moreurl|cms_escape:htmlall}" class="button">Read More...</a></p>
</article>
Many thanks

Re: Problem with spaces in a link

Posted: Thu Dec 10, 2015 1:25 pm
by velden
It's important to have a look at the {news ...} tag too. I assume you're using something like:

Code: Select all

{news detailtemplate="News Detail"}
Note that if you're using only one detail template AND make that template the default one, you can skip the detailtemplate parameter.

Code: Select all

{news}
This will generate urls without the template name in it.

If you still need to replace only the spaces: either give the template another name or use:

Code: Select all

{$entry->moreurl|replace:' ':'%20'}

Re: Problem with spaces in a link

Posted: Fri Dec 11, 2015 1:19 pm
by ColonelBlimp
Thanks for the reply.

You are correct about the {news} tag - it uses both the 'summarytemplate' and detailtemplate' parameters.

I'll try the 'replace' code. My fall back position is to rename the template without spaces, but that would make it inconsistent with the names of all the other templates.

Thanks again for the help. The site is up and running now: just tweaking things here and there.