Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-06-20 08:06:07

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

<txp:expires formatting - &nbsp; instead of space

Hi.
I’m using expires to output the expiry time/date of a single article. It’s being used within a table context and as the table is dynamically sized, the result is spreading over two lines. I’d like to be able to replace the space characters in the output to &nbsp; characters so the line isn’t broken – that is, it’s a single line.

I’m using this syntax:

<div style=“text-align:center;”><txp:expires format=”%b %d, %Y” /></div>

Right now, I have this as a result:

Jan 01,
2013

…and I’d like to have

Jan 01, 2013

I can get around this by forcing the <td> to be a fixed/minimum width, but I’d prefer not to if it can be avoided in a native way. I can see the most logical fix would be to change the output to use &nbsp; instead of space, though I’m definitely open to other advice.

Thanks in advance.

Last edited by gaekwad (2012-06-20 08:06:58)

Offline

#2 2012-06-20 08:37:42

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: <txp:expires formatting - &nbsp; instead of space

gaekwad wrote:

I’d like to be able to replace the space characters in the output to &nbsp; characters so the line isn’t broken – that is, it’s a single line.

Well, you can use anything in the format, including HTML as you see fit. If you want non-breaking space there, you can use one. E.g.

<txp:expires format="%b&#160;%d,&#160;%Y" />

Offline

#3 2012-06-20 08:38:11

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: <txp:expires formatting - &nbsp; instead of space

I’d say that:

<div style="text-align:center;"><txp:expires format="%b %d,&#160;%Y" /></div>

would be the simplest option.

Of course, Gocom was faster, and Textile ate my & # 160 ;

Last edited by Bloke (2012-06-20 08:39:19)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2012-06-20 08:45:31

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: <txp:expires formatting - &nbsp; instead of space

Gocom and Bloke – thank you, you’re both absolutely right. Big appreciation, thanks for your time and input.

PS: it’s pretty obvious when you say it out loud…how embarrassing.

Last edited by gaekwad (2012-06-20 08:46:08)

Offline

Board footer

Powered by FluxBB