The MU forums have moved to WordPress.org

Themifying Event Calendar (24 posts)

  1. JMF
    Member
    Posted 16 years ago #

    Has anyone messed with Kieran O'Shea's excellent calendar plugin with MU?

    It installs fine as a per-user plugin, but is very much written for a single blog install. I'm having fits trying to generalize it so it displays well with different themes.

    Can anyone offer any pointers? Or does it look like an impossible task, the way it's implemented?

    Jeff.

  2. lunabyte
    Member
    Posted 16 years ago #

    Does is include its own stylesheet?

    If so, you can "tweak" the code to pull the stylesheet from the theme directory (most plugins pull it from the plugin directory), and then customize each sheet to match the theme.

  3. JMF
    Member
    Posted 16 years ago #

    Well, it looks like the main problem is that it sort of generates its own page... the calendar is generated on a page called wp-calendar.php that sits in the root directory, which is simply a template with some basic styling, and a call to
    get_header();

    get_sidebar();
    get_footer();

    In the middle of that is a <?php echo calendar(); ?> that draws the calendar. The calendar is accessed by going to http://yoursite.com/calendar, made possible by a couple of .htaccess tweaks.

    This would be easy enough to customize for a single theme, but the calendar call usually needs to be wrapped in some kind of content div or something for many themes...it varies.

    Would there be a way to somehow ad a calendar page template to themes to use his calendar(); call? I'm not sure where to start, or what implications it would have for his .htaccess mods...

  4. JMF
    Member
    Posted 16 years ago #

    It's a REALLY nice calendar, by the way. ;)

  5. andrea_r
    Moderator
    Posted 16 years ago #

  6. dsader
    Member
    Posted 16 years ago #

    I steer away from plugins that scatter their seeds throughout.

    Before long there are orphaned files through your install.

    I'd start by keeping all plugin files in one folder.

    I like plugins that add their magic stuff in the following way to an otherwise normal page/post:

    function calendar() { whatever
    }
    function generate_calendar($content) {
    	if (strpos($content, "<!-- calendar -->") !== FALSE) {
    		$content = preg_replace('/<p>s*<!--(.*)-->s*</p>/i', "<!--$1-->", $content);
    		$content = str_replace('<!-- calendar -->', calendar(), $content);
    	}
    	return $content;
    }
    add_filter('the_content', 'generate_calendar');
    
  7. andrea_r
    Moderator
    Posted 16 years ago #

    Betcha it coudl be re-written. ;) yep, it sounds like a convoluted plugin, but hey, I'm just answering the question...

    one would think the plugin itself would automagically insert itself into the theme.

  8. lunabyte
    Member
    Posted 16 years ago #

    Yep, that one would.

    Nothing difficult about using the hooks provided to tap right into it. A lot of plugins do that.

    They have you add

    <!-- whatever -->
    to a page, and off you go.

    If the css file (if there is one) needs to be kept in single location, the file could be named themename.css, where themename is the name of the theme in use.

    Then, pulled in from the plugin/calendar/css (or whatever) directory.

    If it uses what's already in the theme, instead of adding its own stylesheet, even better.

  9. JMF
    Member
    Posted 16 years ago #

    Yeah, I don't like the idea of scattering files everywhere, either...but it's a *REALLY* nice calendar. ;)

    Pr'aps I'll poke at it a bit, but I'm not such a good poker, sometimes...

    [Edit]: Oh wow. It looks like the page template-thing DOES work, so I can just make a page template for each theme. Excellent! *rubs hands together...

  10. JMF
    Member
    Posted 16 years ago #

    Ak. Nevermind. Making a Page template with just a call to get_header(); calendar(); get_footer(); on it generates a calendar Page, but it pulls ALL THE code (HTML and all) from the wp-calendar.php page in the root directory, instead of reading the Page (or in addition to?).

    So no go so far. I'm not technically capable enough to convert this to a 'standard' plugin, and honestly, for my setup, having an honest-to-goodness Page called "Calendar" would be really cool.

    Waitwaitwait: I noticed the Page's url works out to http://www.mysite/calendar, so removing his line "RewriteRule ^calendar/?$ wp-calendar.php [QSA,L]" from the .htaccess forces it to pull up my Page template, instead.

    HOWEVER, Next and Pervious calendar links return a 404 error. The URL's are formatted as http://site.com/calendar/2007/jul, and there's a rewrite rule to handle those, too:

    RewriteRule ^calendar/([^/\.]+)/([^/\.]+/?$ wp-calendar.php?year=$1&month=$2 [QSA,L]

    I see what that does, but I don't know how to wrangle an .htaccess. Is there a way I could modify that to make it work? (At first glance, I'm guessing "no.")

  11. hawaiian
    Member
    Posted 16 years ago #

    JMF - any updates to converting this calendar for WPMU? I just checked it out and it *is* a really good looking calendar...

  12. SteveAtty
    Member
    Posted 16 years ago #

    It is good looking - I'm currently hacking it round as its got some very odd quirks in it.

  13. SteveAtty
    Member
    Posted 16 years ago #

    OK - I've got it working. Got the rewrite rules working for subdirectory mode (as that is what I run) for everything but the base blog.

    Had to hack a couple of things to get it to work and also had to use a couple of self developed chunks of code to cope with the fact that templates aren't consistent in their layout which enabled the calendar to be embedded into any active template you have.

    Two examples:

    http://canalplan.blogdns.com/steve/calendar/2007/jul
    and
    http://canalplan.blogdns.com/mintball/calendar/2007/oct

  14. tkreucher
    Member
    Posted 16 years ago #

    Hey Steve,

    Mind sharing more about how you got this working? I'd be interested and I'm sure others would too. :) I've searched high and low for a means to do this but so far you are the only implementation of this particular calendar on MU that I've seen working properly.

    Thanks much!

  15. SteveAtty
    Member
    Posted 16 years ago #

    I realised the other day that I'd hacked the date formats for the UK and its used all over the place in the code when you are creating/editing an entry. I'll tidy that bit up so its only defined in one place and then bundle the files up including my open and close tag code blocks which I use all over the place to handle page wrapping

    I did email Kieran about the changes I made to make it fully MU compatible but I didn't hear anything back from him.

  16. tkreucher
    Member
    Posted 16 years ago #

    Gotcha. Well any helpful info you can offer on it would be fantastic. :) It's a great calendar, and it's the one they want to use for our blogs here, and I'm stumped. :) Thank you and let us know!

  17. SteveAtty
    Member
    Posted 16 years ago #

    OK its done.

    I've included my Template wrapping files but it can be installed without them in the more "traditional" way.

    http://canalplan.blogdns.com/steve/2007/12/01/tweaking-a-calendar-for-wpmu/

    There is one annoyance with it - the htaccess rules tend to grab things rather aggresively. So you can't actually have a permalink starting with calendar !!

  18. Farms
    Member
    Posted 16 years ago #

    Nice work! Thanx for sharing :)

  19. SteveAtty
    Member
    Posted 16 years ago #

    Arrgghh!!

    I was having brain cramps over the weekend - I guess the jetlag caught up with me.

    I completely misnamed the link for the download.

    I've updated the page now so it should be OK.

  20. tkreucher
    Member
    Posted 16 years ago #

    OK, so, the holidaze arrived and all of my time has been put into other issues up until now, and I'm having a chance to really work on this again. Sorry to keep dredging it up, but I really want to get this calendar working. :)

    SteveAtty, I downloaded the package you provided and followed the instructions (and once again, thank you so much for making it available!).

    I believe I have an issue with .htaccess, although I've amended it with the two lines provided in the package. Here's what's going on:

    I can get to the current month's calendar when going to:
    http://URL/calendar

    But when I try to go to the previous or next month, I get 404'd. The URL it is going to when clicking "Next" for instance is:
    http://URL/2008/feb

    So if I go and manually change the URL to
    http://URL/calendar/2008/feb

    I can get to the February calendar. But then when I click "Previous" to go back to January, it adds an extraneous 2008 both to the URL and the calendar display.
    http://URL/calendar/2008/2008/jan

    And, any events I had posted to the Jan 2008 calendar are missing because that is not the Jan 2008 calendar, it is the Jan 2008/2008 calendar.

    Clicking Previous again brings up the Dec 2008/2008/2007 calendar page with the URL
    http://URL/calendar/2008/2008/2007/dec

    I am trying very hard to figure this out on my own, but I'm obviously missing something. Perhaps it is obvious, and I will feel like a twit once it's pointed out to me. But I'm taking the twit-risk! I just really want to get this working.

    Also, I am looking at picking up the book Mastering Regular Expressions"> by Jeffery Friedl to add to my library. Any suggestions about it, good, bad, or an alternative you'd recommend more?

    Thank you so much, I really appreciate how helpful this community has been and I want to be a contributor to that assistance as my own knowledgebase and experience with this fantastic product grows. :)

    Cheers,
    Trase

  21. trehug
    Member
    Posted 16 years ago #

    hey there,

    i had been messing with this calendar for a while, and i like it too.

    there are some wierd things with it, for sure.

    even though you may have changed your htaccess - wordpress creates return codes to the browser for it's own reasons.

    i noticed after using this calendar, that some pages were 404's but should not be.

    if you get a utility that allows you to see the HEADER info that the server is throwing back to your browser - you'll see that the page is actually created, but WP is sticking in a 404 with it - but the page content was there anyway!

    funnier still, is that IE and firefox react differently to the 404 *with* the page content, sometimes showing it, sometimes not.

    i found that the solution for me anyway, was to go into the wp-includes/classes.php file
    and insert these lines:

    if (!empty($request_match) &&
    (preg_match("!^calendar/?$!", $request_match) ||
    preg_match("!^calendar/([0-9]+)/([a-z]+)/?$!", $request_match))) {
    unset($error);
    unset($_GET['error']);
    return;
    }

    well, i did this months ago! now i need to review, but i'll be back to make a more sensible statement about it shortly - but check the headers, the adventure begins there...

    ps - it IS a nice calendar, i'm changing mine to allow links in the events, and a few other niceties that it should have.

    PS - the css for it can certainly be seperated out, it's all hardcoded in the calendar.php file. i had just started that when i had to take a couple months away - kerian's css is not that great when it comes to the way he has layed out the table, and especially considering his use of nowrap.....but nonetheless he has done a nice job, it just needs that extra little push.

    ok i'll post more when i have re-dug into this - back on the case! good luck and hth.

  22. trehug
    Member
    Posted 16 years ago #

    -um, i wasn't meaning to knock the guy - i think it is great! and i'm definitely noooo expert, damn

    well...hope it keeps improving

  23. trehug
    Member
    Posted 16 years ago #

    a bit more info

    - on the calendar pages (only), my site seems works with the "www" and without.

    i read that there can be a google penalty for duplicate info or something like that...not sure how that all ties in, but i guess the htaccess lines for the calendar are causing that? that stuff is tricky..

    also - those changes i mentioned in the classes.php file were given to me from a thread on bluehost's forum - a member named lazynitwit offered the suggestion and it was helpful.

    the code goes around line 130, above the line,

    // If req_uri is empty or if it is a request for ourself, unset error.

    hth, later

  24. erick_paper
    Member
    Posted 16 years ago #

    Is there any plugin that does this now for 2.3.3, but without sputtering code all over? I'd just like to show a calendar in the entry/post itself (as that demo in the first post of this thread) but with a plugin that's, um, more modern. Thanks!

About this Topic