Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2010-06-22 00:31:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,826
Website

Re: smd_countdown: time to an event

laptophobo wrote:

I viewed the page in a non-cached browser.

And? Was it any better?

simple countdown: e.g.: “x-number of days to go”

OK, so it’s like the way a competition would work then? For example, the competition opens at the Posted date of the article and runs until its expiry. And you want people to see how many days they have left to enter the competition before the expiry?

The plugin can totally help in this sort of scenario. The tag structure is exactly as you have it, you just need to use the <txp:smd_time_info /> tag to display the number of days instead of the fixed message you posted above. Plenty of examples in the plugin help should get you on the right road.

Last edited by Bloke (2010-06-22 00:35:24)


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

#12 2010-06-22 01:05:37

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: smd_countdown: time to an event

Re: 1st question. the countdown didn’t view.

With the new tag: nothing views. I even uninstalled and re-installed the plug-in.


Living the Location-Independent Life: www.NuNomad.com

Offline

#13 2011-07-17 14:26:44

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

Re: smd_countdown: time to an event

Hi Stef (or anyone else feeling clever).
I’m coming up against a bit of a hurdle with this. I would like to display the number of days before the article expiry occurs. This is my code, currently:

<txp:smd_countdown><txp:smd_time_info display="day_total" label="day, days" labelafter="1" show_zeros="0" labelspacer=" " class="" break="" wraptag="" /></txp:smd_countdown>

which outputs the number of days (with a leading 0 if it’s a single digit number of days), then a space, then ‘day’ or ‘days’, then a line break. I’m a little confused because I thought show_zeros dictates whether leading zeros are displayed, and with neither the wraptag or break set to anything, I figured it would display inline and not have any kind of break after the details are displayed.

Am I doing something wrong? Well, OK, I’m clearly doing something wrong, I’d very much like to know where I’ve made the error :)

Thanks in advance.

Last edited by gaekwad (2011-07-17 14:27:32)

Offline

#14 2011-07-17 19:35:41

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,826
Website

Re: smd_countdown: time to an event

gaekwad wrote:

I thought show_zeros dictates whether leading zeros are displayed

Not quite. It’s confusingly titled (suggestions welcome for v2!) but show_zeros="0" prevents any zero-count items from being displayed at all. Best explained with example: if you chose to display the number of weeks and days to go until your expiry, then:

  • with 30 days to go: “04 weeks 02 days”
  • with 10 days to go: “01 week 03 days”
  • with 5 days to go : “05 days”
  • with 5 days to go and show_zeros="1" : “00 weeks 05 days”

To silence leading zeros for individual numbers, check out the pad attribute. I think pad="1" will do the trick in your case.

Incidentally, shouldn’t your tag be:

<txp:smd_countdown to="expires">
   <p>TIME'S UP!</p>
<txp:else />
   <txp:smd_time_info blah blah />
</txp:smd_countdown>

?

and with neither the wraptag or break set to anything, I figured it would display inline and not have any kind of break after the details are displayed.

This one’s not your fault: it’s TXP’s fault and we have to work around it in this version of the plugin. I forgot to document it, which is bad form.

Firstly, break is the break between display items. In your case you’re only displaying one item so there’s nothing to break (if you were using display="week,day" then your break tag would occur between the week and the day).

The rogue <br /> you’re seeing is actually produced by the label. This “feature” goes back a long way and is what prompted me to raise the doLabel enhancement issue that has yet to be resolved.

[ For background info, Txp has an internal function called doLabel() which this plugin uses. If you don’t specify a labeltag when calling that function, it automatically assumes “br”. But sometimes you truly do not want a break at all after your label — you want it inline. And the function cannot do this. It ought to be possible to specify something like labeltag=" " as a cheat, but that just produces < > after your label ]

Currently there’s no true fix. The only way round it I’ve found is to specify labeltag="span" which at least wraps spans — an inline element — around your ‘days’ label. It’s not pretty but it’s better than a line break.

I could get round this by simply not using doLabel() and writing that bit myself in the plugin but I felt doLabel() was actually wrong in the core and should be fixed. Sadly I forgot about it and never fixed it. One day…


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

#15 2011-07-18 12:34:47

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

Re: smd_countdown: time to an event

Stef – you are a complete dude, and I thank you most kindly for your time and attention.

Next time I’m in Coventry I will buy you (proper) beer :)

Offline

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

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

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: 8,826
Website

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.

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: 566
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
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

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

Board footer

Powered by FluxBB