Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2011-07-18 12:40:57

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,731
GitHub

Re: smd_countdown: time to an event

Bloke wrote:

Incidentally, shouldn’t your tag be:

<snip>

For completeness, yes, you’re right – but I’m doing something marginally clever and using smd_countdown in an article form, so when the article expires it just disappears…so it seemed that code was surplus as no-one was ever going to see it. I’m all about fast page loads and reducing workload for TXP and the browser, so it got chopped.

Last edited by gaekwad (2011-07-18 12:55:10)

Offline

#17 2011-07-18 12:44:57

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,455
Website GitHub

Re: smd_countdown: time to an event

gaekwad wrote:

I’m doing something marginally clever and using smd_countdown in an article form, so when the article expires it just disappears

Cunning, and logical. Only do what’s needed for the job. I like that.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#18 2012-03-27 11:50:09

Exiladler
Member
From: somewhere in Europe
Registered: 2006-08-20
Posts: 56
Website

Re: smd_countdown: time to an event

Hi,

I want to use the plugin and display the number of days left in a specific font, also using label before and after the countdown so need to isolate the number of days with a css id or class

“only 177 days to go”

tried to set class=“countdown” but no luyck so far, any suggestions?

Offline

#19 2012-07-25 11:05:40

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 638
Website

Re: smd_countdown: time to an event

Ohh..my mistake sorry, it wasn’t a countdown case.
(but I am going to use it for something else in the same project)
Thanks anyway

Last edited by THE BLUE DRAGON (2012-07-25 11:54:52)

Offline

#20 2012-10-04 14:07:27

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,731
GitHub

Re: smd_countdown: time to an event

I think I may have found a bug with v0.1

I’m using this markup:

(<txp:smd_countdown to="expires"><txp:else /><txp:smd_time_info display="day_total" labelafter="1" labelspacer=" " label="day to go, days to go" pad="" show_zeros="0" /></txp:smd_countdown>)

I expect to see something like this:

(3 days to go)

Instead, I see this:

(3 days to go
)

According to the browser inspector, there’s a <br> inserted after the ‘to go’. First off, and with all due respect to Stef, it shouldn’t be there. Second, if it’s used anywhere, it should really be a <br /> and not a <br>.

I’m a little wary of bleating about this since I may have my syntax wrong, and to be frank I can work around it, but I wanted to flag it.

Offline

#21 2014-01-23 10:19:10

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,731
GitHub

Re: smd_countdown: time to an event

Hi Stef (and everyone else smarter than I).
I’m hoping you could advise where I’m going wrong with this scenario, or give me a pointer. I’d like to display the number of days until article expiry. Here’s the smd_countdown code I’m using:

<txp:smd_countdown to="expires"><txp:smd_time_info display="day_total" /></txp:smd_countdown>

Here’s my code inline (excuse the squashed-ness):

<h4><small>Exp: <txp:if_expires><txp:expires format="%b %e, '%y" /> (<txp:smd_countdown to="expires"><txp:smd_time_info display="day_total" /></txp:smd_countdown>)<txp:else />none</txp:if_expires></small></h4>

…and here’s the output:

Exp: Jun 30, '14 ()

…and here’s the tag trace snippet:

<txp:if_expires>
[<txp:if_expires>: true]
<txp:expires format="%b %e, '%y" />
<txp:smd_countdown to="expires">
[<txp:smd_countdown to="expires">: false]
</txp:smd_countdown>
</txp:if_expires>

Article does expire, has a valid date recognised by if_expires, but smd_countdown doesn’t like it. What did I get wrong?

Thank you in advance.

Offline

#22 2014-01-23 20:05:36

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,455
Website GitHub

Re: smd_countdown: time to an event

gaekwad wrote #278388:

Article does expire, has a valid date recognised by if_expires, but smd_countdown doesn’t like it. What did I get wrong?

This is a case where perhaps my logic doesn’t line up with real people’s expectations. I did agonise for ages over it at the time, but decided that the ‘true’ branch of the conditional smd_countdown tag should actually be the scenario executed when the time is reached. The ‘else’ block is what gets executed all the time the event has yet to be reached. Example from the docs:

