Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#829 2013-08-11 15:59:30

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 206
Website

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

Hi Bloke! One question, Althought I already use smd_calendar, I used to use zem_event_list, so… How do I do this with smd_calendar?

  <txp:php>
  $array = array("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado");
   echo"<div class='weekday'><h2>".$array[date('w', strtotime('-1 day'))]."&nbsp;";
   echo date('j', strtotime('-1 day'))."</h2>";
   echo"<txp:zem_event_list date_from='-1 day' date_to='-1 day' form='news_daily' />";
   echo"</div>";  
   echo"<div class='weekday'><h2>".$array[date('w')]."&nbsp;";
   echo date('j')."</h2>";
   echo"<txp:zem_event_list date_from='now' date_to='now' form='news_daily' />";
   echo"</div>";
   echo"<div class='weekday'><h2>".$array[date('w', strtotime('+1 day'))]."&nbsp;";
   echo date('j', strtotime('+1 day'))."</h2>";
   echo"<txp:zem_event_list date_from='+1 day' date_to='+1 day' form='news_daily' />";
   echo"</div>";
   echo"<div class='weekday'><h2>".$array[date('w', strtotime('+2 day'))]."&nbsp;";
   echo date('j', strtotime('+2 day'))."</h2>";
   echo"<txp:zem_event_list date_from='+2 day' date_to='+2 day' form='news_daily' />";
   echo"</div>";
   echo"<div class='weekday'><h2>".$array[date('w', strtotime('+3 day'))]."&nbsp;";
   echo date('j', strtotime('+3 day'))."</h2>";
   echo"<txp:zem_event_list date_from='+3 day' date_to='+3 day' form='news_daily' />";
   echo"</div>";
   echo"<div class='weekday'><h2>".$array[date('w', strtotime('+4 day'))]."&nbsp;";
   echo date('j', strtotime('+4 day'))."</h2>";
   echo"<txp:zem_event_list date_from='+4 day' date_to='+4 day' form='news_daily' />";
   echo"</div>";
   echo"<div class='weekday nopr'><h2>".$array[date('w', strtotime('+5 day'))]."&nbsp;";
   echo date('j', strtotime('+5 day'))."</h2>";
   echo"<txp:zem_event_list date_from='+5 day' date_to='+5 day' form='news_daily' />";
   echo"</div>";
  </txp:php>

What do I need is to show a list of events of the current week.

Thanks in advance.

Offline

#830 2013-08-12 20:16:29

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

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

robhert wrote:

show a list of events of the current week

If all your articles (a.k.a. events) are in a particular section, it should be no more tricky than using something like this:

<txp:smd_article_event section="events" wraptag="dl" from='<txp:smd_cal_now offset="-7 day" />' to='<txp:smd_cal_now />'>
   <txp:if_different>
      <dt><txp:posted format="%A" /></dt>
   </txp:if_different>
   <dd>
      <txp:permlink><txp:title/></txp:permlink>
      <txp:posted />
   </dd>
</txp:smd_article_event>

Untested, but something along those lines should get you going in the right direction. I used a dl/dt/dd list here but you could muck about with the markup to achieve something closer to the div soup you posted. Hope that helps.


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

#831 2013-08-19 04:47:30

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 206
Website

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

Hi Stef! Thank you! I’m trying to make it work. I would tell you how it’s going.

Offline

#832 2014-01-19 10:54:12

Gallex
Member
Registered: 2006-10-08
Posts: 1,308

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

doesn’t display articles set to future. but date in calendar is presented (opens blank page).

my form:

<txp:smd_calendar section="uritused" size="small" firstday="1" dayformat="{P,E,T,K,N,R,L}"  monthformat="{Jaanuar,Veebruar,Märts,Aprill,Mai,Juuni,Juuli,August,September,Oktoober,November,Detsember}" time="any" expired="1" yearwidth="2,4c" id="aastalind" />

txp: 4.5.5. php: 5.5.2

Last edited by Gallex (2014-01-19 14:28:29)

Offline

#833 2014-01-20 09:39:38

Gallex
Member
Registered: 2006-10-08
Posts: 1,308

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

any ideas? i’m in big trouble, i need to make public the site today!

Offline

#834 2014-01-20 09:42:20

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

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

Have you tried to set time="any"?

<txp:article time="any" ... />

Offline

#835 2014-01-20 09:54:55

Gallex
Member
Registered: 2006-10-08
Posts: 1,308

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

etc, you are a life saver!! thank you!

Offline

#836 2014-02-04 02:27:28

damienbuckley
Member
From: Brisbane, QLD, AU
Registered: 2006-02-24
Posts: 138
Website

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

Hi Stef,

Is there anything you can look at for future releases with regard to error-handling? I just had an instance whereby a client had entered a couple of incorrect format entries in the repeat and omit fields and it took the site down. The problem was that the page had runtime of over 26s and was exceeding the server’s virtual memory limit.

I was able to track down the issue eventually but is there a way you could stop this kind of problem from taking the site down?

