Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Static page customization

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

Page: 1
Go to End
Author Topic: 244 Views
  • boompb
    Avatar
    Community Member
    2 Posts

    Static page customization Link to this post

    Hi

    I'm trying to create a static page with some customization in it.

    In my ProjectPage.php i have:

    class ProjectPage_Controller extends Page_Controller
    {
        function init()
        {
           parent::init();
        }
       
        function myCustomFunction()
        {
           include('../../../ext/incl/test.php');
           $name = 'BLAH';
           echo '<a href="http://example.com/php/test.php?name='.$name.'">link</a>';
        }

    }

    And in my ProjectPage.ss i have something like:

    <div>
    $myCustomFunction
    </div>

    The problem is the function is called BEFORE everything else (ie. before <html>) & not at the point between the divs.

    Can anyone help as to why?

    Cheers

  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: Static page customization Link to this post

    I'm not sure on the full template processing pipeline but HTML is not genreated procedurally. Functions are processed then the HTML is genereted so if you want a function to output a value into the template at it's insertion point you need to use return instead of echo.

    return '<a href="http://example.com/php/test.php?name='.$name.'">link</a>';

  • boompb
    Avatar
    Community Member
    2 Posts

    Re: Static page customization Link to this post

    Thanks!

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