Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#745 2011-09-01 16:27:01

pafruu
Member
From: New Brunswick, Canada
Registered: 2010-01-14
Posts: 65

Re: smd_calendar: complete schedule / event / calendar / diary

Ok I’m trying to solve the problem with a <txp:variable>

here is the declaration of the variable at the top of template, I have 2 since I need english and french:

<body>
<txp:variable name="eventfr" value='<txp:smd_article_event form="eventsfr" section="calendrier" time="today" limit="2" category="event" allspanned="1" stepfield="custom_1" />' />
<txp:variable name="event" value='<txp:smd_article_event form="events" section="calendar" time="today" limit="2" category="event" allspanned="1" stepfield="custom_1" />' />

and then in my form on the home page here is what I have for code:

<txp:if_variable name="eventfr"><txp:variable name="eventfr" />
<txp:else />
<p>Rien au programme</p>
</txp:if_variable>

Today, on sept 1st, there are no events showing so I should get the “Rien au programme” text showing up but it is not there. What am I doing wrong?


I try, and I try, and I try…. and sometimes I achieve

Offline

#746 2011-09-01 16:34:03

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

Re: smd_calendar: complete schedule / event / calendar / diary

pafruu

Your statements look good to me. You could try adding this as debug to your Form:

**<txp:variable name="eventfr />"**

When you view the article, if you see a space (or some text of course) between the two sets of stars then you’ll know that the calendar tag is returning something — even if it’s a space, newline, <br /> or something you can’t normally “see”. If it is you’ll need to take some action to resolve it, either by removing newlines in your Form or using the txp:variable tag as a container, or something like that.

That’s my best guess at present.

Last edited by Bloke (2011-09-01 16:35:02)


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

#747 2011-09-01 18:03:04

pafruu
Member
From: New Brunswick, Canada
Registered: 2010-01-14
Posts: 65

Re: smd_calendar: complete schedule / event / calendar / diary

Bloke wrote:

You could try adding this as debug to your Form:

**<txp:variable name="eventfr />"**

thank you for your reply Bloke, did you mean?

**<txp:variable name="eventfr" />**

I tried it and the result was just four stars like so:

jeudi 1 septembre

****

I believe this means that nothing is returned at all, which means something else is causing the problem, but i don’t know what.


I try, and I try, and I try…. and sometimes I achieve

Offline

#748 2011-09-01 19:45:42

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

Re: smd_calendar: complete schedule / event / calendar / diary

pafruu wrote:

did you mean <snip>

Yes, sorry. Fat fingers.

I believe this means that nothing is returned at all, which means something else is causing the problem

D’oh of course! Can you try:

<txp:if_variable name="eventfr" value=""> ....

Without the value="", you’re testing for “does the variable exist at all” which of course it does. You need to check if it contains nothing. I should have spotted that earlier.


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

#749 2011-09-01 23:20:36

pafruu
Member
From: New Brunswick, Canada
Registered: 2010-01-14
Posts: 65

Re: smd_calendar: complete schedule / event / calendar / diary

Bloke wrote:

D’oh of course! Can you try:

<txp:if_variable name="eventfr" value=""> ....

I bow down to your awesomeness.. It worked!!

here is the code:

<txp:if_variable name="eventfr" value=""><p>Rien au programme</p><txp:else /><txp:variable name="eventfr" /></txp:if_variable>

thank you soo much for your help! Your plugin is amazing!

Last edited by pafruu (2011-09-01 23:21:08)


I try, and I try, and I try…. and sometimes I achieve

Offline

#750 2011-09-05 13:03:10

Teemu
Member
From: Shanghai
Registered: 2010-04-27
Posts: 60

Re: smd_calendar: complete schedule / event / calendar / diary

Stef,

I’m using version 0.52 and isoweeks="week, {week}" setting. Every month’s first two weeks have the same week number, resulting week numbers after first one to be off by one.

Offline

#751 2011-09-05 13:19:33

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

Re: smd_calendar: complete schedule / event / calendar / diary

Teemu wrote:

Every month’s first two weeks have the same week number

Oooh, freaky. It’s not doing that here, so I can only assume it’s your server that’s confusing my pants code (probably because I missed a timezone setting somewhere).

Could you add debug="1" to the calendar tag and look for THIS MONTH'S RENDERED CALENDAR in the output. Just after that you’ll see some numbers. The first will be a long integer, then a date. That date should correspond with midnight on the first day of the month shown on the calendar.

