Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

include content generated by php file in template


Reply


1672 Views

Avatar
qlex

Community Member, 68 Posts

11 May 2009 at 9:27pm

Hi.
I have been struggling with the following problem.
I have a php file, which is basically an ajax-powered box that is linked to a 3rd party transit planning tool. the box allows the user to provide departure/destination and opens an external url in the lightwindow. it also uses jquery autosuggest functionality to aid user when providing the departure/destination.

the file, when called directly in the browser works correctly.
in order to include it in the page class i have done the following:

1) in the Page.ss in the Page_Controller extends ContentController section i have added the following function:

public function getBufferedContent() {
   ob_start();
   include('wartabud.php');
   $return = ob_get_contents();
   ob_end_clean();
   
   return $return;
}

2) put the wartabud.php file in the same directory as Page.php

3) called the function $getBufferedContent in the Page.ss template.

As a result, i got the wartabud.php to display where i wanted, but its there without any functionality (ajax, lightwindow etc.)

The wartabud.php, as you might assume, has some 170lines of code so preferred to have it as separate file.

Could anybody tell me what are my options here? I do require the funcitionality of including such external pieces of code, as i need it for my client's websites.

thanx for any tips and please do try to keep any suggestions simple if possible (im a designer, not a coder)
qlex