1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. To combat forum spam, new accounts will need to make at least one (valid) post.
    Otherwise, we will periodically purge all users without posts or that haven't confirmed their account.

Integrating EPC into a Wordpress sidebar

Discussion in 'Wordpress' started by Mad Dog, Jul 17, 2006.

Thread Status:
Not open for further replies.
  1. I recently incorporated EPC into the sidebar of a WordPress template and had to muck my way through a few things before it worked right. It turns out it’s actually pretty simple once you know the steps. To help anyone else who’s looking to do this, here are the basic steps and pointers to ease the way:

    1. Make sure you create the EPC database table in the same MySQL database WordPress uses. When you set up EPC, point it to the database and it will take care of the dirty work.

    2. Most WordPress templates split pages into several files: header.php, sidebar.php, etc. Follow the directions in the INTEGRATION section of EPC help. Typically you’ll:

    - Add the CSS call to the HEADER.PHP file just before the </HEAD> tag:
    <?php $CSS=1; require("calendar/calendar.php"); ?>

    - For the mouseover option, add the code in SIDEBAR.PHP, right below the <body> tag:
    <?php $OL=1; require("calendar/calendar.php"); ?>

    - You may have to play with the path to find works with your server and site structure. Make sure it’s a relative path. I ended up having to use: “../calendar/calendar.php”

    3. In Wordpress, make sure the PERMALINKS (OPTIONS > PERMALINKS) are set for the default (“http://yoursite.com/wordpress/?p=123”) so your calendar’s month-to-month navigation works with your archive pages. If you don’t, things will get very confused.

    That should pretty much do it. Of course you may need to edit the CSS to make the calendar smaller if you have a narrow sidebar.

    Good luck!
    Mad Dog
  2. Brian

    Brian EPC Developer Staff Member

    (Made into a sticky!)
  3. I am having trouble integrating my easy php calendar into my wordpress blog.

    Thing I've done already:

    I've successfully added my EPC to the wordpress blog's database on my server.
    I host my my own WordPress site.
    I've placed the <?php $CSS=1; require("calendar/calendar.php"); ?> tag in the header.php file.

    Here are things I currently cannot do.

    1) I cannot place the sidebar mouse-over code in the <body> portion of the sidebar.php of my theme because there is no <body> tag in the sidebar.php. I'm not sure if this is because I"m using dynamic sidebars, but the three sidebar.php files I've looked (my current theme, the Classic theme and the default theme simply do not have <body> tags in their sidebar.php files.

    2) in addition, adding the php code you mentioned in the "Text 1" area of the sidebar (via the sidebar widget) results in nothing being displayed.

    3) I've found that trying to post php code in my actual posts results in the code being ignored. I've tried using plugins like exec php, but to no avail.

    Is there some kind of security built within wordpress that prevents php scripts from being executed?

    I'm in the dark here. I've exhausted all my options. I want to get a dynamic blog working with a built in calendar. Is this too much to ask?

    thanks for your input.
    -cosmo d
  4. TRY THIS:

    1. In the file header.php, find the <body> tag and place this code JUST UNDERNEATH IT:

    <?php $OL=1; require("calendar/calendar.php"); ?>

    2. In the file sidebar.php, right under the line <div id="sidebar"> (or whatever that div is called in your template) add this code:

    <div id="easyCalender">
    <!-- ADD CITYDISH.PHP CALENDAR -->
    <?php require("calendar/calendar.php"); ?>
    <!-- END CALENDAR -->
    </div>

    This of course will add the calendar to the top of the sidebar. It should work. You can move it elsewhere. And depending on your template, you might have to alter the EPC CSS to adjust the size of the calendar.

    Let me know if that works.

    Mad Dog
  5. It worked. Thank you for posting the quick and useful reply. They key for me was putting the

    <div id="easyCalender">

    <!-- ADD CITYDISH.PHP CALENDAR -->
    <?php require("calendar/calendar.php"); ?>
    <!-- END CALENDAR -->
    </div>

    command in the sidebar.php file. What, exactly, does that command do?

    I tell ya, I'm fairly new to PHP, but putting together my home website as given me a lot to chew on. Thank you for this very useful guide.
  6. Sorry if I left out what I thought was the obvious in my posting: That's the code that inserts the actual calendar! It actually creates a <div> for it (in case you want to use custom CSS), then the lines before and after it are simply comments to make it easy for you to remember what that's all about when you have to go back to it in a few months.

    The other pieces of code you added link to the CSS file and set it up so the mouseover works, what I thought were the tricky parts.

    Learning to mess with Wordpress templates will teach you a lot....and frustrate you a lot. But it is a great learning experience. Glad I could help.

    MD
  7. The issue appears to be that it always pulls in the php file (in the case of WP, that is index.php).

    To make this not be an issue open calendar/calendar.php and look for:

    Code:
    // DETERMINE NAME OF CURRENT FILE
    if (!isset($thisFile) || (isset($_GET['thisFile']) || isset($_POST['thisFile']))) {
      $thisFile = $_SERVER['SCRIPT_NAME'];
      $thisFile = explode("/",trim($thisFile)); 
      $thisFile = $thisFile[count($thisFile)-1];
      if (!file_exists($thisFile)) $thisFile = htmlentities($_SERVER['PHP_SELF']);
      }
    
    And replace it with:

    Code:
    // DETERMINE NAME OF CURRENT FILE
    if (!isset($thisFile) || (isset($_GET['thisFile']) || isset($_POST['thisFile']))) {
      $thisFile = "";
      }
    
    This should remove the "index.php" that it places in the links and any WordPress page should function correctly.

    From what I've seen I don't think this will cause issues with the other displays, but if it does you could always create two versions of the file and call the one that you need for a particular display.
  8. I'll be interested to find out if other people try it to see if it works. For me, the default permalinks set-up works fine so I'm not inclined to mess with this unless I have to.

    MD
  9. I'll let you know - because the permalink solution doesn't work for me either. I was able to get the calendar inserted but the links are wrong.

    http://www.ignatiusproductions.org/ it's not looking for the calendar.php within the calendar directory.

    Leslie
  10. I tried using this code - now it produces links like
    HTML:
    ?mo=7&yr=2007
    Any other suggestions?

    Thanks,
    Leslie
  11. Also is I include this:

    I wind up with 2 calendars. One at the very top of the page and one where I placed it.

    Also none of the dates that have events are linked - in addition to the next month links being wrong.

    Thanks again,
    Leslie
  12. Looking at the URL you posted I see one calendar and the pop-ups work. Have you figured it all out or is something still a problem?
  13. I'm still "playing" with it. The links at the bottom still are wrong. I'm wondering is there some way to maybe iframe it? Even if I get the correct links, I have no idea how it's going to work - I think it will not "reload" into the WP index page.

    I'm having to copy and paste the javascript into the sidebar and add the CSS into the WP css file to even get what I have there. None of the tips I have found posted here have worked for me.
  14. ve9gra

    ve9gra Support Team

    I'm not sure why you're having so much trouble... I am willing to give it a try if you will give me access to your Wordpress. (Contact me via the link in my sig)
  15. I'm checking it out and things seem to work as they're supposed to as far as I can see. The "next month" and "previous month" links work. The links underneath the calendar work. The calendar pop-ups work. So I'm not sure where the problem is at this point.
  16. Yup, yup! Many, many many thanks go to Gervais. Couple things I had tried were not quite right and then I left out a tag. But I know better now!

    Leslie
  17. has anyone got the calendar working in AJAX mode with wordpress? i'm about to try it, but i'm wondering if anyone has any tips before i jump in.

    cheers.
  18. ve9gra

    ve9gra Support Team

    I haven't heard of anyone trying it out. But I don't see why there would be an issue.
  19. Glad I found this thread - I've made the changes to the calendar.php file as suggested by watershedstudio.

    The calendar displays, but when I change months the entire page the calendar is included on is re-loaded.

    What I'd like is to just have the calendar re-written, not the entire page.

    I found a reference to an iframe code, but I'm not sure how to incorporate the settings that are currently calling the monthly calendar to display.

    Here's what I currently have to display the calendar:

    <div id="easyCalender">
    <!-- ADD EASY PHP CALENDAR -->
    <?php
    $TOC=1;
    require("phpcalendar/calendar/calendar.php");
    ?>
    <!-- END CALENDAR -->
    </div>

    and here is code for displaying the calendar in an iframe (found from another thread)

    <iframe src="calendar_list_mode.php?mo=<?php echo $mo ?>&yr=<?php echo $yr ?>" height="400" width="465"></iframe>

    How do I incorporate my code into the src value for the iframe code?

    Hopefully I explained that so other people can understand...
  20. Is there a list of command line variables, other than the few listed in the docs? I've searched this site, and all the files for the installation, but can't find any reference to the "calendar_list_mode" variable set in the iframe code above.

    Did I miss the list somewhere?
Thread Status:
Not open for further replies.

Share This Page