<txp:smd_countdown to="expires">
  Too late, you missed it :-(
<txp:else />
  There's still time to get to the show...
</txp:smd_countdown>

My reasoning was that if you were only interested in showing when some event was reached (and not interested in the meantime), you wouldn’t want to have to put an empty <txp:else /> for no reason. So although it seems slightly counter-intuitive, you either need to put an empty else in your smd_countdown tag or set your prefs to publish expired articles and put a message in, like this:

<h4>Exp: <txp:if_expires>
   <txp:expires format="%b %e, '%y" />
      (<txp:smd_countdown to="expires">
         Too late!
      <txp:else />
         <txp:smd_time_info display="day_total" />
      </txp:smd_countdown>)
   <txp:else />
      none
</txp:if_expires></h4>

Does my backwards-ass logic make some kind of sense now?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#23 2014-01-23 20:17:56

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,731
GitHub

Re: smd_countdown: time to an event

Bloke wrote #278409:

[…] the ‘true’ branch of the conditional smd_countdown tag should actually be the scenario executed when the time is reached. The ‘else’ block is what gets executed all the time the event has yet to be reached. […]

Does my backwards-ass logic make some kind of sense now?

Absolutely – and I should’ve read more clearly. Thank you, Stef – very helpful.

Offline

#24 2014-01-30 17:40:03

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,731
GitHub

Re: smd_countdown: time to an event

Hi again, Stef (and anyone else smarter than I).
Some time ago, I made reference to a bug that I suspected was inserting <br> into the code. Now I’ve come back to use this plugin again, I’ve pinpointed what appears to be triggering it.

This is the testing code containing the smd_countdown block:

<h4 style="padding-top:0rem;">
	<small>Exp: <txp:if_expires>
		<txp:expires format="%b %e, '%y" /> (
			<txp:smd_countdown to="expires">
			<txp:else />
				<txp:smd_time_info display="week" label="week, weeks" />
			</txp:smd_countdown>
		)
		<txp:else />
			none
		</txp:if_expires>
	</small>
</h4>

I was also using the labelafter attribute but I’ve stripped that out until I can figure our what I’m doing wrong. With that code above, this generates a spurious <br> after the label:

<h4 style="padding-top:0rem;"><small>Exp: Jun 30, '14 (weeks<br>21)</small></h4>

If I remove the label attribute:

<txp:smd_time_info display="week" />

…the <br> disappears:

<h4 style="padding-top:0rem;"><small>Exp: Jun 30, '14 (21)</small></h4>

What’s confusing me is that there’s no reference to <br> in the plugin code, nor is there mention in the documentation to say that it’s set as a break tag. I’d be grateful for some advice on this, if anyone can help, please. Thanks!

Offline

#25 2014-01-31 09:04:43

etc
Developer
Registered: 2010-11-11
Posts: 5,677
Website GitHub

Re: smd_countdown: time to an event

Hi Pete (not that I’m smarter…)

if you see doLabel() in the code, that’s your guy.

Offline

#26 2014-01-31 10:23:29

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,731
GitHub

Re: smd_countdown: time to an event

Hi Oleg – thank you for the info. I’ve also had a brief back-and-forth with Stef over email and you’re right: it’s doLabel(). I will figure out a workaround.

Offline

#27 2014-01-31 15:50:47

etc
Developer
Registered: 2010-11-11
Posts: 5,677
Website GitHub

Re: smd_countdown: time to an event

If you pass it through rah_replace, mind that it’s actually <br />, that your browser’s inspector displays as <br>.

Offline

#28 2014-02-01 01:21:36

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,731
GitHub

Re: smd_countdown: time to an event

It’s like you’re in my head, Oleg. I tried rah_replace with <br> and it didn’t work, so left it until I had time to investigate further. Once again you’ve saved me a bunch of time and work -thank you very much!

Offline

#29 2014-02-03 11:44:45

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,731
GitHub

Re: smd_countdown: time to an event

For completeness, here’s the code I used to get around the doLabel() snag:

<h4 style="padding-top:0rem;">
	<small>Exp: <txp:if_expires>
		<txp:expires format="%b %e, '%y" /> (
			<txp:rah_replace from="<br />" to="">
				<txp:smd_countdown to="expires">
				<txp:else />
					<txp:smd_time_info display="week" label="week, weeks" />
				</txp:smd_countdown>
			</txp:rah_replace>
		)
		<txp:else />
			none
		</txp:if_expires>
	</small>
</h4>

Mucho thanks to Stef and Oleg.

Offline

#30 2014-10-29 08:50:57

alivato
Member
Registered: 2011-03-31
Posts: 152

Re: smd_countdown: time to an event

How to delete <br>

<txp:smd_countdown to="31 Dec 2014 23:59:59">
<txp:else />
 <txp:smd_time_info display="day"
           labelafter="1" labelspacer=" "
           label="d." show_zeros="0" />
 <txp:smd_time_info display="hour"
           labelafter="1" labelspacer=" "
           label="h." show_zeros="0" />
 <txp:smd_time_info display="minute"
           labelafter="1" labelspacer=" "
           label="m." show_zeros="0" />
</txp:smd_countdown>

Last edited by alivato (2014-10-29 08:54:01)

Offline

Board footer

Powered by FluxBB