Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-01-26 17:17:32
- mrjysta
- Member
- Registered: 2008-09-22
- Posts: 89
Insert </br> into article title field
I need to add a </br> into the title field/
I have tried the == from textile and notext. but doesn’t seem to work/
Offline
Re: Insert </br> into article title field
Article titles are HTML-escaped, so this can’t be done. Also applies to the site slogan, as I learned recently, and presumably for the same reason.
Code is topiary
Offline
#3 2009-01-26 18:00:41
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Insert </br> into article title field
The good news is that I remember there was a plugin just for this. The bad news is I can’t recall the name. Try to search here or google.
Offline
#4 2009-01-27 00:43:02
- mrjysta
- Member
- Registered: 2008-09-22
- Posts: 89
Re: Insert </br> into article title field
Ok thanksguys ill look into it/
Offline
Re: Insert </br> into article title field
I took a quick look but didn’t see a plugin. Here’s one workaround. If you don’t like that, I just thought of another. It’s a pseudo-plugin.
Keeping in mind that you want titles to look correct in feeds, pick a placeholder for line breaks. It will have to be something you wouldn’t mind seeing in cases where it doesn’t get replaced (e.g. RSS feeds), and it will have to be something you wouldn’t otherwise want to use in a title. The vertical bar | could work.
Where you now have <txp:title />
, replace with <txp:output_form form="break_titles" />
. Then make a form, type “misc”, called break_titles (or use a different name if you prefer). Put this in the form:
<txp:php> global $thisarticle; assert_article(); echo str_replace(' | ', '<br />', $thisarticle['title']); </txp:php>
Note the string that gets replaced: ‘ | ‘, i.e. a vertical bar with a space on each side. Change this to whatever placeholder you pick.
YMMV.
Last edited by jsoo (2009-01-27 09:38:53)
Code is topiary
Offline
#6 2009-01-27 23:40:55
- mrjysta
- Member
- Registered: 2008-09-22
- Posts: 89
Re: Insert </br> into article title field
Awesome!!! This works great jsoo, thank you/
Offline
Re: Insert </br> into article title field
I think you can skip a step if you go ahead and use the <br /> (or <em> or whatever you need) in your article title, but output it with
<txp:php>
global $thisarticle;
echo $thisarticle['title'];
</txp:php>
instead of <txp:title />
Last edited by nabrown78 (2009-01-28 20:55:57)
Offline
Re: Insert </br> into article title field
You can, but then you will have titles in your RSS feed that look like:
My excellent article:<br />Part 2
which is why I suggested a workaround that would look OK in feeds too:
My excellent article: | Part 2
Last edited by jsoo (2009-01-28 23:04:26)
Code is topiary
Offline
Re: Insert </br> into article title field
Gotcha, that makes sense.
Offline
#10 2011-09-20 14:06:32
- pafruu
- Member
- From: New Brunswick, Canada
- Registered: 2010-01-14
- Posts: 65
Re: Insert </br> into article title field
LOOOOVING it! thank you so much for that trick
I try, and I try, and I try…. and sometimes I achieve
Offline
#11 2011-09-22 05:47:27
- alivato
- Member
- Registered: 2011-03-31
- Posts: 151
Re: Insert </br> into article title field
thx!
Offline
Re: Insert </br> into article title field
Hi
is using
<txp:custom_field name="Title" />
can do the trick?
Offline
Pages: 1