How do I get the value $Link to work inside a control?
Template Section.ss:
$Link
<ul>
<% control FilterColourList %>
<li><a href="$Link/$ColourName">$ColourName</a></li>
<% end_control %>
</ul>
The first $Link in the template above works fine but when it is inside the control it does not work - it is blank (I assume this is because it is not a field named Link in FilterColourList/FilterColourType.php).
Is there a way to access the field $Link from Section inside the control of FilterColourList?
Just in case - here is the php code aswell:
Section.php
<?php
class Section extends Page {
public static $db = array(
'Tagline' => 'Text'
);
public static $has_many = array(
'Detail' => 'Detail'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextareaField('Tagline'), 'Content');
$fields->removeFieldFromTab('Root.Content.Main', "MenuTitle");
$fields->removeFieldFromTab('Root.Content.Main', "Content");
return $fields;
}
}
class Section_Controller extends Page_Controller {
function FilterColourList() {
$dataObj = 'FilterColourType';
$filter = '';
$sort = 'ColourName ASC';
$join = '';
$limit = '';
$ColourList = DataObject::get($dataObj, $filter, $sort, $join, $limit);
return ($ColourList) ? $ColourList : false;
}
}
?>
FilterColourType.php:
<?php
class FilterColourType extends DataObject {
static $db = array(
'ColourName' => 'Text'
);
public static $belongs_many_many = array(
'Detail' => 'Detail'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'ColourName', 'Colour' ) );
return $fields;
}
}
?>