Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: smd_calendar: complete schedule / event / calendar / diary
Hi Stef,
Many thanks for that (sorry for missing the CSS notes in your docs), but I definitely needed your explanation notes above – it makes everything much clearer. I must admit (and you’ve probably worked this out by now) that I find the whole CSS thing mind-numbing sometimes. In fact, that goes for Textpatterns more involved processes too!
Offline
#98 2009-02-12 14:59:08
- woof
- Member
- Registered: 2004-08-01
- Posts: 128
Re: smd_calendar: complete schedule / event / calendar / diary
Hi Stef
Apologies in advance if I’m missing something obvious (it happens :-)), but I’m wondering is it possible to output the details of the current calendar elsewhere on the page?
e.g. in the title tag or in a heading like this:
<h1>Performances for {month}</h1>
I’ve tried a few things but drew a blank
cheers
Offline
Re: smd_calendar: complete schedule / event / calendar / diary
woof wrote:
is it possible to output the details of the current calendar elsewhere on the page?
Not directly from the plugin, no. The calendar is standalone insofar as you just chuck it on the page and it renders there and then. Once it’s done rendering, that’s it: you lose any persistence.
But if you can wangle it, you may be able to be a bit clever. I can think of one or two possible avenues to explore:
- Use the URL line. The
m=
number is the month number. You could probably grab that and — if it exists — do a little lookup to convert the number to a month name. Either use 12 txp:variables or… well, how are your PHP skills? ;-) - Use a
cellform
. The disadvantage is you’d have to design the cell contents but you could make cells add your own URL variable, e.g. use&the_month={monthname}
in an anchor tag. Then you can grab this name directly from the URL and display it
I’m not sure about that last one because if you use the next/prev navigation to view another month — as opposed to clicking a cell — your variable will be lost. The maintain
attribute will probably keep the value as-is, which you don’t want. Hmmm, if the nameval
attribute was more intelligent you could perhaps specify that you wanted it pre-filled with dynamic info *ponder*
In both cases, the adi_gps plugin is your friend. Possibly smd_if as well, to test if the value is set or not and alter the heading accordingly.
Last edited by Bloke (2009-02-12 15:23:54)
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
#100 2009-02-12 15:27:15
- woof
- Member
- Registered: 2004-08-01
- Posts: 128
Re: smd_calendar: complete schedule / event / calendar / diary
Many thanks Stef – I had already waded into 2 territory and got my pants wet — I’ll give 1 a go, sounds straightforward.
Offline
#101 2009-02-12 17:42:15
- smd_ksu
- Member
- Registered: 2008-12-23
- Posts: 25
Re: smd_calendar: complete schedule / event / calendar / diary
Great plugin. I have a few questions:
1. Is there a way, using smd_article_event to display just current events? Like say a exhibit which runs from January to March so is currently running.
2. Also with smd_article_event, I would like to have events that have not expired yet to not show up when using time=“past”. Again with exhibits, one starts in January but doesn’t end until March shouldn’t be in the past yet.
3. Is there a way to use “offset” to go back in time? Like to show events back a month and forward a month.
Thanks for any help you can give.
Offline
#102 2009-02-12 19:11:02
Re: smd_calendar: complete schedule / event / calendar / diary
smd_ksu wrote:
to display just current events?
In theory, with time="any"
or time="past"
any event which has not expired will be displayed. If this is not the case, please send me an example or post some tags/article contents so I can try and replicate this and track down the problem.
events that have not expired yet to not show up when using time=“past”.
“past” is a bit of a misnomer in TXP. It really means “anything with a Posted date earlier than this very second”. It does not necessarily find things that happened “in the past” as you and me might define it. It largely depends on your referece point.
The only check the pluginn does is to see if the posted date occurred before ‘now’. It does not check the expiry except to see if the expired date has passed.
What I would say is that if you wanted to omit something that happened earlier than, say, ‘this month’ then use the from
attribute to insert the date of the 1st day of the current month (see one of the later examples in the help for how to use <txp:smd_cal_now />
inside this attribute).
Is there a way to use “offset” to go back in time? Like to show events back a month and forward a month.
Not with offset because that takes a simple number of events to “skip” from the start of your list of matched events.
But it can be done with from
and to
. Set an smd_article_event tag to go from “this month-1” to “this month+1” (again, see same example I cited from the last example) and then use <txp:if_different />
to detect the change in month. One of the other examples (number 1 or 2 I think) has a form that does this so you can display something like:
Events in January
—> blah blah
—> blah blah blah
Events in February
—> blah blah blah
—> blah blah blah blah
…
Hope I’ve not misunderstood your intentions. Does any of that help at all?
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
#103 2009-02-12 21:11:26
- smd_ksu
- Member
- Registered: 2008-12-23
- Posts: 25
Re: smd_calendar: complete schedule / event / calendar / diary
Thanks. Last question, does the smd_cal_now “offset” only take months? I tried <txp:smd_cal_now now=”?month?year” offset=“1 week” /> and that didn’t work.
EDIT: Nevermind, I’m stupid, I got it. Thanks again for your help. This plugin rules.
Last edited by smd_ksu (2009-02-12 21:23:31)
Offline
#104 2009-02-12 21:32:40
Re: smd_calendar: complete schedule / event / calendar / diary
smd_ksu wrote:
Thanks. Last question, does the smd_cal_now “offset” only take months?
No, it takes any valid English timeframe. The now
parameter can take:
?year
: replaced with the current year (or value ofy=
if present)?month
: replaced with the current month (orm=
)?day
: replaced with the current day (ord=
)
or of course an actual date, and then the offset applies the difference you specify to that value of now
.
Examples, assuming today’s date is 12 Feb 2009:
<txp:smd_cal_now offset="1 week" />
- 19th Feb 2009 (one week from today)
<txp:smd_cal_now now="?month ?year" offset="1 week" />
- 8th Feb 2009 (because ?month ?year is essentially equal to 1st Feb 2009)
<txp:smd_cal_now now="?month ?year" offset="-1 week" />
- 25th Jan 2009 (one week back from 1st Feb)
<txp:smd_cal_now now="?month ?year" offset="1 week" />
when the URL says?m=3
- 8th Mar 2009 (one week from 1st March)
EDIT: cool, glad you got it working
Last edited by Bloke (2009-02-12 21:34:26)
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
#105 2009-02-12 23:10:26
- woof
- Member
- Registered: 2004-08-01
- Posts: 128
Re: smd_calendar: complete schedule / event / calendar / diary
just an idea for a future version – would it be possible to filter by tag – either your own smd_tags or tru_tags or by a value in a custom field?
Offline
#106 2009-02-12 23:43:17
Re: smd_calendar: complete schedule / event / calendar / diary
woof wrote:
just an idea for a future version – would it be possible to filter by tag – either your own smd_tags or tru_tags or by a value in a custom field?
You can filter by custom fields now, indirectly. I’ve used smd_if here but adi_gps would work equally as well (and makes the code shorter). I just didn’t have it installed on my test server.
<!-- Initialize the txpvar: probably not necessary -->
<txp:variable name="cust" value="" />
<txp:smd_if field="urlvar:cf" operator="isused">
<txp:variable name="cust" value="{smd_if_cf}" />
</txp:smd_if>
<txp:smd_calendar select="month">
<txp:if_custom_field name="custom1" val='<txp:variable name="cust" />'>
<a href="?cf=<txp:custom_field name="custom1" />"><txp:title /></a>
</txp:if_custom_field>
</txp:smd_calendar>
You can also add maintain="cf"
if you wanted the currently used custom field to be retained as you navigate across months. The code there might need a bit of tweaking to add some conditional logic around the if_custom_field in case the cf variable is missing (otherwise you’ll only see entries that have nothing in the given custom field, which may or may not be what you want).
[ EDIT: in fact that whole example’s a bit contrived: you’d probably alter it so the anchor inside the if_custom_field just held the link to the article itself. When you are not filtering by custom field you’d want to use that anchor up there, so you can offer people the ability to filter by the custom field of the given event in any cell… urk! ]
Tags are probably trickier, but the same principle applies (certainly to tru_tags which uses the keywords field). smd_tags would be able to filter in-place as above, or as part of a pre-filtered list using the /smd_tags/article/tag-name
URL syntax: put a calendar on your tag list page and use the smd_if_tag and/or smd_tag_name in your calendar cells to show other articles with the same tag. At least you will be able to do that when I fix the URL syntax in that plugin.
Does that give you something to work on?
Last edited by Bloke (2009-02-12 23:54:30)
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
#107 2009-02-12 23:49:50
- woof
- Member
- Registered: 2004-08-01
- Posts: 128
Re: smd_calendar: complete schedule / event / calendar / diary
outstanding! you’re a legend. thanks a million.
Offline
#108 2009-02-13 01:46:31
- woof
- Member
- Registered: 2004-08-01
- Posts: 128
Re: smd_calendar: complete schedule / event / calendar / diary
Bloke wrote: [ EDIT: in fact that whole example’s a bit contrived: you’d probably alter it so the anchor inside the if_custom_field just held the link to the article itself. When you are not filtering by custom field you’d want to use that anchor up there, so you can offer people the ability to filter by the custom field of the given event in any cell… urk! ]
Yes, I ended up using the following adaption of your example:
but first some background, I’m building a theatre company site
I’m using two sections: “Productions” and “Calendar” and a custom field called “Token” to glue them together.
A single production might have anything from 1 to 20 performance runs over a 30 year period, so I create those as separate articles in the Calendar section and then using the code below display them all in a calendar on the production’s main info page which is a single article in the Productions section. As long as this article and all the calendar articles share the same value — doesnt matter what — in the token field, the performances are displayed (maybe there’s a more elegant way to achieve this but this one works so I’m happy).
<!-- Initialize the txpvar: probably not necessary -->
<txp:variable name="cust" value="" />
<txp:smd_if field="token" operator="isused">
<txp:variable name="cust" value="{smd_if_token}" />
</txp:smd_if>
<txp:smd_calendar section="calendar" select="month">
<txp:if_custom_field name="Token" val='<txp:variable name="cust" />'>
<txp:permlink><txp:title /></txp:permlink>
</txp:if_custom_field>
</txp:smd_calendar>
Bloke wrote: Does that give you something to work on?
Big time – thanks to your help I have a much deeper understanding of the workings and potential of the <txp:variable />
tag and the smd_if
plug-in
I’ve said it before and I’ll say it again — you’re a legend! Cheers for the support and a great plug-in
Offline