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.

Archive /

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

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

Couple of questions


Go to End


3 Posts   1452 Views

Avatar
eKstreme

2 Posts

14 September 2007 at 11:44pm

Hey,

I just heard of SS at Read/Write Web. Looks very very good. I have two questions that I couldn't answer from searching the docs.

Basically, I want to create a web app with a login system built in and a blog and forum and other features to interact with the community.

1. Can PHP code be part of the page's content? This would be useful for doing database lookups.

2. If so, is there a way to figure out if a user is logged in or not?

Thanks.
Pierre

Avatar
Matt

Community Member, 86 Posts

16 September 2007 at 7:45pm

We try to separate design/layout and code as much as possible, so you can't just put PHP directly into your page templates, but you can achieve the same thing by adding something to both your template and code files, for example inside your Page.php and Page.ss files:

<?php
/** Get something cool
 * @return CoolObject Something that's cool
 */
function GetCoolThing() {
  return $this->cool;
}
?>

And in your template, just use the following:
[html]$GetCoolThing

<!-- To access a field on whatever you return (e.g. The time a page was created) -->
$GetCoolThing.Created[/html]

Hope that helps some - if you want to know anything else, take a look at the tutorials, they should help you get started.

Avatar
eKstreme

2 Posts

18 September 2007 at 8:41pm

Thanks for that Matt. I'll dig into the tutorials.

Pierre