As you navigate up and down the months, check that date reads correctly for all months: it uses that value to calculate the ISO week: if the date’s wrong, my code’s faulty. If it’s right, PHP may be faulty. In that case, please let me have your low level diagnostics and I’ll do some digging.


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

#752 2011-09-05 13:47:59

Teemu
Member
From: Shanghai
Registered: 2010-04-27
Posts: 60

Re: smd_calendar: complete schedule / event / calendar / diary

Bloke wrote:

As you navigate up and down the months, check that date reads correctly for all months: it uses that value to calculate the ISO week: if the date’s wrong, my code’s faulty. If it’s right, PHP may be faulty. In that case, please let me have your low level diagnostics and I’ll do some digging.

Date is right. I will email you diagnostics.

Offline

#753 2011-09-05 15:28:22

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

Re: smd_calendar: complete schedule / event / calendar / diary

For the record, the plugin’s problem stemmed from Teemu’s particular server setup. Having a client based in Shanghai with that timezone, and the server in New York meant there was a 13 hour time difference between the two areas. When I calculated the ISO week number I was wrongly using safe_strtotime() which was applying the server offset a second time, pushing the date back 13 hours, tipping it into “yesterday” which then completely foiled the ISO week calculation. Bah!

I’m quite sure there are other instances of this kind of thing floating around the plugin — I thought I’d caught them all in v0.52, but it’s only through bug reports from exotic server setups that I can ever hope to find the rest, since I’m in the same timezone as my server and we’re both GMT.

I’ll give it a few days in case this particular setup yields any more problems before releasing v0.53. Many thanks to Teemu for the server access to track down the bug.

Last edited by Bloke (2011-09-05 15:29:15)


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

#754 2011-09-23 04:17:19

Teemu
Member
From: Shanghai
Registered: 2010-04-27
Posts: 60

Re: smd_calendar: complete schedule / event / calendar / diary

Stef,

I was wondering if I could pick your brain a bit more about this plugin, or anybody’s who’s interested.

I’m using it on a art gallery site with custom fields as date fields and <txp:smd_article_event /> to list the exhibitions.

Works great but my client wants additional function, possibility to filter results by year (All – 2011 – 2010 – 2009… )

How could I do this?

Here’s my thoughts:

Use <txp:smd_cal_now /> to pick the year from date field and set that as a class for each item. Then use some jquery for filtering.

But then my question is… how could I return all the years that have exhibitions as a list (2011 – 2010 – 2009… )? Obviously I would need this for filtering menu.

Any thoughts or suggestions would be appreciated.

Offline

#755 2011-09-23 11:04:01

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

Re: smd_calendar: complete schedule / event / calendar / diary

Teemu wrote:

my client wants additional function, possibility to filter results by year (All – 2011 – 2010 – 2009… )

Take a look at the custom attribute to <txp:smd_article_event />. If you put up a simple HTML form with the dates as a select list (or something) then when someone submits the form, you can use <txp:adi_gps /> to read the variable in and plug it into the custom attribute. For example, assuming your start date custom field is custom_6 and your HTML form variable containing the date is mydate (and you’ve told people to input dates as YYYY-MM-DD in your custom fields) :

custom='custom_6|like|<txp:variable name="mydate" />%'

You can probably modify that idea if it’s not quite what you want.

Last edited by Bloke (2011-09-23 11:06:05)


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

#756 2011-09-23 12:09:45

Teemu
Member
From: Shanghai
Registered: 2010-04-27
Posts: 60

Re: smd_calendar: complete schedule / event / calendar / diary

Bloke wrote:

Take a look at the custom attribute to <txp:smd_article_event />. If you put up a simple HTML form with the dates as a select list (or something) then when someone submits the form, you can use <txp:adi_gps /> to read the variable in and plug it into the custom attribute. For example, assuming your start date custom field is custom_6 and your HTML form variable containing the date is mydate (and you’ve told people to input dates as YYYY-MM-DD in your custom fields)

I see what you mean. Wouldn’t I need to put the years manually to the select list? Thinking about future and the client, I was wondering if there would be any way dynamically fetch years that have articles?

Last edited by Teemu (2011-09-23 12:10:30)

Offline

Board footer

Powered by FluxBB