Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#811 2012-07-02 05:11:53

saccade
Plugin Author
From: Neubeuern, Germany
Registered: 2004-11-05
Posts: 521

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

Just a quick hands up of mine:

I’m using the date and extrafields at several installations of education and community sites and they are essential for me.

And so: multiple dates are important for me.

Best regards
Michael

Offline

#812 2012-07-02 11:50:27

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

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

mrdale wrote:

So the only real trick is UX and getting the expiration to work as a repeated event and not the end of a span.

I think I’m ok with the customer visually entering values one at a time. like so…

  1. Click in field
  2. Up pops a date/time picker
  3. person selects date and time
  4. Closes picker
  5. field is populated
  6. Opens picker
  7. selects another date and time
  8. closes picker
  9. this time the field needs to recognize that a value is being added, add a delimiter and not destroy the existing value.
  10. repeat from step 6

This workflow would work. The second to last step is a doozie tho.

How about starting with one date/time picker field plus supporting fields and then, on completion, give the option to open a new set of date/time picker field plus … and on and on until you’re done? Something like this: jQuery – Dynamically Adding Form Elements. Demo of concept at http://charlie.griefer.com/blog/jquery-dynamically-adding-form-elements/

I bet there is a way to do much the same thing with txp:etc_query as this approach is about adding elements to the DOM but I don’t know much about XPath at all.

Last edited by joebaich (2012-07-02 12:01:31)

Offline

#813 2012-07-09 08:21:47

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

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

I’m having a few problems getting this awesome beast to behave properly.

I am looking to use a small calendar in a side bar which, when each day is clicked, links to a section and displays the events from that day only – for movie days/times at a cinema. At the moment I am just getting a full list from the current month.

I have specified the start & end date are custom fields. The articles may be input into txp many weeks before they are displayed.

This is my actual calendar code

<txp:smd_calendar section="movies" size="small" dayformat="{Su,Mo,Tu,We,Th,Fr,Sa}" datefields="custom_7,custom_8" section="movies" expired="0" />

This is my code on the page for section “movies”:

<txp:smd_article_event section="movies" datefields="custom_7,custom_8" wraptag="ul" limit="30" expired="0"  form="movies_programme" sort="custom_7 asc" class="program_listings" allspanned="0" />

The 3 main problems I am having are:

  1. Calendar urls The links from the Calendar are random for example the link on 8th July is actually ?date=2012-05-28&s=movies which doesn’t seem to be found in any of my Posted, Expired or custom_7 & custom_8 fields. The link of the 12th July is fine ?date=2012-07-12&s=movies, but the link on the 13th July goes back by a month ?date=2012-06-01&s=movies. If I add linkposted="recur" to my txp:smd_calendar this is fixed (not sure why) but I still have the problem below.
  2. Calendar filtering – no matter which day I click, the list of events is always the same. The start & end dates seem to working in txp:smd_calendar links on the calendar as only the desired days are links. Some events do overlap, but for example if I click on July 30th, I still it lists all the events which have gone past their end date – but uses the correct month :)

I feel the time filter is something I thought I could possibly use, it filtered out old events, but still listed the rest of the events from the month…. but the other options…. time=“today” looked promising, but each link showed 1 event, the same event all month :(

I added debug=“1” and this is the output:

select unix_timestamp(Posted) AS uPosted from textpattern where  Status IN (4) AND Section IN ('movies')  ORDER BY Posted ASC LIMIT 0, 1
select unix_timestamp(Posted) AS uPosted from textpattern where  Status IN (4) AND Section IN ('movies')  ORDER BY Posted DESC LIMIT 0, 1
select unix_timestamp(LastMod) AS uLastMod from textpattern where  Status IN (4) AND Section IN ('movies')  ORDER BY LastMod DESC LIMIT 0, 1
++ THIS MONTH'S CALENDAR [ start stamp // end date // end stamp // end date // tz offset (end) ] ++
1341064800
2012-07-01 00:00:00
1343743199
2012-07-31 23:59:59
1343775599
select *, unix_timestamp(Posted) as uPosted, unix_timestamp(LastMod) as uLastMod, unix_timestamp(Expires) as uExpires from textpattern where  Status IN (4) HAVING UNIX_TIMESTAMP(custom_7) <= 1343775599 AND (now() <= Expires OR Expires = '0000-00-00 00:00:00') AND Section IN ('movies')  ORDER BY Posted ASC
++ THIS MONTH'S RENDERED CALENDAR [ start stamp // end date // start day // end stamp // end date // end day number ] ++
1341064800
2012-07-01 00:00:00
Sun
1343743199
2012-07-31 23:59:59
31

I feel I am either a) misunderstanding what smd_calendar can do (but I am sure I have seen this working like this) or b) missing something really, really simple

[edit] the datefields input into the database is like this 2012-07-09 – does it need to be a full time stamp? [/edit]

Last edited by tye (2012-07-09 08:29:15)

Offline

#814 2012-07-09 08:39:13

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

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

