Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-04-07 15:11:24

Siguo
Member
From: Beijing, China
Registered: 2008-05-22
Posts: 44

en...I want to report a bug

I’m using a table to display some database count numbers, than include some “0” returned by safe_count.

but that ‘0’ can’t be displayed by td().

I’ve checked the td() function and tag() function that td() used. here is the code:

function td($content=’‘,$width=’‘,$class=’‘,$id=’‘) { $content = (!$content) ? ‘ ’ : $content; $atts[] = ($width) ? ‘ width=”’.$width.’”’ : ‘’; $atts[] = ($class) ? ‘ class=”’.$class.’”’ : ‘’; $atts[] = ($id) ? ‘ id=”’.$id.’”’ : ‘’; return t.tag($content,‘td’,join(‘’,$atts)).n; }

and function tag($content,$tag,$atts=’‘) { return ($content) ? ‘<’.$tag.$atts.’>’.$content.’</’.$tag.’>’ : ‘’; }

seems this is because the “!content” get rid off my 0s. So I have to change these two functions to below:

function td($content=’‘,$width=’‘,$class=’‘,$id=’‘) { $content = ($content==’‘) ? ‘&#160;’ : $content; $atts[] = ($width) ? ‘ width=”’.$width.’”’ : ‘’; $atts[] = ($class) ? ‘ class=”’.$class.’”’ : ‘’; $atts[] = ($id) ? ‘ id=”’.$id.’”’ : ‘’; return t.tag($content,‘td’,join(‘’,$atts)).n; }

and function tag($content,$tag,$atts=’‘) { return ($content!=’‘) ? ‘<’.$tag.$atts.’>’.$content.’</’.$tag.’>’ : ‘’; }

solved this problem.

Offline

#2 2009-04-07 15:15:04

Siguo
Member
From: Beijing, China
Registered: 2008-05-22
Posts: 44

Re: en...I want to report a bug

……………….en I’m sorry, so ugly, I just don’t familar with the textile, please forgive me.

all I want to say is the !content in td() and tag() get rid off ‘0’ values.

Offline

#3 2009-04-07 18:34:24

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

Re: en...I want to report a bug

Siguo, you are just trying to output false that is impossible. Right? And integer zero happens to equal false in php as you probably know and the function does check against false as it should.

Thus, there isn’t exactly a bug, you just shouldn’t be using false, but a content, for example zero as a string. Your fix just removes usage of false, and adds check against “empty”.

Just let you know. That fix just changes what it checks against…

Last edited by Gocom (2009-04-07 18:38:33)

Offline

#4 2009-04-08 03:10:12

Siguo
Member
From: Beijing, China
Registered: 2008-05-22
Posts: 44

Re: en...I want to report a bug

hi, Gocom, I’m trying to output ‘0’, but the td() function will replace it with ‘&#160;’, because !(‘0’) == true.

I’ve canceled my fix, and use <td></td> in stead of td().

:)

Offline

#5 2009-04-08 05:40:56

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: en...I want to report a bug

Thanks for the report. Fixed in r3173.

Offline

Board footer

Powered by FluxBB