Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-02-02 09:02:32

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

[SOLVED] Plugin which counts days

I am looking for a countdown plugin which just counts days and custom messages are served when deadline is reached.

I am currently using glx_countdown but it calculates the time in years/months/weeks/days/hours/etc.

I am also aware of fha_time_diff and smd_countdown all of which do not offer (in my knowledge) the desired by us output.

If anybody can help with the editing of the glx plugin would be an excellent solution for us.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2013-02-02 09:41:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: [SOLVED] Plugin which counts days

colak wrote:

smd_countdown… do not offer (in my knowledge) the desired by us output.

What output do you actually want? smd_countdown’s container can format the output (almost) any way you like. For example (from the help):

<txp:smd_countdown to="expires">
   The event has arrived.
<txp:else />
   The event is
      <txp:smd_time_info display="day_total"
           label="day, days" labelafter="1"
           labelspacer=" " />
   away.
</txp:smd_countdown>

Isn’t something like that what you need? I do, however, need to do some work on the internationalisation aspect of the plugin so it can handle singular values better in languages other than English. But if that’s a problem you can work around that by hand with smd_if for now.

Last edited by Bloke (2013-02-02 09:44:31)


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

#3 2013-02-02 11:47:57

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: [SOLVED] Plugin which counts days

Hi Stef

Thanks.. That looks good! The problem is updating over 1000 articles to replace the plugin with yours. A question…

would

<txp:smd_countdown to='<txp:if_custom_field name="custom3"><txp:custom_field name="custom3" escape="" /><txp:else />&nbsp;</txp:if_custom_field>'
<txp:else />
<txp:smd_time_info display="day_total" label="day, days" labelafter="1" labelspacer=" " />
</txp:smd_countdown>

work using this plugin?

In the custom field I would have something like "22 Jun 2013">passed. or whatever the date and the word needs to be.

> Edit: No… it doesn’t seem that it will work. My quotes look wrong

Last edited by colak (2013-02-02 12:01:41)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2013-02-02 13:33:00

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [SOLVED] Plugin which counts days

Hi Yiannis.
In your snippet, there is a missing > at the very end of the first line:

<txp:smd_countdown to='<txp:if_custom_field name="custom3"><txp:custom_field name="custom3" escape="" /><txp:else />&nbsp;</txp:if_custom_field>'>
<txp:else />
<txp:smd_time_info display="day_total" label="day, days" labelafter="1" labelspacer=" " />
</txp:smd_countdown>

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2013-02-02 16:51:25

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: [SOLVED] Plugin which counts days

Hi Julián, the reason for that is because I am including it within the custom_field. I’m wondering if this would work:

custom_field possible content: "22 Jun 2013">'passed.

and in the template:

<txp:if_custom_field name="custom3">
<txp:smd_countdown to='<txp:custom_field name="custom3" escape="" />
<txp:else />
<txp:smd_time_info display="day_total" label="day, days" labelafter="1" labelspacer=" " />
</txp:smd_countdown>
<txp:else />&nbsp;
</txp:if_custom_field>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2013-02-02 17:42:11

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [SOLVED] Plugin which counts days

I don’t know if you can “abuse” the parser that way, but I’d refrain of doing so.
I also confess that I don’t get why would you want to do it that way. That is, why you need to put this: "22 Jun 2013">'passed. on your cfield instead of just “22 Jun 2013”.

Also, you could take advantage of the default attribute on txp:custom_field.

<txp:smd_countdown to='<txp:custom_field name="custom3"  default="&nbsp" />'>
passed
<txp:else />
<txp:smd_time_info display="day_total" label="day, days" labelafter="1" labelspacer=" " />
</txp:smd_countdown>

(btw, I’m not familiar with smd_countdown)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#7 2013-02-02 18:53:54

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: [SOLVED] Plugin which counts days

Hi Julián, thanks for the input.

looking closely at what we need, maybe the code will not work anyway.

Apart from the texts (where this plugin is not needed) we have as a general rule 5 types of posts which require one of the following ‘words’ there. expired, passed, &nbsp; and – here is where i see a problem – ongoing which means that the plugin will not be doing its job there. I guess i’ll have to sleep over it and think it over afresh tomorrow.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#8 2013-02-02 19:01:07

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,303

Re: [SOLVED] Plugin which counts days

colak wrote:

If anybody can help with the editing of the glx plugin would be an excellent solution for us.

That’s exactly what I’m after on a cold weekend :)

Yiannis, there’s an array in the code following these comments:

	// array of time period chunks
	// Edit below this to suit your language

You should remove from that array all but the line that relates to the days, leaving only array(60 * 60 * 24 , "day", "days"), // day

If, following this editing, at the moment (08.00 pm) you get a 0 for the third of February (tomorrow) that is because there are less than 24 hrs until tomorrow. So you’ll have to adjust the date via the day attribute of the glx tag until the result suits your needs.

Hope it helps and works correctly.

Last edited by uli (2013-02-02 22:19:38)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#9 2013-02-02 20:06:01

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: [SOLVED] Plugin which counts days

Thanks Uli, that was it! Thanks soo much.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#10 2013-02-02 20:11:19

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: [SOLVED] Plugin which counts days

Last thing :) is there a way to have the plugin replace the 0 day with last day?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#11 2013-02-02 22:13:21

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,303

Re: [SOLVED] Plugin which counts days

colak wrote:

is there a way to have the plugin replace the 0 day with last day?

Not one I can help you with by editing the plugin. But rah_replace (or smd_wrap) could do that for sure.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#12 2013-02-03 07:49:43

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: [SOLVED] Plugin which counts days

Thanks Uli, that gives me an idea to do it with a variable but it doesn’t work.

This is what I have now

<txp:if_custom_field name="custom3">
<txp:variable name="lastday" value='<txp:custom_field name="custom3" escape="" default="&nbsp;" />' />
<txp:if_variable name="lastday" value='<span title="deadline">0 days</span>'>
<span title="deadline">last day</span>
<txp:else />
<txp:variable name="lastday" />
</txp:if_variable>
</txp:if_custom_field>

Can anyone see what I am doing wrong?

> Edited to explain what does and what does not work: The code works as a whole but the if_variable value is somehow not recognised and as such 0 days is not replaced with last day

Last edited by colak (2013-02-03 08:05:11)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB