My class testPage.php looks like this:
<?php
class testPage extends Page {
private static $db = array(
'Location1' => 'Text',
'Location2' => 'Text',
'Location3' => 'Text'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Locations', TextField::create('Location1','Location #1'));
$fields->addFieldToTab('Root.Content.Locations', TextField::create('Location2','Location #2'));
$fields->addFieldToTab('Root.Content.Locations', TextField::create('Location3','Location #3'));
return $fields;
}
}
And my template (testPage.ss) looks like this:
<ul>
<script type="text/javascript">
for ( i=1; i<4; i++ ) {
document.write('<li>$Location [ i ]</li>');
}
</script>
</ul>
I've used the CMS to add values to each location e.g. Location #1 = Ipswich. But the template doesn't return any location values. I expected it to return Ipswich as the first line item for example. But it just returns " [ i ] " as each line item. Obviously I'm doing something simple wrong. Can anyone advise please?