Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2009-08-27 11:39:53

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

Re: List problem

Initial <txp:variable /> assignment is missing?


Code is topiary

Offline

#26 2009-08-27 17:29:27

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List problem

jsoo wrote:

Initial <txp:variable /> assignment is missing?

It’s not missing, but it isn’t being parsed properly. And I just realized why… in my code example I forgot to close the variable tag… how embarrassing! Try this:

<txp:category_list>
   <txp:variable name="has_articles" value='<txp:article_custom section=''<txp:section />'' category=''<txp:category />'' limit="1" />' />
   <txp:if_variable name="has_articles" value="">
   <txp:else />
   <div class="module">
   <h4><txp:category title="1" /></h4>
   <txp:article_custom section='<txp:section />' category='<txp:category />' wraptag="ul" class="listing" break="li">
   <txp:permlink><txp:title /></txp:permlink>
   </txp:article_custom>
   </div>
   </txp:if_variable>
</txp:category_list>

Offline

#27 2009-08-27 17:36:43

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Re: List problem

Hi Els (+ Jsoo),

That works perfectly now, thank you so much for your time and effort – when I started down this route I had no idea it was going to be so complicated!

Offline

#28 2009-08-27 17:49:11

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: List problem

Great you got it working. Els – you know what to do with that code example…..!!!

Offline

#29 2009-08-27 19:05:40

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List problem

decoderltd wrote:

I had no idea it was going to be so complicated!

The code itself is fairly simple, it was me who made it complicated :-( If I hadn’t forgotten to close that tag in post #6 the thread could have ended there ;)

jstubbs wrote:

you know what to do with that code example…..!!!

You’re welcome to use it of course :)

Offline

#30 2009-08-28 12:19:31

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Re: List problem

Thanks again for all your help Els, really appreciate your time.

I’ve adapted your code so it pulls in a piece of section specific ‘intro’ text (each section has a short introductory paragraph)-

<txp:variable name="has_articles" value='<txp:article_custom section=''<txp:section />'' category=''<txp:category />'' limit="1" />' />
         <txp:if_variable name="has_articles" value="">
         <txp:else />
         <h4><txp:category title="1" /></h4>
         <txp:article_custom section='<txp:section />' category='<txp:category />' wraptag="div" class="intro" status="5">
         <txp:body />
         </txp:article_custom>
</txp:if_variable>

A couple of questions regards the final code, it currently pulls my lists so long as there is a category assigned, is there a way to have the code continue to behave as it does, but also produce an article list even if there is no category assigned?

Finally, there seems to be a series of <br /> appearing which I can’t trace back to any code, not sure if there is any connection…

<div class="module">
<h4>Articles</h4>
<ul class="listing">
<li>
</li>
<li>
<a href="http://www.gardensbydesign.uk.net/garden-notebook/garden-note-1" rel="bookmark">Garden notebook article 1</a>
</li>
</ul>
</div>
<br/>
<br/>
<br/>
<br/>

If I can get this to work then I can run most pages from a single form. Love those tags within tags – Textpattern nirvana!

Last edited by decoderltd (2009-08-28 14:34:38)

Offline

#31 2009-08-28 18:57:33

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: List problem

TextBook should be your first port of call whenever you encounter something strange.

In this case, see this entry in the article_custom page I linked to above for the following:

break="tag text"
The (X)HTML tag (without brackets) or string to separate list items.
Default: br.

Change your code like so to turn off the <br />

<txp:article_custom section='<txp:section />' category='<txp:category />' wraptag="div" break="" class="intro" status="5">
         <txp:body />

Offline

#32 2009-08-28 19:06:12

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List problem

decoderltd wrote:

I’ve adapted your code so it pulls in a piece of section specific ‘intro’ text (each section has a short introductory paragraph)-

I think you may want to remove the <h4><txp:category title="1" /></h4> from that code, because it leaves you with a pair of empty h4 tags.

it currently pulls my lists so long as there is a category assigned, is there a way to have the code continue to behave as it does, but also produce an article list even if there is no category assigned?

I’m not sure if I understand you correctly, but does it do what you want if you remove category=''<txp:category / >'' from the article_custom tag?

Finally, there seems to be a series of <br /> appearing which I can’t trace back to any code, not sure if there is any connection…

I think it’s the break attribute in category_list rather than in article_custom, Jonathan. So you’d have to change the opening tag to <txp:category_list break="">.

Offline

#33 2009-08-28 19:13:10

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List problem

jstubbs wrote:

In this case, see this entry in the article_custom page

Jonathan, thanks for pointing this out, the default value for break in article_custom is not br, but empty. I corrected the Textbook entry.

Offline

#34 2009-08-28 19:25:32

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: List problem

Is the category_list entry correct Els?

break="value"
(X)HTML tag (without brackets) or string used to separate list items.
Default: br.

I thought Wet said that category_list wraptag is set to empty by default, so why is the break tag adding a br tag? Would make more sense to keep it empty too, no?

Offline

#35 2009-08-28 19:35:31

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: List problem

jstubbs wrote:

Is the category_list entry correct Els?

Yes, unfortunately it is.

I thought Wet said that category_list wraptag is set to empty by default, so why is the break tag adding a br tag? Would make more sense to keep it empty too, no?

I couldn’t agree more. I’d prefer an empty default value for break in all tags that use the attribute.

Offline

#36 2009-08-28 19:53:06

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

Re: List problem

Els wrote:

I’d prefer an empty default value for break in all tags that use the attribute.

Confusingly, it is.

This ‘feature’ is a side-effect of the function doWrap() which a tonne of tags (and plugins) use to render their list output. As far as I can make out — would have to play with it some more — it tries to figure out if you’ve used a non-enclosing break (i.e. something other than a tag) and takes different action in each case. Perhaps it chooses wrongly sometimes.

I’ve noticed odd things with the break tag on occasion. Really must work out a definitive list of weirdness and try to find out why one day.

Last edited by Bloke (2009-08-28 19:54:16)


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