Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-05 16:25:56

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Opening a tag with txp:if_different, how to close it ?

I’m sure this is dumb easy, I can’t get my mind around it.

Let’s say you work with html lists. If you open a list with txp:if_different, how to close it outside the conditionnal ?

Example (form an article form):

<code>
<txp:if_different>
<li><txp:category1 title=1 />
<ul>
</txp:if_different>
<li>
<txp:permlink><txp:title /></txp:permlink>
</li>
</code>

On line 3, we open a ul tag, that need to be closed but only if it was open.

Hmmmm, ‘thinking while I’m typing. How 4.x handle nested form ?

Last edited by Jeremie (2005-12-05 16:26:35)

Offline

#2 2005-12-05 21:43:21

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Opening a tag with txp:if_different, how to close it ?

Put the “ul” tags around the call to the form in your page template.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2005-12-05 22:39:47

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

Re: Opening a tag with txp:if_different, how to close it ?

Just thinking out loud…

<code>
<txp:if_different>
<li><txp:category1 title=1 />
<ul>
</txp:if_different>
<li>
<txp:permlink><txp:title /></txp:permlink>
</li>
<txp:if_different>
<span><txp:category1 /></span></ul></li>
</txp:if_different>
</code>
and set the span to display:none?

Offline

#4 2005-12-06 01:31:15

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Opening a tag with txp:if_different, how to close it ?

Or maybe put it within an html comment?

Offline

#5 2005-12-06 08:31:48

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Opening a tag with txp:if_different, how to close it ?

How about this:-

<code>
<txp:if_different>
</ul>
<li><txp:category1 title=1 />
<ul>
</txp:if_different>
<li>
<txp:permlink><txp:title /></txp:permlink>
</li></code>
<br />

Then surround the tag in the page template with <code><ul></ul></code>. The only problem with this is that you get an empty <code><ul></ul></code> at the top which isn’t very semantic.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#6 2005-12-06 09:09:46

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: Opening a tag with txp:if_different, how to close it ?

You want to be mean to my code :(

I’m trying to do something somewhat clean if possible…

Offline

#7 2005-12-06 09:23:22

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Opening a tag with txp:if_different, how to close it ?

Ha haa. Well you could always put the “li” tags in after the first “ul” in the page template and use it for a title or something. I’m just trying to keep it simple here. ;)

In fact you would be able to give that top “ul” and “li” their own class so you could style them nicely. :)

Last edited by thebombsite (2005-12-06 09:27:48)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#8 2005-12-06 14:02:51

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: Opening a tag with txp:if_different, how to close it ?

Well, to explain I’m trying to do a sitemap.

So basically it’s structured like this :

  • A section
    • A category
      • an article of that category
      • an article of that category
      • an article of that category
    • Another category
      • an article of that category
      • an article of that category
  • Another section
    • A category
      • an article of that category
      • an article of that category
      • an article of that category
    • Another category
      • an article of that category
      • an article of that category
  • Again another section
  • A special link (like a forum
    • a sub special link
    • a sub special link

etc.

The thing is, with nested lists, I can’t get to see how to use the if_different tag to handle breaking the article sorting of a section into categories.

Edit: Ok there’s a nice bug with the forum’s Textile API. Section are level 1 of the arbo, categories are level 2, articles are level 3.

Last edited by Jeremie (2005-12-06 14:04:26)

Offline

#9 2005-12-06 15:36:15

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Opening a tag with txp:if_different, how to close it ?

Well you would need 2 “if_different” blocks for that, one for the sections and the second for the categories followed by the article listing so :-

<code>
<txp:if_different>
<li><h3><txp:section title=“1” /></h3>
<ul>
</txp:if_different>
<txp:if_different>
<li><h4><txp:category1 title=“1” /></h4>
<ul>
</txp:if_different>
<li><h5><txp:permlink><txp:title /></txp:permlink></h5></li></code>
<br />

But that’s going to leave a load of open “ul” and “li” tags at the end and you don’t know in advance how many it will be do you? Does it have to be a list? You could argue that they are all titles and use the “h” tags that I’ve put in without the ul/li tags. It could be styled to look like a list that way.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#10 2005-12-06 16:53:50

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

Re: Opening a tag with txp:if_different, how to close it ?

Couldn’t you use <txp:if_first_article> and <txp:if_last_article> for the opening and closing ul tags?

Offline

#11 2005-12-06 18:23:45

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: Opening a tag with txp:if_different, how to close it ?

Stuart, right now I only use one form per section. Aka I build the list by hand for each section, calling a txp:article_custom by hand. When I got that, it will always time to do something more elegant :)

And yep I have tried to move the sections and categories to headers tags, but that doesn’t solve the opening/closing ul problem.

Doggiez… well that’s a tought. I think I will try it.

Last edited by Jeremie (2005-12-06 18:24:45)

Offline

#12 2005-12-06 19:53:07

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Opening a tag with txp:if_different, how to close it ?

Well my sitemap is an article and done completely manually. It does use lists though. ;) I don’t think I could do it this way. Sometimes I’m pointing at an article and sometimes at a section. It doesn’t follow any logic that the “if_different” tag could pick up on. I do use it for both of my archives though. It is very useful.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

Board footer

Powered by FluxBB