17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 3456 Views |
-
silverstripe don't let me add PHP code

14 October 2008 at 3:40am
Hi!
I want to add php code in /themes/mytheme/tutorial/Page.ss but I have this error:Parse error: syntax error, unexpected T_STRING in C:\WINNT\Temp\silverstripe-cacheE--_silverstripe_cms-elisa\.cacheE.._silverstripe_cms.elisa.themes.villevenete.templates.Page.ss on line 25
why?
Can I add php code in .ss file? is necessary to include php in tag <?php ... ?> ??I try with this tag and witougth but nothing change.. -
Re: silverstripe don't let me add PHP code

14 October 2008 at 4:39am
SS follows the MVC approach, which means keeping all different kinds of content separated. You can't add php code in your template, at least not easily. You could do so by using iframes or similar.
PHP code is suppose to go in your page/controller class, and then accessed in the template by using loops and variables.
-
Re: silverstripe don't let me add PHP code

14 October 2008 at 5:01am
Thanks!
sorry butI post some day agò and I try to solve the problem but I Can't.. -
Re: silverstripe don't let me add PHP code

17 October 2008 at 12:24am
Put your php code in /mysite/Page.php inside a new function under the Page_Controller.
e.g.
class Page extends SiteTree {
static $db = array(
);
static $has_one = array(
);
}class Page_Controller extends ContentController {
function init() {
parent::init();
}
// Pull out the currency cookie value and return
function myCustomFunction() {
return "Hello World"
}}
Then in your Page.ss file, simply call the function to output whatever it returns:
$myCustomFunction
You cannot put PHP code into any .ss file. I suggest that you work through the tutorials to get a better idea of how Silverstripe works here: http://doc.silverstripe.com/doku.php?id=tutorials
| 3456 Views | ||
|
Page:
1
|
Go to Top |



