Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Apostrophes/single quotes in article titles
Hi.
I’m using this in an article form to output some footer links in a ul
:
<li><txp:permlink title='<txp:title /> was posted <txp:posted format="since" />'><txp:title /></txp:permlink></li>
…which outputs something like this on hover (article title
in this case is I like hot toast
):
I like hot toast was posted 4 hours ago
This is great, and exactly what I was expecting. However, if title
contains an apostrophe, the hover now looks like this (article title
in this case is I ate Stef's hot toast
):
I ate Stef’s hot toast was posted 3 hours ago
Which is not so great. Is there a way to change the '
to an apostrophe? I was wondering if rah_replace would do it, but it seems a little overkill for the task.
Thank you in advance.
Last edited by gaekwad (2012-09-15 11:17:25)
Offline
Re: Apostrophes/single quotes in article titles
If rah_replace
is already installed on the site, it’s fine to use it here. Otherwise, I can not find anything better than title='<txp:php>echo str_replace("' ;", "''", title(array()));</txp:php> was posted <txp:posted format="since" />'
Edit: delete the space between '
and ;
, textile is stronger than me.
Last edited by etc (2012-09-14 13:36:08)
Offline
Re: Apostrophes/single quotes in article titles
Thank you, Oleg — rah_replace
is already installed, so I’ll go ahead and use that.
Offline
Re: Apostrophes/single quotes in article titles
or use double quotes
<a href="<txp:permlink />" title="<txp:title />" ><txp:title /></a>
but then the title should be no double quotes.. :)
Last edited by makss (2012-09-14 17:14:28)
aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)
Offline
Re: Apostrophes/single quotes in article titles
makss wrote:
or use double quotes
Amazing, nice one!
Offline
Re: Apostrophes/single quotes in article titles
makss wrote:
or use double quotes
Hi makss.
Thank you for your reply. The problem I have with double quotes is parsing <txp:posted format="since" />
as it contains double quotes and is important to the output. I can’t test it right now, but would this work:
<li><txp:permlink title=”<txp:title /> was posted <txp:posted format=‘since’ />”><txp:title /></txp:permlink></li>
Last edited by gaekwad (2012-09-15 10:51:50)
Offline
Re: Apostrophes/single quotes in article titles
gaekwad wrote:
I can’t test it right now, but would this work:
<li><txp:permlink title="<txp:title /> was posted <txp:posted format='since' />"><txp:title /></txp:permlink></li>
Yes, it works, and that’s amazing. Not this one, but
<a href="<txp:permlink />" title="<txp:title /> was posted <txp:posted format='since' />" ><txp:title /></a>
will.
Last edited by etc (2012-09-15 11:16:18)
Offline
Re: Apostrophes/single quotes in article titles
etc wrote:
Yes, it works, and that’s amazing. Txp parser does marvels.
Thank you again, Oleg – I am very grateful for your assistance.
Offline
Re: Apostrophes/single quotes in article titles
Sorry, I was too fast. Actually, this one works too:
<txp:permlink title="<txp:title /> was posted <txp:posted format='since' />"><txp:title /></txp:permlink>
Txp parser does marvels.
Last edited by etc (2012-09-15 11:43:38)
Offline
Re: Apostrophes/single quotes in article titles
<txp:permlink title="<txp:title /> was posted <txp:posted format='since' />"><txp:title /></txp:permlink>
That shouldn’t be working, AFAIK.
Parsing tags in tags require simple quotes (at least, for a one-level depth).
The above line should be:
<txp:permlink title='<txp:title /> was posted <txp:posted format="since" />'><txp:title /></txp:permlink>
Offline
Re: Apostrophes/single quotes in article titles
maniqui wrote:
<txp:permlink title='<txp:title /> was posted <txp:posted format="since" />'><txp:title /></txp:permlink>
Thanks, Julián, that’s good to know — exactly what I was using in my opening post.
Offline
Re: Apostrophes/single quotes in article titles
maniqui wrote:
<txp:permlink title="<txp:title /> was posted <txp:posted format='since' />"><txp:title /></txp:permlink>
That shouldn’t be working, AFAIK.
That’s what I thought too, but I’m testing and retesting – it works. Could somebody confirm?
Offline