Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Include PHP command in .ss

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1611 Views
  • corkg
    Community Member
    30 Posts

    Include PHP command in .ss Link to this post

    How can you add a PHP Query in the Page.ss File?
    if($HeaderImage == NULL){$HeaderImage=="imsa_files/construct/header.png"; }else{ $HeaderImage=="$HeaderImage";}

    Where $HeaderImage is a Variable saved into the database.

  • sammahoney
    Community Member
    14 Posts

    Re: Include PHP command in .ss Link to this post

    I've been asking the same thing but no joy so far. I want to add a PHP include to a .ss file, but I get an error everytime.

    Anyone any ideas no?

  • zyko
    Community Member
    66 Posts

    Re: Include PHP command in .ss Link to this post


    if 'Variable saved into the database' means a page db_column:
    i know it's not absolutely the thing you want,
    i do these things by implementing a function on the page (or DataObject)
    which has this logic inside.
    than use the function in the template


    public function RealHeaderImage() {
    if (!$this->HeaderImage) {
    return "imsa_files/construct/header.png";
    return $this->HeaderImage;

    then in ss use


    not sure whether soemeone has to use brackets, or not...


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.