Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » php

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: 1924 Views
  • jerome187
    Avatar
    Community Member
    5 Posts

    php Link to this post

    I need to put some php into one of my .ss files (its a template) how to I tell ss to process it as .php and not .html?

  • jerome187
    Avatar
    Community Member
    5 Posts

    Re: php Link to this post

    Someone in #silverstripe helped me figure it out.

  • marikas
    Avatar
    Community Member
    24 Posts

    Re: php Link to this post

    Hi Jerome187,

    Great you learned how to do this. Would you mind sharing the titbit to help other helpless fools like myself?

    TIA

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: php Link to this post

    to follow up on the request: the underlying principles that silverstripe builds upon generally discourage putting too much logic into templates, thats why we have a intentionally restricted template language that doesn't parse PHP.
    PHP-code belongs into the controller or model, which can both be accessed in the template by calling methods on them.

    more information:
    http://doc.silverstripe.com/doku.php?id=tutorials
    http://doc.silverstripe.com/doku.php?id=datamodel
    http://doc.silverstripe.com/doku.php?id=templates
    http://doc.silverstripe.com/doku.php?id=objectmodel

  • jerome187
    Avatar
    Community Member
    5 Posts

    Re: php Link to this post

    pretty much you write a php function in the page controller then call it from your template. Unfortunately this only solved one problem for me, getting the captcha image to display (and validate too) but I ran into another problem when making a form that precesses credit cards via cybersource. Creating the form in php was a huge pain, and I could not even get it working, I could not find out how to change the action to something simple, like action="https:somewhere.com/process.php" I could make the form call a php function when it gets submitted but I did not know how to make php send a form to an address. Also in the form this code was necessary:

    <?php
    require_once ("HOP.php");
    InsertSignature("$ammount", "usd")
    ?>

    I had no idea where to put that... I ended up making the order page outside of ss and using a page to redirect to it. Kinda lame cause its a static page and has to be edited everytime the site is changed from the cms. Does anyone know what I'm talking about and can anyone propose a better solution for this? I like SS, becides not allowing php in the templates... and making the forms, its nice for error checking but.... maybe if I knew how to use them better?

    --Jerome

    1924 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.