Building a Theme for the Extended ‘Page Type’ in SilverStripe

As we made HomePage.php Page we added two fields to the page type + the one that’s always in pagetype the content. In this tutorial I will tell you how to use them in theme and in next how to remove the content part from the CMS. So for starting lets make the theme file.

  1. Go to your Theme folder what is located in themes/yourtheme/ there most have at least two sub folders css/ for the custom style you using for your themes and the template/ folder for the template files.
  2. In your template folder you have the file what is the file for your main template (with all the normal stuff like head, body, etc) and then you have the ‘Layout’ folder and ‘Include’ folder the HomePage theme file we create in to the Layout folder.
  3. So go to themes/yourtheme/templates/Layout and add file by the name of Page Type ‘’
  4. I let you to build your themes so I just give you the lines for Description and Photo CMS Fields.
  5. For photo you can use lines like:
    $Photo.SetWidth(80) // returns a image 80px wide, ratio kept the same
    $Photo.SetHeight(80) // returns a image 80px tall, ration kept the same
    $Photo.SetSize(80,80) // returns a 80x80px padded image
    $Photo.SetRatioSize(80,80) // **New in 2.4** returns an image scaled proportional, with its greatest diameter scaled to 80px
    $Photo.PaddedImage(80, 80) // Returns an 80x80 image. Unused space is padded white. No crop. No stretching
    $Photo.Width // returns width of image
    $Photo.Height // returns height of image
    $Photo.Orientation // returns Orientation
    $Photo.Filename // returns filename
    $Photo.URL // returns filename address
  6. For Description you can use:
    $Description.FirstParagraph //renders only the first paragraph of description
    $Description.LimitCharacters(10) //Limits this field's Description by a number of 10 characters.
    $Description.FirstSentence //Returns the first sentence from the first paragraph.
    or just $Description //Returns whole text.

Looking for quality SilverStripe Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , | Posted under SilverStripe CMS | RSS 2.0

Author Spotlight

Teet Bergmann

I'm a freelance web designer from Estonia. Mostly doing sites using Silverstripe, magento, prestashop, wordpress.

Leave a Reply

Your email address will not be published. Required fields are marked *