Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Multiple custom variables on a template/layout

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

Page: 1
Go to End
Author Topic: 807 Views
  • Fedorawearingpolarbear
    Avatar
    Community Member
    3 Posts

    Multiple custom variables on a template/layout Link to this post

    I'm looking for the best but simplest way to have multiple custom variables on a page layout, the variable output would different depending on the page.

    For example three variables; name, price, sku number. There are three products, each product needs those variables. However each of those variables output would be different depending on the product.

    I've looked into template variables.

    function MyCustomValue() {
    return "Hi, this is my site";
    }

    However it doesn't seem efficient since I would have to create a custom value for each page. A custom field box when creating a page in the admin panel would be prefered; in the product layout where ever $Price is placed it would output the value that was typed in the custom field, I imagine this is difficult to create. I have briefly looked into dataobjects, I can't seem to wrap my head around them. What is the best solution for what I want to do?

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Multiple custom variables on a template/layout Link to this post

    A custom field box when creating a page in the admin panel would be prefered

    Adding fields to pages is easy. Make sure you've read the first 2 tutorials which cover adding fields to pages. If your products are already pages then you don't need DataObjects.

    807 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.