Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-12-31 08:14:26

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Inconsistent Behavior: txp:linklist vs txp:file_download_list

I’ve found that txp:linklist and txp:file_download_list do not behave the same when given an empty “wraptag” attribute. I’m trying to combine the output of txp:linklist and txp:file_download_list into a single list, like so:

<ul>
  <txp:linklist wraptag="" break="li" />
  <txp:file_download_list wraptag="" break="li" />
</ul>

txp:linklist wraps the links with <li> but txp:file_download_list does not. A look at the txp source confirms the different behavior. Is there good reason for this? Or would it be safe to change txp:file_download_list to have the same behavior as txp:linklist?

Seems like a bug and it would be great if it could be fixed in 4.0.8. ;)

Last edited by artagesw (2008-12-31 08:14:47)

Offline

#2 2008-12-31 08:54:51

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Inconsistent Behavior: txp:linklist vs txp:file_download_list

Submit a patch :)

Offline

#3 2008-12-31 09:08:39

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Inconsistent Behavior: txp:linklist vs txp:file_download_list

I’d be happy to submit a patch. But I’d like a dev to look at the existing code first and compare these two tag handlers. txp:file_download_list is making a special case of ul and ol tags and there is no comment in the code to explain why it might be doing that. There may be a good reason for it that I am unaware of.

Offline

#4 2008-12-31 12:09:43

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Inconsistent Behavior: txp:linklist vs txp:file_download_list

The break attribute is ignored if the wraptag attribute isn’t set and for anything other than ol/ul it assumes the break tag doesn’t surround the listed item. That doesn’t seem right, and like I am wondering if there is a special case where this is useful.

Offline

#5 2008-12-31 19:31:21

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Inconsistent Behavior: txp:linklist vs txp:file_download_list

I agree it doesn’t sound right. The txp:linklist tag works fine without making that assumption. In fact, it is more powerful to not require a wraptag, because that allows combination of tags such as what I am trying to do. I’ll patch my installation to verify that it behaves as expected with no strange side effects.

Offline

#6 2009-01-02 01:14:26

artagesw
Member
From: Seattle, WA
Registered: 2007-04-29
Posts: 227
Website

Re: Inconsistent Behavior: txp:linklist vs txp:file_download_list

OK, here’s the patch. Working fine for me.

diff -NBaur textpattern.cur/textpattern/publish/taghandlers.php textpattern.new/textpattern/publish/taghandlers.php
--- textpattern.cur/textpattern/publish/taghandlers.php	2008-12-31 18:09:48.000000000 -0800
+++ textpattern.new/textpattern/publish/taghandlers.php	2009-01-01 17:02:53.000000000 -0800
@@ -3286,12 +3286,7 @@
 			if ($out)
 			{
-				if ($wraptag == 'ul' or $wraptag == 'ol')
-				{
-					return doLabel($label, $labeltag).doWrap($out, $wraptag, $break, $class);
-				}
-
-				return ($wraptag) ? tag(join($break, $out), $wraptag) : join(n, $out);
+				return doLabel($label, $labeltag).doWrap($out, $wraptag, $break, $class);
 			}
 		}
 		return '';

Offline

#7 2009-01-04 18:42:34

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

Re: Inconsistent Behavior: txp:linklist vs txp:file_download_list

On a similar subject, I have been finding that if wraptag is ‘ul’ or ‘ol’ and break is empty, doWrap is not changing the break to ‘li’ as it should. This is true for me both on my local and live setups (both running TXP 4.0.8 and php 5.2.6). I am working on a plugin and tried giving break a default value of NULL and that didn’t work either.

I tested this with <txp:linklist wraptag="ul" /> and found the same thing: no <li> tags are added.

Going through doWrap(), I see that line 2627 catches the empty break attribute so that you never get to line 2638, where doWrap() tests for the empty break along with wraptag equal to ‘ul’ or ‘ol’.

Changing the match pattern on line 2627 from '/^\w+$/' to '/^\w*$/' fixes this. I don’t know if it causes other problems, but I don’t see how it would. Ack, does indeed cause problems.

Last edited by jsoo (2009-01-04 20:09:20)


Code is topiary

Offline

#8 2009-01-04 20:02:15

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Inconsistent Behavior: txp:linklist vs txp:file_download_list

That’s a good thing, actually. It allows you to add the <li> in the list form.

Offline

#9 2009-01-04 20:09:40

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

Re: Inconsistent Behavior: txp:linklist vs txp:file_download_list

OK, thanks

So, no need for lines 2638-2641 in taghandlers.php?

Last edited by jsoo (2009-01-04 20:12:15)


Code is topiary

Offline

#10 2009-01-04 20:24:43

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Inconsistent Behavior: txp:linklist vs txp:file_download_list

I think wraptag and break should be explicitly specified if you want to override them.
Assumptia is the mother of all screwups, so this is one place where TXP shouldn’t assume too much, IMO.

Offline

#11 2009-01-04 20:36:13

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

Re: Inconsistent Behavior: txp:linklist vs txp:file_download_list

Right, I’m just saying that on that basis there’s a vestigial block in doWrap() (lines 2638-2641). It can never be reached, because the block above it catches all cases where break is empty.


Code is topiary

Offline

#12 2009-01-04 21:59:46

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Inconsistent Behavior: txp:linklist vs txp:file_download_list

You’re right about that block of code never being reached. That is a bug. I think it should be removed, but that won’t happen in TXP 4.0.8. Thanks for reporting it though!

Offline

Board footer

Powered by FluxBB