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.


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

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

Using PHP in templates




30 March 2008 at 4:28am (Last edited: 30 March 2008 4:32am), Community Member, 1 Post

Hi there,

First of all, I want to say want a great CMS SS is. In particular, the interface for the backend of the CMS is miles ahead from 99% of what's out there at the moment, and is something I feel confident clients would be able to use with very little help.

Secondly, I have to admit that I'm not a hardcore developer by any means, although I know enough to be able to customize most CMSs to my needs. SS has been tricky in that respect - I know the code is very well structured, but the lack of tutorial-type backend documentation makes it a bit tricky for someone like me who is more designer than developer.

Something I've been struggling with is not being able to use PHP in my templates. I know that there's a real need to seperate content from presentation (as discussed here ) but I can't help feel that occasionally logic and presentation are so closely intertwined that a little logic in a tempate file is a good thing. But I may be wrong!

One exaple is something I'm working on now, where I have a list of child pages that I want to span over several columns in a menu in the front end (see screenshot). The normal way I'd do this is using PHP to count the child pages as they're iterated, and insert something like </ul><ul> every fifth child to break the list into columns.

This is very simple in PHP, but seems a lot more complicated in SilverStripe - I'm not even sure where to start!

WHat do you guys think?