Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-06-22 13:17:53

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

txp:realted_articles with form attr still inserts break

I use form with <txp:realted_articles form="bbb" /> but break attr is inserted anyway:

	function related_articles($atts, $thing = NULL)
	{
		global $thisarticle, $prefs;

		assert_article();

		extract(lAtts(array(
	>>>		'break'    => br, <<<
			'class'    => __FUNCTION__,
			'form'	   => '',
			'label'    => '',
			'labeltag' => '',
			'limit'    => 10,
			'match'    => 'Category1,Category2',
			'no_widow' => @$prefs['title_no_widow'],
			'section'  => '',
			'sort'     => 'Posted desc',
			'wraptag'  => '',
		), $atts));

I think there should be something like this:

isset($form) ? $break="" : $break="br or value entered by user"

Last edited by the_ghost (2008-06-22 13:20:08)


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#2 2008-06-22 13:24:02

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

Re: txp:realted_articles with form attr still inserts break

I thought the break attribute of ‘br’ was just the default and if you didn’t want it then you added break="" to the tag? Or have I missed your point?


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

#3 2008-06-22 14:03:53

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: txp:realted_articles with form attr still inserts break

Yes, break="" works, but i thinks it’s nonsensically to add break if i’m using form. Remebmer, that form attr was added to related articles not very far ago, and break="br", i think, is rudimentary behaviour.


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#4 2008-06-22 14:14:33

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

Re: txp:realted_articles with form attr still inserts break

the_ghost wrote:

Yes, break="" works, but i thinks it’s nonsensically to add break if i’m using form.

I see what you mean. But more often than not it is useful to be able to specify a break inside a form so you can do:

<txp:related_articles form="art_list" break="li" wraptag="ul" />

And get back:

<ul>
<li>Article1</li>
<li>Article2</li>
<li>Article3</li>
</ul>

I think that’s how other tags work, so I see no reason why this should be any different, unless I’m being dense!

I will admit though that the ‘default’ break item does seem a little arbitrary across tags; sometimes it’s empty, sometimes it’s a ‘br’ and occasionally it’s an ‘li’ (I think, haven’t checked). I guess each tag’s default break is linked to its intended use?

Last edited by Bloke (2008-06-22 14:15:52)


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

#5 2008-06-22 15:29:53

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: txp:realted_articles with form attr still inserts break

I think we speak over liitle different things. My opinion is that if i specified a form attr, then i (or other newbie user) don’t expectatу that break tag will appear. In my variant it was like this:

<ul><txp:realted_articles form="bbb" /></ul>

form bbb:

<li class="box">
<txp:permlink title="Открыть статью"><txp:title /></txp:permlink><br />
</li>

I got:

<ul>
<li class="box">
<a href="/">Article 1</a>
</li>
<br />

<li class="box">
<a href="/">Article 1</a>
</li>
<br />

<li class="box">
<a href="/">Article 1</a>
</li>
<br />
</ul>

Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#6 2008-06-22 16:00:46

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

Re: txp:realted_articles with form attr still inserts break

the_ghost wrote:

I think we speak over liitle different things. My opinion is that if i specified a form attr, then i (or other newbie user) don’t expectatу that break tag will appear.

Yes, I think we speak of different things :-) It would be good to get someone else’s opinion on this matter.

For sure, if you are manually adding <ul> around your txp tag and manually adding <li>’s inside your form, you might expect the break to be ignored automatically. But the tag cannot predict how you are going to use your form; nor can it look to see if you have surrounded each item in your form with some other HTML tag; it’s clever, but it’s not SkyNet!

As far as the tas is concerned, you could have used it like this:

<txp:related_articles form="bbb" />
<txp:permlink title="Открыть статью"><txp:title /></txp:permlink>

Or you could have specified wraptag="div". Without the default break="br", all your titles would run into each other instead of being separated by a line break.

So my guess is the ‘default’ option assumes that most people will not be using a form and thus would prefer a simple <br />-delimited list of things instead of all the ItemsAppendedToEachOtherInOneLongList ;-)

A form is a more ‘advanced’ use of the tag and thus with it comes the notion that you should be aware of the defaults and override them if you are going to manually specify HTML tags yourself. While I agree that sometimes the defaults should just be blank so you can build them up yourself — an “opt in” policy — in ‘list’ tags, a minimum default of a line break is at least a starting point for people unfamiliar with the tags so they get something that sort of looks reasonable when using the tag without any attributes.

*shrug* that’s how I see it anyway.

Last edited by Bloke (2008-06-22 16:02:04)


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

Board footer

Powered by FluxBB