Show Child pages in a Silverstripe template

David Nash silverstripe, What I'm Working On Today Leave a Comment

This allows you to create infinitely deep Silverstripe page hierarchies without having to mess around too much with navigation. Simple and effective. <% include Nav %> <div id=”Content”> <h1>$Title</h1> $Content $Form <% if Children %> <ul style=”padding-top: 1em”> <% control Children %> <li><a href=$Link>$MenuTitle </a></li> <% end_control %> </ul> <% end_if %> </div><!–Content–>

HTML syntax highlighting for Silverstripe .ss template files in vim

David Nash silverstripe, vim, xhtml 3 Comments

By default vim opens .ss files with some other file format syntax highlighting. To enable HTML (actually XHTML) syntax highlighting on your .SS Silverstripe template files, create (or edit) your ~/.vim/filetype.vim file. Then enter this: au BufNewFile,BufRead *.ss      setf xhtml Then open a .ss file and it’ll give you nice HTML syntax highlighting. And because it’s in your home directory, it’ll keep working even after you upgrade vim.

Remove empty LEGEND tags in Silverstripe search form

David Nash silverstripe, xhtml 3 Comments

I’m pretty obsessive about my HTML validating with no errors and no warnings. It bugs me that when I use Silverstripe’s incredibly convenient $Searchform in the template that it outputs an empty legend tag inside the fieldset. There’s an easy way to fix this: Create a templates directory inside mysite. Copy sapphire/templates/ to mysite/templates/ Edit your copy of the file and remove that pesky <legend></legend> line Refresh your page that uses the searchform and bathe in the warm glow of a error and warning free page! Thanks to Maksfeltrin in the Silverstripe forums for pointing this out.

Dynamic Font/Image Replacement in Silverstripe

David Nash silverstripe, What I'm Working On Today 15 Comments

I’ve recently started creating sites with SilverStripe CMS, and I’m loving it. My client wants nicely rendered non-standard font titles that fade in and out, without using javascript. Here’s how I’m going to accomplish it: In Silverstripe’s mysite/code/Page.php I overload the onBeforeWrite() call in my Page class. This intercepts the data before it is written to the database. I can get the title of the updated page from $this->Title I will then use PHP’s GD (graphics) library to create a PNG with a transparent background. I’ll use imagettftext() to load a font from a TTF file and write it to …