21281 Posts in 5729 Topics by 2600 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 833 Views |
-
Adding NumericField()

12 March 2010 at 6:29pm
Relatively new to Silverstripe, and loving it. Starting to try to add some more functional pages. And not much experience in php.
I'm making a site for a local football team. I have everything showing up in cms and on the web page. So I know my numbers are good from the CMS to the db to the web page.
I want to be able to add the scores for the quarters.
Here is how I have it set up in php page.
'Quarter01visitor' => 'Int',
.....
.....$fields->addFieldToTab("Root.Content.Box", new NumericField("Quarter01visitor", "1st Quarter - Visiting Team"));
.....
.....How can I add up my Quarter01visitor, Quarter02visitor...etc... into a new variable to display on my page?
Am I on the right track?Thanks for any help.
-
Re: Adding NumericField()

14 March 2010 at 9:57am
You should just have to use:
$Quarter01visitor
In your template.
Mo
-
Re: Adding NumericField()

14 March 2010 at 10:00am
Oops, just read your post again, sorry. You are probably best off using a custom method in your Page_Controller. Something like:
...
public function getQuarterTotal() {
return ($this-> Quarter01visitor + $this->Quarter02visitor);
}
...Then add:
$QuarterTotal
to your template
Mo
| 833 Views | ||
|
Page:
1
|
Go to Top |


