Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-06-23 06:31:27

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

if different - show multiple days

i’m trying to get the hang of the powerful if_different tag.

i’d like to show:

May
   Thursday
           10
    Thursday 
           17

and so on but with this script it won’t do that

<txp:if_different>
<h2><txp:posted format="%B" /></h2>
</txp:if_different>
        <txp:if_different>
        <h2><txp:posted format="%A" /></h2>
        </txp:if_different>
    <txp:if_different>
    <h2><txp:posted format="%d" /></h2>
    </txp:if_different>

Last edited by mrtunes (2010-06-23 06:32:23)

Offline

#2 2010-06-24 18:03:46

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

Re: if different - show multiple days

maybe i should change the question to: how do you use if_different to display a calender-type view (obviously without the intricuicies of a real calendar)?

Offline

#3 2010-06-24 20:28:03

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

Re: if different - show multiple days

I don’t think it can work with your example.
You need to use the if_different tags in exactly the same order as is set in the sort attribute in your article tag. This would work:

<txp:article sort="posted asc">
   <txp:if_different>
      Year: <txp:posted format="%G" />
   </txp:if_different>
   <txp:if_different>
      Month: <txp:posted format="%B" />
   </txp:if_different>
   <txp:if_different>
      Day: <txp:posted format="%d %A" />
   </txp:if_different>
</txp:article>

What you are trying to do is not sorting by date: May, Thursday 10 – May, Thursday 17 – May, Thursday 24 – May, Thursday 31 – May, Friday 11 – …

If you want a calendar, but only show the dates that have articles, you could try smd_calendar and hide the article-less dates with CSS.

Offline

#4 2010-06-24 20:45:16

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

Re: if different - show multiple days

thank you els. i will give it another go later on.

last time i checked on smd_calendar, stef was planning on giving us the option to control its output (it’s in table format last i checked). waiting to see when the new version is out.

Offline

#5 2010-06-25 04:42:15

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

Re: if different - show multiple days

i was able to put down a better idea of what i’m shaping here:

Offline

#6 2010-06-25 05:12:16

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

Re: if different - show multiple days

with the amazing power of textpattern i was able to put something that resembles said mockup within approx. an hour.

i’m never short on kudos to this program!

<div id="events">
<txp:article_custom pgonly="0" section="eventstest"   sortby="posted" sortdir="asc" time="any">
<txp:if_different>
<h2 class="eventYear alignRight"><txp:posted format="%G" /></h2>
</txp:if_different>
<txp:if_different>
<h2 class="eventMonth alignRight"><txp:posted format="%B" /></h2>
</txp:if_different>
<div id="eventWrapper">
<div id="dater">
<txp:if_different>
<h2 class="eventDayName alignLeft"><txp:posted format="%A" /></h2>
</txp:if_different>
<txp:if_different>
<h2 class="eventDay alignLeft"><txp:posted format="%d" /></h2>
</txp:if_different>
</div> <!-- end dater div -->
/*             break               */
<div class="eventListing alignRight">
 <h3><txp:title /></h3>
<!-- some listing data -->
<txp:body /> 
</div> <!-- end eventListing class -->
</div> <!-- end eventWrapper div -->
</txp:article_custom>

Offline

#7 2010-06-25 12:24:29

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

Re: if different - show multiple days

Ah, was that what you meant, looks good. It doesn’t seem very logical to me not to display the day for every event, but that’s a personal preference I guess.
BTW sortby and sortdir are deprecated, use sort="posted asc".

Offline

#8 2010-06-25 13:39:56

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

Re: if different - show multiple days

thanks!

yes you are right, i still have to test what happens when i put an event in between thurs june 3 and thurs june 10.

if thurs june 10 has no day name in that scenario, then it would definitely be confusing.

Offline

Board footer

Powered by FluxBB