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.
- 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.
- In your template folder you have the Page.ss 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.
- So go to themes/yourtheme/templates/Layout and add file by the name of Page Type ‘HomePage.ss’
- I let you to build your themes so I just give you the lines for Description and Photo CMS Fields.
- 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
- 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.