PDA

View Full Version : Integrating EPC into a Wordpress sidebar


Mad Dog
07-17-2006, 03:29 AM
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

Brian
07-17-2006, 10:00 AM
(Made into a sticky!)

gumbomasta
09-28-2006, 01:08 AM
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

Mad Dog
09-28-2006, 01:40 AM
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.

I wouldn't recommend adding PHP code using any widgets. Add it manually into the sidebar.php file.

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.

why are you trying to add PHO in your posts? Is this related to using EPC? (I have Exec PHP installed and it works fine for me)

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

Wordpress runs completely on PHP. Because of how it's parsed, without using a plug-in like ExecPHP it won't parse posts.

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


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

gumbomasta
09-28-2006, 01:57 AM
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.

Mad Dog
09-28-2006, 02:06 AM
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.

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

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

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:


// 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:


// 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.

Mad Dog
02-28-2007, 06:49 PM
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.

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

lesliekirk
06-06-2007, 06:50 PM
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

lesliekirk
06-07-2007, 11:36 AM
And replace it with:


// DETERMINE NAME OF CURRENT FILE
if (!isset($thisFile) || (isset($_GET['thisFile']) || isset($_POST['thisFile']))) {
$thisFile = "";
}


I tried using this code - now it produces links like ?mo=7&yr=2007

Any other suggestions?

Thanks,
Leslie

lesliekirk
06-07-2007, 12:08 PM
Also is I include this:

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


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

Mad Dog
06-07-2007, 01:47 PM
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

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?

lesliekirk
06-07-2007, 01:54 PM
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.

ve9gra
06-07-2007, 04:35 PM
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)

Mad Dog
06-07-2007, 06:14 PM
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.

lesliekirk
06-07-2007, 06:20 PM
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

jazbek
07-11-2007, 01:05 PM
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.

ve9gra
07-11-2007, 06:49 PM
I haven't heard of anyone trying it out. But I don't see why there would be an issue.

redcrew
10-25-2007, 01:39 PM
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 (http://www.easilysimplecalendar.com/forums/showthread.php?t=5373))

<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...

redcrew
10-26-2007, 12:16 PM
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?

Brian
10-26-2007, 09:06 PM
calendar_list_mode is not a command of the calendar. Must be something to do with WP?

redcrew
10-27-2007, 02:03 PM
Thanks for the reply. Guess I'll reword the question.

How can I include the easy php calendar into a page using an iframe? What would be used for the "src" attribute in an iframe?

ve9gra
10-27-2007, 09:26 PM
Some other page that has the calendar displayed on it.... Like /calendar/demo.php for example.

redcrew
10-27-2007, 10:16 PM
Guess I'm not explaining the issue very well.

On the page named "calendar", I want to include the simple php calendar in an iframe or object. The page named "calendar" is the page the currently contains the calendar code on the page, along with the header, footer, etc. for that page.

I don't want to include the page named "calendar" into another page - if I did, the other page would include the footer, header, etc. for that page.

What I'm looking for is the code reference to use just for the calendar created by simple php calendar. I want to reference it in the "src" for an iframe code segment.

Jazbek references the iframe code in this reply (http://www.easyphpcalendar.com/forums/showpost.php?p=24329&postcount=13), but I haven't found her code posted on the forums.

ve9gra
10-28-2007, 07:20 PM
No, you're not getting it...

You cannot directly reference the calendar in the src of the iframe. You'll have to create your own blank page that includes the calendar (or use one of the demos that are included) and use that for your source.

Tore
02-15-2008, 04:55 PM
Bump. :)

Would be good to have a way to get the nice permalinks in WordPress work with the calendar. The provided solution may have worked with past versions. But not with the latest WP and Calendar.

ve9gra
02-15-2008, 07:34 PM
It does work... as long as you keep the Permalinks set to the "Default" type.

Tore
02-16-2008, 12:46 PM
What I mean is to use options like Date and Time based links. I'm sure most WP calendar users had WordPress before they got the
calendar and they already have permalinks set up to look "nicer" than the default option. Now they all have to give people new links to subpages.

If permalinks only works with one out of many many options, then they don't work well enough.

ve9gra
02-16-2008, 02:43 PM
You have to understand that Easy PHP Calendar was developed as a stand-alone application. Integrating it within other applications has a varying level of success, but it was never modified to cater to a specific application. It was never meant as a WP plugin, and should never be considered as such. The fact that it plays nice with one of the WP Permalinks type should be appreciated.

Tore
02-17-2008, 11:49 AM
I do appreciate it. That however no reason why one shouldn't wish to know it if somebody should come up with ways to integrate it even better.
:)

Tal
09-13-2008, 10:14 AM
Just wanted to say thanks for the instructions on this thread - with the first few posts I successfully got my calendar in my sidebar - nice.

the calendar software is the best I've found so far for wordpress to replace jevents I was using in joomla before I ditched joomla - there's still a lot of features I'd like to see added - like a search function and the ability to pull up a calendar with events from just one category and stuff like that - but at least I'm on my way now.

csmitty58
10-03-2008, 06:03 PM
My biggest mistake was to think I could make this work, I was first unaware of the difference between wp.com and .org. second I am not very experienced with web design and that mistake cost me $50.00. I at least hope the calendar file are on my computer so in the event I do go to a host site I will have them. as for the 50.00 oh well lesson learned have a beer on me smitty