Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#211 2009-04-14 10:34:58
Re: smd_calendar: complete schedule / event / calendar / diary
decoderltd
Have you tried adding category='<txp:category />' as an attribute to smd_calendar? Or do you mean it’s not outputting any at all right now, when there are some future event articles in the ‘diary’ section?
In a past life the calendar tags automatically filtered events by current section / category / author but I took that out a few versions ago. When I get more space in the plugin (i.e. when TXP 4.0.9 is officially released and we get 16Mb of codespace instead of 64Kb!) I’ll go nuts and probably offer an option to automatically reinstate this behaviour to save you doing it manually.
As for tooltips you can look at the standard plugin or jTip which is pretty funky. Ease of use depends on how comfortable you are with javascript! For a simple tooltip you could just cram the link’s title attribute with a load of stuff, e.g.
<txp:permlink title='Location: <txp:custom_field name="location" /> | Time: <txp:posted format="%T" />'>
<txp:title />
</txp:permlink>
and let the browser do all the work.
Last edited by Bloke (2009-04-14 10:36:01)
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
#212 2009-04-14 11:05:11
Re: smd_calendar: complete schedule / event / calendar / diary
Hi Stef,
Thank you for that, I’ve tried category='<txp:category />' but without the if_category tag it seems to output all events irrespective of category. If I reinstate the if_category tag I only get the else statement as before. But don’t worry, if it’s problematic I can list a selection of upcoming events instead.
Thank you for the tooltip options, I’ll look into those (although you probably remember the extent of my Javascript knowledge from my various smd_gallery posts!).
One other question, I notice that when I click a recurring calendar event it returns the original post date (not the actual clicked calendar date), is there a way around this? My form is:
<dl>
<dt>Date:</dt>
<dd class="first"><txp:posted format="%A, %B %d, %Y" /></dd>
<dt>Venue:</dt>
<dd class="first"><txp:custom_field name="event venue" /></dd>
<dt>Time:</dt>
<dd class="first">Starts at <txp:posted format="%H:%M" /></dd>
</dl>
<br />
<txp:body />
If possible I would also like to show all the dates of a spanned event in the above form (rather than just the first). Thanks.
Offline
#213 2009-04-14 11:47:55
Re: smd_calendar: complete schedule / event / calendar / diary
decoderltd wrote:
I’ve tried
category='<txp:category />'but without theif_categorytag it seems to output all events irrespective of category. If I reinstate theif_categorytag I only get theelsestatement
Hmmm, that smells like a bug to me. I’ll have to try it out on a test site to confirm. Just looking at my code, it may be due to the tag being used in an article_list vs an individual article mode. I think it only works reliably in an individual article context (but I may be wrong, it’s just a hunch) because I’m checking against Category1 and Category2 instead of the ‘global’ category.
Just out of curiosity, is your ULR bar something like site.com/diary?c=courses and your smd_article_event tag in an individual article form? I might have to rethink the category list option because clearly it’s not going to work when category lists are not individual articles!
when I click a recurring calendar event it returns the original post date (not the actual clicked calendar date)
Yes, it’s a feature *cough* of the way things are done in TXP. Consider that you only have 1 “real” article Posted on one “real” date, so when you click on a permlink, TXP dutifully takes you to that article, whereby all you have is the “real” article info available to you. That’s the problem. All the recurring dates are “virtual” articles.
However, I have outlined a workaround somewhere (either in the help or, more likely, in a post here) which involves some trickery. What you do is pass the ‘fake’ date as a ? URL variable along with the permlink, thus your permlink might be: site.com/articles/learning-tai-chi?dat=10-may-2009. Then, in your Learning Tai Chi article (which is actually published today), you use some plugin such as smd_if or adi_gps to grab this date and display it instead of the ‘real’ date. If the URL date is missing or mangled you display the article’s real date as a fallback.
Another option is to take someone to a “booking” form on click. Using the same technique of passing info from the calendar, you can pre-fill details into textboxes, thus saving your visitors some typing.
If possible I would also like to show all the dates of a spanned event in the above form (rather than just the first)
Hmm, that’s tricky. You’ve stumped me! It involves maths I think because all we have is a start and end date. Oh, hang on, I think you can use smd_article_event with the allspanned attribute. It’s not designed explicitly for this purpose but it might work because it treats spanned events as individual days, so in the container you can put a <txp:posted /> tag and see each day separately. Try that and let me know if it works. If not I’ll have to get my thinking legs on.
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
#214 2009-04-14 12:09:50
Re: smd_calendar: complete schedule / event / calendar / diary
Thanks Stef, that all makes sense – I’ll try your allspanned idea and see what happens. I’ll also search out the ‘fake date ‘ workaround.
Going back to your txp_category query, when I have an event article open the URL displays http://www.site.com/section/title, I’m using category_1 to store the event category. Form-wise, I have an article form which lays out the page (column, main content, etc), I’ve then created a separate form for the category event listing under discussion and called that in using txp:output_form
Offline
#215 2009-04-14 14:41:37
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: smd_calendar: complete schedule / event / calendar / diary
decoderltd
If I understand you correctly, you are talking about an individual article page, and in that case you need category='<txp:category1 />' (or category='<txp:category1 />,<txp:category2 />' if you are using both categories) instead of <category='<txp:category />'.
Offline
#216 2009-04-15 10:00:41
Re: smd_calendar: complete schedule / event / calendar / diary
Great, thanks Els. That now works perfectly if I don’t use the <txp:if_category> + <txp:else /> tags. This is handy for the times when there are scheduled events but I need a workaround so a notice appears when there isn’t. Any ideas on a workaround?
Last edited by decoderltd (2009-04-15 10:01:04)
Offline
#217 2009-04-15 17:38:30
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: smd_calendar: complete schedule / event / calendar / diary
I’m sure that can be done, but I’ve lost a bit what your code is at the moment ;) Can you post what you have now?
Offline
#218 2009-04-15 20:14:26
- Josefin
- Member
- Registered: 2008-01-30
- Posts: 18
Re: smd_calendar: complete schedule / event / calendar / diary
I seems to work great! But hm.. I tried the quick home-made-demo:
* Install the plugin * Make a section called something like events * In your page template for that section, add <txp:smd_calendar section=“events” /> * Go and create some articles in the events section, set the dates to whenever you want those events to occur * View yoursite.com/eventsAs I understand it, I set the publish-date to when I want the event to take place, but when I set the date to say, sometime next week, the event will be clickable in the calender but wont show on the page since it hasnt been “published yet”.
And also; where do I set the ID for the calendar (calid)
I’m not used to using plugins.
/Josefin
Offline
#219 2009-04-16 09:23:16
Re: smd_calendar: complete schedule / event / calendar / diary
Josefin wrote:
As I understand it, I set the publish-date to when I want the event to take place
Correct. At least, that’s one way to do it. In the latest version you can also elect a custom field to hold your ‘start’ and/or ‘end’ event dates and then use TXP’s built-in published/expires dates to post your article as normal. Look at the datefields attribute in the plugin help.
but when I set the date to say, sometime next week, the event will be clickable in the calender but wont show on the page
When you say “won’t show on the page” do you mean in a regular article list? If so then that’s correct behaviour because TXP’s <txp:article /> tag won’t list articles in the future. <txp:article_custom time="any" /> will show them, as will <txp:smd_article_events />.
When you click a ‘future’ event from the calendar it should show the article correctly though, because TXP can still ‘see’ a future Live article if you know its direct URL (which the calendar does). Does the article show up correctly in this case?
where do I set the ID for the calendar (calid)
Use the id="my_calendar_name_here" attribute of the <txp:smd_calendar /> tag.
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
#220 2009-04-16 09:28:26
Re: smd_calendar: complete schedule / event / calendar / diary
Hi Els,
My form code so far is –
<h6>Upcoming <txp:category1 title="1" /></h6>
<txp:if_category>
<txp:smd_article_event section="diary" stepfield="custom_1" skipfield="custom_2" omitfield="custom_3" extrafield="custom_4" sort="Posted,Title asc" time="future" wraptag="dl" category='<txp:category1 />' limit="10" >
<txp:if_different>
<dt><txp:permlink><txp:title/></txp:permlink></dt>
</txp:if_different>
<dd><txp:posted /></dd>
</txp:smd_article_event>
<txp:else />
<p>No other scheduled <txp:category1 title="1" /> at the moment.</p>
</txp:if_category>
It works fine if I remove the <txp:if_category><txp:else /></txp:if_category> container, but of course I don’t get a notice if a category is empty.
Offline
#221 2009-04-17 00:07:26
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: smd_calendar: complete schedule / event / calendar / diary
decoderltd, you could try the code below. I haven’t tested it though…
<h6>Upcoming <txp:category1 title="1" /></h6>
<txp:variable name="events_in_category" value='<txp:smd_article_event section="diary" stepfield="custom_1" skipfield="custom_2" omitfield="custom_3" extrafield="custom_4" sort="Posted,Title asc" time="future" category='<txp:category1 />' limit="1" />' />
<txp:if_variable name="events_in_category" value="">
<p>No other scheduled <txp:category1 title="1" /> at the moment.</p>
<txp:else />
<txp:smd_article_event section="diary" stepfield="custom_1" skipfield="custom_2" omitfield="custom_3" extrafield="custom_4" sort="Posted,Title asc" time="future" wraptag="dl" category='<txp:category1 />' limit="10">
<txp:if_different>
<dt><txp:permlink><txp:title/></txp:permlink></dt>
</txp:if_different>
<dd><txp:posted /></dd>
</txp:smd_article_event>
</txp:if_variable>
I think you can probably leave out all attributes except section, time, category and limit in the smd_article_event tag that is in the txp:variable tag, but I’m not sure what they do so I’ve left them in for the moment.
I haven’t had the time yet to figure out how to leave out the event that is currently being viewed, but if you need that as well, I’ll try and think of a way to do that later.
Offline
#222 2009-04-17 08:12:17
Re: smd_calendar: complete schedule / event / calendar / diary
Els wrote:
I think you can probably leave out all attributes except
section,time,categoryandlimitin the smd_article_event tag that is in the txp:variable tag
Correct. Assuming you are not relying on the number of dates from a recurring event (i.e. as in this case you are just testing the existence of any event) then it is perfectly ok to leave out any custom fields or other attributes that don’t apply.
I haven’t had the time yet to figure out how to leave out the event that is currently being viewed
Hmm, that’s a good point. I thought I’d coded it so that the current event is automatically ignored if in an individual article but I may have dreamed that! If you (or anyone) finds that’s not the case then please let me know. It should be in the code, perhaps as an attribute to ignore the current article or not. Good catch, thanks.
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
#223 2009-04-17 08:22:16
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: smd_calendar: complete schedule / event / calendar / diary
Bloke wrote:
Hmm, that’s a good point. I thought I’d coded it so that the current event is automatically ignored if in an individual article but I may have dreamed that! If you (or anyone) finds that’s not the case then please let me know. It should be in the code, perhaps as an attribute to ignore the current article or not. Good catch, thanks.
That wasn’t a catch ;) I just assumed it wouldn’t ignore the current event (don’t know why…), I didn’t test my code example – didn’t even look at the plugin help… – and I’ve never used it this way myself, so probably I was completely wrong about this.
Offline
#224 2009-04-17 09:43:44
- Josefin
- Member
- Registered: 2008-01-30
- Posts: 18
Re: smd_calendar: complete schedule / event / calendar / diary
Thanx!
Bloke wrote:
When you click a ‘future’ event from the calendar it should show the article correctly though, because TXP can still ‘see’ a future Live article if you know its direct URL (which the calendar does). Does the article show up correctly in this case?
No the future articles dont show in my main column when i click them, only past ones does. This is my code:
…
<div id=“mainColumn”>
<h1>Kalendarium</h1>
<table width=“480” border=“0” cellspacing=“0” cellpadding=“0”>
<tr>
<td><txp:article form=“static_text” /></td>
</tr>
</table>
</div>
<div id=“calendar”>
<txp:smd_calendar size=“small” section=“ns_kalender” id=“norra” />
</div>
…
I’m not a developer, so I might be asking stupid questions ;)
/J
Offline
#225 2009-04-17 10:17:56
Re: smd_calendar: complete schedule / event / calendar / diary
Josefin wrote:
No the future articles dont show in my main column when i click them
Weird, it works on my test system and I’m using a standard <xtp:article /> tag. I wonder what’s different between the two systems?
To eliminate (or otherwise) the plugin, let’s try this:
- Create (or find) an article in your ns_kalendar section, make sure its status is Live and that its date is, say, sometime next month
- Save the article if you haven’t already
- Next to the Title textbox, hit View
Does the article show up then? Is the page URL something like http://site.com/ns_kalendar/my-article-title?
If that doens’t work, your page template is not rendering future articles for some reason. We’ll have to find out why.
However, if the above test works, go to a page with the calendar on it, navigate forward to next month and locate the article you just viewed. Hover over the link to that article and check that the URL is the same as the one we just looked at when you viewed it manually. They should match exactly. If they don’t, we need to find out why your calendar is generating different links to future articles!
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