Offline

#837 2014-02-05 20:34:54

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

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

damienbuckley wrote #278651:

Is there anything you can look at for future releases with regard to error-handling?

Yeah, probably. Thought I’d trapped quite a few, but maybe there are things left to do. What version are you using, btw? The latest is v0.53.

I just had an instance whereby a client had entered a couple of incorrect format entries in the repeat and omit fields and it took the site down.

Eeek, that’s not good, sorry. Would you mind letting me know what formats they entered so I can try it here? I’ve tried mangling dates in the omit custom field in ever-increasingly wacky formats — text, extra commas, glyphs — but all I’ve succeeded in doing so far is make the omitted dates not get omitted if a date is mangled in some way. If you could help me make it fail, I’ll of course patch it.

In fact, the whole plugin could be made more PHP-5 aware nowadays using the much better DateTime object which may well make the code a lot simpler and reliable, but… not today.


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

#838 2014-02-05 22:10:00

damienbuckley
Member
From: Brisbane, QLD, AU
Registered: 2006-02-24
Posts: 138
Website

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

Its all good mate – no apologies necessary – just trying to help improve things.

The problems were pretty simple mistakes really. One was an extra comma that crept in between month and year in the Omit field as follows:

11 April 2014, 18 April 2014, 25 April 2014, 4 August 2014, 11 August 2014, 26 September, 2014, 3 October 2014,

and another entirely random entry in the Repeat field:

‘Last Tuesday’

Obviously I’ve explained to the users that they need to avoid such errors but its a church site with over 20 users…

I was running the v0.53 beta but had swapped it back to v0.53 as part of my troubleshooting. I can no longer find the beta on your site however. Have you removed it or is v0.53 the latest version now?

Server is running PHP: 5.3.23. This can be switched up if it will make any difference? I left it as is as newer versions of PHP on this server have not had the timezone set properly…

If you need to see it actually fall over I can either arrange a Skype hookup to crash the live site momentarily or I can shoot you the db I exported when it wasn’t working incase there is something else involved. Theres nothing confidential on it.

Offline

#839 2014-02-05 23:21:51

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

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

damienbuckley wrote #278683:

One was an extra comma that crept in between month and year in the Omit field:

I thought that might be the case so I tried it earlier and couldn’t get it to fail. But I’ve just tried it again with your list and it was working fine up until trying to display a particular month (December 2014) then it kind of hung. Although it might not be that, as my hosting seems to be on a general go-slow and they have some server issues tonight so it might just be that. I’ll have to wait and see, but I’ll test that out and see what the plugin is doing behind the scenes. It may well be that seeing “2014” as a discrete entity in the list (which is what is happening because of the comma) creates 365 omit entries, which is clearly going to take some time.

As far as guarding against that, well, it depends if PHP throws an error or not. I’m using PHP’s date and time functions to create dates based on what is supplied in that field. If PHP’s internal function converts “2014” into 365 dates then there’s nothing I can do about it. But if it reports that it can’t figure it out or returns something that I can trap as “erroneous” then it’s something I can fix.

and another entirely random entry in the Repeat field: ‘Last Tuesday’

Ah, now that probably will kill things. Again, I’ll test it out when my server returns to some form of normality. But I can see that causing a problem as the plugin tries to create N articles with a step of ‘Last Tuesday’. It’d take the article’s posted date, add ‘Last Tuesday’ to it and create another fake article date with that date stamp. It’ll then add ‘Last Tuesday” to that date and create another fake article date. And repeat this all the way until the expiry, or until the end of the current month, or up to the end date of your smd_article_event tag.

The plugin is designed to create a lot of intervals from dates, but I don’t know the consequences of adding a ‘negative’ value to the current date. It may be going backwards, e.g. today is Wednesday, last Tuesday would either be yesterday (-1 day) or Tuesday last week (-8 days). If it keeps adding, say, -1 to each date, it’ll just create a gazillion fake article dates stretching back to 1970 and probably won’t stop until PHP runs out of memory, because the plugin assumes that the offset is positive so it’s only looking for the end of the period (in the future, not the past) in order to stop the calculation.

I’ll run some tests and find out, thanks for the info.

I was running the v0.53 beta… is v0.53 the latest version now?

Yes, the beta became the actual v0.53 as there were no bug reports at the time.


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

#840 2014-02-06 00:58:21

damienbuckley
Member
From: Brisbane, QLD, AU
Registered: 2006-02-24
Posts: 138
Website

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

Bloke wrote #278684:

It may well be that seeing “2014” as a discrete entity in the list (which is what is happening because of the comma) creates 365 omit entries, which is clearly going to take some time.

I figured that might be the case and having the two involved just pushed it over the edge so to speak. It was loading on my local machine but took 26 seconds. The live hosting just caved in – lack of memory etc.

Look forward to seeing how you go but let me know if the db or whatever is helpful in diagnosing the issue.

Offline

Board footer

Powered by FluxBB