Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,524
Website

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,524
Website

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 of y= if present)
  • ?month : replaced with the current month (or m=)
  • ?day : replaced with the current day (or d=)

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,524
Website

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

#109 2009-02-13 20:14:45

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

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

@Bloke: Stef, looks like you invented another ‘makes your head spin’ plug-in again :)

OK, now I have read the whole 11 pages of the thread and I have two very typical (provocative) event questions:

  1. How to announce events? The moment I post an event I want to announce the event by adding it to the standard front page flow. Using the post date will make the event invisible. So I am looking for a way…
  2. The announcement on the front page as mentioned above is not enough. I want the post also to appear in advance in the TXP news feed. How to solve this?

Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#110 2009-02-13 20:59:56

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,524
Website

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

merz1 wrote:

How to announce events?

Use <txp:smd_article_event /> on your front page. It’s a bit like article_custom but understands repeated, spanned, extra and future dates. As long as the article is Live you can view it, even if its date is future. BTW, the tag can also apply other time-based limits and be paged via pg so you can step through pages of forthcoming events. It won’t wash the dishes though.

appear in advance in the TXP news feed.

Hmmm, that I don’t know anything about. I’ve never used a feed with the plugin.

If it’s possible to configure a feed by using it as a container tag or something then you should be able to embed a call to smd_article_event inside it. If not then I don’t know how to do it. Let me read up on news feeds and see how they work in TXP. It may be that you can be clever and use the existing tags to convince the feed to show future events (anyone any ideas?). Or it may require a separate smd_cal_feed tag in the plugin.

Will get back to you on that one, probably not this week though.


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

Board footer

Powered by FluxBB