Forums / General / How to include PHP in templates

How to include PHP in templates

Author Message

Karmela Shah

Tuesday 21 March 2006 11:27:25 am

Hi,
I have been looking all over and cannot find a answer for adding a php file or just a script to the pagelayout template.
I know that {literal} is for HTML, but is there any other tag that I can use to add PHP scripts?

What I am trying to accomplish is to have an admin page that I could go to and add the a schedule to the database and have the upcoming events to show up on the main page.

I know how to do it in PHP but I don't know how to do this in ezpublish.
Does any one have any idea how to do this?

I would really appreciate it if you could help me.
Thanks.
Karmela

Betsy Gamrat

Tuesday 21 March 2006 6:41:40 pm

Karmela,

Break the week down into days and times and then place your content in as needed. Create container classes for weeks, days, and times. Then as you create events, use the location bar to put them into the appropriate times.

To pull the data out for the home page, you'll need to determine the date and time (adjust it for any time zone differences between the server location and the target time zone), then traverse the schedule to find the corresponding node and display the data.

Good luck

Karmela Shah

Thursday 23 March 2006 5:32:05 am

Dear Betsy,

Thank you for aswering my question.
However, since I am not really familiar with ezpublish, I could not understand what exactly you meant. Is it possible for you to explain a little more? I would really appreciate it.
Also, do you know if there is a tag I can use to add php scripts to the templates?
Thank you very much.

Karmela

Betsy Gamrat

Thursday 23 March 2006 1:58:02 pm

Hi,

My approach was to create classes for a week, day, and hour - and then use the location bar to put the events in there. There is alot of custom code involved. If you are new to eZ publish, you might want to consider handling the calendar with a different method. eZ does have its own calendar, but I have never used it.

If you are just going post upcoming events, you may be able to just post them in a list with the existing classes and use a template to display the next one in the list, sorting them in descending order of date (from most recent to most distant).

There are no tags (that I know of) to put PHP directly in templates. This describes AJAX, which you might be able to use to include PHP content in an eZ publish template. Basically, the client browser uses javascript to request the PHP content after the page loads.

http://www.w3schools.com/ajax/default.asp

This is a nice calendar that you might be able to use.

http://www.ikemcg.com/scripts/index.html

Good luck.

Betsy Gamrat

Saturday 08 April 2006 10:27:52 am

I found the answer to this in a rather roundabout way, but here it is:

If you would like to integrate dynamic content from several applications, you can use <b>readfile</b>.

By creating a siteaccess for eZ that delivers content on a transparent background, you can use PHP to pull the content into a page and deliver it with other content. This would be valuable in cases where you would like to include content from several applications on the same page, and use the applications to manage and deliver the content.

<?php
echo readfile("http://domain.com/ez/index.php/plain");
?>