Jump to:

3439 Posts in 1028 Topics by 869 members

Template Questions

SilverStripe Forums » Template Questions » include content generated by php file in template

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1616 Views
  • qlex
    Community Member
    68 Posts

    include content generated by php file in template Link to this post

    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() {
       $return = ob_get_contents();
       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)

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.