Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

adding php in template [solved]


Go to End


2 Posts   5676 Views

Avatar
servalman

Community Member, 211 Posts

23 June 2010 at 4:43am

Edited: 23/06/2010 5:49am

Hello

houpsssss ! I can not do it directly sorry for this post I don't know how to supress them

For some reason (passing a variable to a flash movie via flashvar) I have to insert a line of php inside a template :

Inserting flash object inside the template is pretty simple but writting something like

<? php $toto1='toto'; ?> seems not to work.

Maybe it is not possible

Thank you

Avatar
Willr

Forum Moderator, 5523 Posts

23 June 2010 at 9:13am

You cannot use PHP in the templates. You must write your PHP functions / code in Page.php and call that from your template..

// mysite/code/Page.php 

function ToTo() { return 'toto'; }

// your template

$ToTo;