Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

#2 2009-01-26 17:51:55

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

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

#5 2009-01-27 09:06:53

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

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

#7 2009-01-28 20:55:26

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

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

#8 2009-01-28 23:03:58

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

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

#9 2009-02-04 18:26:00

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

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

#12 2011-09-22 09:35:53

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,539
Website GitHub Twitter

Re: Insert </br> into article title field

Hi

is using

<txp:custom_field name="Title" />

can do the trick?

Offline

Board footer

Powered by FluxBB