tye wrote:

I am looking to use a small calendar in a side bar which, when each day is clicked, links to a section and displays the events from that day only

Quick tip: don’t use size="small" in this case! It creates all sorts of hassles like those you found, because it uses a very simplistic date format to render links and, unless you override it with linkposted or do some clever adi_gps wrangling, will only link to the first occurrence of an event.

Instead, use a fullsize calendar and just tame it to look like a mini calendar by using the container / form / cellform to change the default behaviour. You then have complete control over destination URLs and cell contents.

The other half of the issue is in the destination page template. You’ll need some clever logic in there — possibly by using adi_gps to read in a variable that you pass from the calendar — which will use <txp:smd_article_event> to display exactly the list of events in which you are interested.

Last edited by Bloke (2012-07-09 08:40:11)


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

#815 2012-07-10 00:14:24

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

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

Thanks Stef – I’ll let you know how I go

Offline

#816 2012-12-19 16:22:02

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 608

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

I’m encountering a problem with the min calendar.

I’ve entered events for 2013 and when I flip across to next year all the days that have events on them are highlighted. When I click on a date on the mini calendar the correct events are shown (along with the correct date at the top of the page) but the mini calendar changes to back to 2012. So instead of February 2013 the mini calendar now says February 2012 and highlights events in 2012.

I’m using Textpattern 4.5.2 and smd_calendar 0.52

—Edit 1—
I’ve also tried installing the 5.3 beta but get the same results.
Tried rolling back to 0.50 (which worked before) but get the same results.

I wonder If I could have broken something when I change the layout/design of the calendar. Or maybe it’s a bug that I was unaware of as I’ve always entered events for the new year In January before now.

—Edit 2—
After having a long think about this last night I came to the conclusion that the mini calendar keeps changing because I’m not passing the year in a variable like I am the day and date. So I’m off to check my code and variables to see what I can come up with.

Last edited by Algaris (2012-12-20 08:26:24)

Offline

#817 2012-12-20 14:33:26

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 608

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

Okay, now I’m confused. It appears that I’ve already defined the Year as a variable and upon further investigation I see that any link (not just links on the mini calendar) that change the calendars view switches the mini calendar back to 2012.

This is the entire contents of my variables form:

<!-- If on the homepage use the default section else use the sections name for the section -->
<txp:variable name="this_section"><txp:if_section name="default"><txp:else /><txp:section /></txp:if_section></txp:variable>
<!-- Setup the dateURL variable -->
<txp:variable name="dateURL">
	<txp:smd_cal_now format="&amp;date=%Y-%m-%d&amp;day=%e&amp;weekday=%A&amp;month-name=%B&amp;year=%Y&amp;month-num=%m" now='<txp:variable name="date" />' />
</txp:variable>
<!-- Grab variable values from the URL (used when a date is click on in the mini calendar) -->
<txp:adi_gps name="date" quiet="1" />
<txp:adi_gps name="day" quiet="1" />
<txp:adi_gps name="weekday" quiet="1" />
<txp:adi_gps name="month-name" quiet="1" />
<txp:adi_gps name="month-num" quiet="1" />
<txp:adi_gps name="year" quiet="1" />
<txp:adi_gps name="view" quiet="1" />
<!-- Set default values for the variables -->
<txp:php>
	global $variable;
	if (empty($variable['date'])) $variable['date'] = date('Y-m-d');
	if (empty($variable['day'])) $variable['day'] = date('j');
	if (empty($variable['weekday'])) $variable['weekday'] = date('l');
	if (empty($variable['month-name'])) $variable['month-name'] = date('F');
	if (empty($variable['month-num'])) $variable['month-num'] = date('n');
	if (empty($variable['year'])) $variable['year'] = date('Y');
	if (empty($variable['view'])) $variable['view'] = 'day';
</txp:php>
<txp:variable name="isoweek"><txp:smd_cal_now format="%V" now='<txp:variable name="date" />' /></txp:variable>

Here’s how I’m outputting the mini calendar complete with links:

<txp:if_section name="default">
<txp:variable name="calendar_section" value="" />
<txp:else />
<txp:variable name="calendar_section"><txp:section /></txp:variable>
</txp:if_section>
<txp:if_category>
<txp:variable name="calendar_category">&amp;c=<txp:category /></txp:variable>
<txp:else />
<txp:variable name="calendar_category" value="" />
</txp:if_category>
<txp:smd_if_cal flag="SMD_ANY">
<a href="<txp:site_url />?s=<txp:variable name="calendar_section" /><txp:variable name="calendar_category" />&amp;view=day&amp;date={year}-{monthzeros}-{dayzeros}&amp;day={day}&amp;weekday={weekdayfull}&amp;month-name={monthname}&amp;year={year}&amp;month-num={month}">{day}</a>
<txp:else />
{day}
</txp:smd_if_cal>

Here’s the URL I get when clicking on the 9th January 2013 from the mini calendar.

