Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-06-27 15:32:39

cnewkirk
Plugin Author
From: Bakersfield, Ca
Registered: 2006-01-04
Posts: 21

[plugin] [ORPHAN] cnn_month_select

Plugin cnn_month_select

This is a very simple plugin (hack) that adds functionality to either mdp_calendar or zem_event. It simply creates a select form that will allow you to choose a month and year and automatically jump to the month.

I figure that if I needed it, maybe someone else will also. It’s my first plugin, so if I did something stupid or if there are any bugs, let me know (but be nice…). It’s so simple though, I can’t imagine that there are any huge problems…

Download

cnn_month_select-1.2.txt

Usage:

Just place a <txp:cnn_month_select /> tag wherever you want the form to appear.

Attributes:

  • plugin
    • the plugin that creates the calendar
    • optional values are zem_event or mdp_calendar
    • default is zem_event
  • id
    • the id attribute of the form element
    • default is monthSelectForm
  • action
    • the action attribute of the form
    • default is blank
    • this only needs to be used if you want to place the form on a different page from the calendar itself.
  • wraptag
    • the html tag to wrap the form elements in
    • default is div
  • monthselectid
    • the id attribute of the month select element
    • default is monthSelect
  • monthlabel
    • the label text for the month select element
    • default is Month:
    • example usage: <txp:cnn_month_select monthlabel="Choose a month: " />
  • yearselectid
    • the id attribute of the year select element
    • default is yearSelect
    • only needed used with mdp_calendar
  • yearlabel
    • the label text for the year select element
    • default is Year:
    • only needed used with mdp_calendar
  • submitvalue
    • the value of the form’s submit button
    • default is Go
  • submitid
    • the id attribute of the submit button
    • default is blank
  • submitclass
    • the class attribute of the submit button
    • default is button

Changelog

  • Version 1.2 – July 14, 2008
    • Fixed a bug where the list options would always show the same months, regardless of what month was being viewed.
    • Cleaned up the code a little to be easier to read and (possibly) update.
  • Version 1.1 – July 10, 2008
    • I forgot to add the id attribute to the select elements. This is fixed.
    • Added the monthlabel and yearlabel attributes to the plugin. (See above or the plugin help for usage instructions.)
  • Version 1.0 – June 30, 2008
    • Fixed a bug that caused the form to show the current month instead of the month being viewed by the calendar.

Last edited by cnewkirk (2009-12-12 01:04:55)

Offline

#2 2008-06-28 02:09:02

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 959
Website

Re: [plugin] [ORPHAN] cnn_month_select

With zem_event not being actively updated, this is a nice addition.

Functional observation fwiw: when I change the month (say I go to April 2009), everything works as intended. Once April 2009 is displayed, the button resets to June 2008 (the actual current month). It was unexpected behavior for me. I would have expected it to show the month currently being displayed, not the actual current month.

Even so, nice addition to zem_event.

Mike

Offline

#3 2008-06-28 17:41:56

cnewkirk
Plugin Author
From: Bakersfield, Ca
Registered: 2006-01-04
Posts: 21

Re: [plugin] [ORPHAN] cnn_month_select

Oops… It works that way if you are using mdp_calendar, but not zem_event.

I’ll fix it on Monday, but in the meantime, you should be able to edit the plugin and make it work.

Find this line:

$currentdate = $y.'-'.prepend_zero($m);

and change it to:

gps('date') ? $currentdate = gps('date') : $currentdate = $y.'-'.prepend_zero($m);

let me know how this works.

Offline

#4 2008-06-28 18:14:10

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 959
Website

Re: [plugin] [ORPHAN] cnn_month_select

Looks like that fixed it.

Thanks!

Offline

#5 2008-06-30 15:06:39

cnewkirk
Plugin Author
From: Bakersfield, Ca
Registered: 2006-01-04
Posts: 21

Re: [plugin] [ORPHAN] cnn_month_select

Ok, the plugin is updated with the fix for maverick added.

I went ahead and changed it to version 1.0 also. I don’t imagine that there will need to be many more changes, but let me know…

Offline

#6 2008-07-10 03:03:27

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 959
Website

Re: [plugin] [ORPHAN] cnn_month_select

in case anyone wants the fix:

when validating xhtml 1.0 strict there will be a warning that id=“monthSelectForm” references a non-existent id.

Edit the plugin to fix:

Find
‘monthselectid’ => ‘monthSelect’,

Replace With
‘monthselectid’ => ‘monthSelectForm’,

Offline

#7 2008-07-10 22:18:30

cnewkirk
Plugin Author
From: Bakersfield, Ca
Registered: 2006-01-04
Posts: 21

Re: [plugin] [ORPHAN] cnn_month_select

Aww Man!!! I hate stupid errors like this one…

I forgot to add the id attribute to the select elements. Maverick, the fix you suggested will get rid of the validation warning, but it’s not really the correct fix.

So I added the correct id to the select elements and updated the plugin to version 1.1.

I also took the opportunity to add a couple of new attributes to the plugin: monthlabel and yearlabel. See the plugin help for instructions on how to use them.

Last edited by cnewkirk (2008-07-10 22:23:15)

Offline

#8 2008-07-14 21:16:54

cnewkirk
Plugin Author
From: Bakersfield, Ca
Registered: 2006-01-04
Posts: 21

Re: [plugin] [ORPHAN] cnn_month_select

I found another little stupid bug, so welcome to version 1.2. See the title post and changelog for details.

I hope this is the last update to this thing…

Offline

#9 2008-07-19 05:44:57

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

Re: [plugin] [ORPHAN] cnn_month_select

Chris,

Thanks for the plugin – it’s a great enhancement.

I had to modify the code to get it to work for me though. I made 2 changes:

(1) I’m using it with mdp_calendar that has an attribute of id="calendar" in the tag. This puts a CSS ID in the rendered HTML for the calendar but it also puts a &calid="calendar" in the GET vars.

To force cnn_month_select to do the same I added the following line, just before the last $out[] = doTag ... line:

	$out[] = doTag('', 'input', '', ' type="hidden" name="calid" value="calendar");

Ideally cnn_month_select could have an additional attribute where the value could be specified in the tag.

(2) I had to use attribute action="diary/" – where diary is the name of the section where I’m using the calendar. If I left the action blank, cnn_month_select sent me to the default page. I’m using clean URLs but messy mode might need action="s=diary" (that’s not quite right but hopefully you get my drift).

Cheers,

Adi

Offline

#10 2008-07-23 17:21:54

cnewkirk
Plugin Author
From: Bakersfield, Ca
Registered: 2006-01-04
Posts: 21

Re: [plugin] [ORPHAN] cnn_month_select

Hey Adi,

I’m glad you found a use for the plugin!!!

As for your suggestions:

(1) Great idea. This is what I get for not fully researching things. I’ll add an attribute into 1.3 when I get back home in a few weeks.

(2) This I’m a little confused about… If you leave the action attribute blank, it should send you back to the same page the form is on (which I’m assuming is the same page the calendar is on), not necessarily the default page. Do you have the form on a different page from the actual calendar? I take your point on the messy urls though; I’ll have to think about that and play around a little…

Offline

Board footer

Powered by FluxBB