Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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
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
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 abr
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
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