www.sitename.com/?s=&view=day&date=2013-01-09&day=9&weekday=Wednesday&month-name=January&year=2013&month-num=1

Last edited by Algaris (2012-12-20 14:36:55)

Offline

#818 2012-12-20 15:18:02

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 608

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

I’ve managed to get it working! All I had to do was add year='<txp:variable name="year" />' to the
smd_calendar tag.

Thanks for making such a wonderful plugin Stef.

Last edited by Algaris (2012-12-20 15:18:35)

Offline

#819 2013-03-06 12:14:30

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

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

Hi Stef,

I’m hitting a problem when specifying two or more categories, e.g:

<txp:smd_calendar section="noticeboard" category="event,all-day-event"> ... </txp:smd_calendar>

In other words, I’m interested in entries for the calendar that all belong to the section “noticeboard” but are only associated with categories “event” or “all-day-event”.

The current month calendar comes up OK, but the prev/next links just give me blank pages.

The prev link is: http:// ... /?c=event,all-day-event&m=2&y=2013

If I remove “event” or “all-day-event” from the URL list the page is displayed.

Still no joy if I remove section=“noticeboard” from the smd_calendar tag.

Any clues to what I’m doing wrong would be most welcome.

Offline

#820 2013-03-06 22:25:07

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

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

gomedia wrote:

The prev link is: http:// ... /?c=event,all-day-event&m=2&y=2013

Bah! Shoddy code on my part. Forgot that category and section could take multiple values and just stuffed them in the URL verbatim.

Leaves me with a dilemma of how to handle that situation because I don’t think the URL can support more than one, even if I sent them as an array. Wonder what the effect is if I just take the first one and use it in the link. Would it impact the page logic in any way?

Hmmmmmm. Ideas on a postcard to the usual address…

Last edited by Bloke (2013-03-06 22:26:15)


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

#821 2013-03-06 23:00:30

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

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

Bloke wrote:

Hmmmmmm. Ideas on a postcard to the usual address…

Thanks for the reply.

I noticed that the section didn’t even get a mention in the URL (it’s different to the section where the calendar is sitting), so I’m guessing this is a TXP URL article retrieval job as opposed to a built-in query by the plugin.

I can only think of a workaround to make it do what I want – which is basically to put all the different categories of interest (there’s actually more than two in play) under one category parent, have that specified in the smd_calendar ‘category’ attribute & then filter out the articles using if_article_category within the smd_calendar form. Haven’t tried it in anger yet though, but I’m hopeful. It won’t be as efficient – but needs must when the client drives!

Offline

#822 2013-06-06 14:46:59

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

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

Hi folks, I’m new to smd_calendar and am trying to figure out how to maintain the month selected if I select a category from a txp:category_list

It works fine if I select the category first and then change month as smd_cal appends the date onto the end of the category string but the category_list links reset everything back to current month.

How can I carry the dates over when I select a category from the category_list?

Offline

#823 2013-06-21 08:43:13

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

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

damienbuckley wrote:

How can I carry the dates over when I select a category from the category_list?

Unfortunately, as you found, category_list wipes any extra URL variables. I would expect the only solution is to roll your own category_list container so you build up the link manually. Something like this (untested):

<txp:smd_calendar>
   <txp:variable name="curr_month"><txp:smd_cal_info type="month" /></txp:variable>
   ...
</txp:smd_calendar>

...

<txp:category_list wraptag="ul" break="">
   <li>
      <a href="/category/<txp:category /><txp:if_variable name="curr_month">?m=<txp:variable name="curr_month" /></txp:if_variable>"><txp:category title="1" /></a>
   </li>
</txp:category_list>

I think that should work. Essentially you’re just making a note of the current month in a txp:variable and then when you get to display your category list, you read that value back and construct an anchor which includes that value.

This approach won’t work if your category_list appears before your calendar tag. If there’s no way to rearrange your page flow to achieve this then you have a couple of options. Firstly, employ something like adi_gps to read the value of the m URL variable just before your category_list tag. Stash it in the same txp:variable as in the calendar tag I gave above, and then the category_list code I posted will continue to work. Otherwise, you’re probably into jQuery territory to inject the month into the anchor after the DOM has loaded. Bit messy.

Hope that helps.


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

#824 2013-06-21 09:13:42

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

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

etc_url does exactly what you need: create/modify a TXP url. That should work:

<txp:category_list wraptag="ul" break="li">
      <txp:etc_url url="" query='id&c=<txp:category />'><txp:category title="1" /></txp:etc_url>
</txp:category_list>

Offline

#825 2013-07-16 06:50:01

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

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

Sorry folks, forgot to subscribe to the thread…

Thanks for these suggestions. I’ll give them a whirl.

I have another query – is it possible to repeat events on certain weekdays? i.e. a course which is ran on Friday, Saturday and Sunday every week? I’ve tried all sorts of repeat combinations with no success. I know the alternative is to enter the event for the three days and repeat weekly but just thought I’d ask if there was a way to do it with one article entry?

Offline

Board footer

Powered by FluxBB