3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 462 Views |
-
access the variables from a parent out of an <% control ?

29 July 2011 at 7:16am Last edited: 29 July 2011 7:18am
Hey @ all,
If got a problem.
i build this page
Reference.ss
<% control Screens %>
<div class="refimg">
<a href="$Screen.url" rel="lightbox-$Title" title="$Description">$Screen.setWidth(430)</a>
</div>
<% end_control %>
<div class="clear"></div>Reference.php
<?php
class ReferencePage extends Page {
static $allowed_children = 'none';
static $default_parrent = 'referenzen';
static $can_be_root = false;public static $db = array(
'Date' => 'Date',
'Category' => 'Text',
'Site' => 'Text'
);public static $has_one = array(
'Client' => 'ClientObject',
'Preview' => 'Image'
);
public static $has_many = array(
'Screens' => 'ScreenObject'
);function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', $date = new DateField('Date', 'Release Date'), 'Content');
$date->setConfig('showcalendar', true);
$fields->addFieldToTab('Root.Content.Main', new TextField('Category','Web/Print/Hosting etc.'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Site','Link zur Online Referenz (Website wenn online)'), 'Content');
$clients = DataObject::get('ClientObject')->toDropDownMap('ID', 'Name');
$fields->addFieldToTab('Root.Content.Main', new DropdownField('ClientID', 'Client', $clients, $this), 'Content');
$fields->addFieldToTab('Root.Content.Screens', new ImageDataObjectManager($this, 'Screens', 'ScreenObject', 'Screen', array('Description' => 'Beschreibung'), 'getCMSFields_forPopup'));
$fields->addFieldToTab("Root.Content.Preview", new ImageField('Preview', 'Preview Image 276px x 140px'));
return $fields;
}}
class ReferencePage_Controller extends Page_Controller {}
?>
and
ScreenObject
<?php
class ScreenObject extends DataObject {public static $db = array(
'Description' => 'Text'
);public static $has_one = array(
'Screen' => 'Image',
'ReferencePage' => 'ReferencePage'
);public function getCMSFields_forPopup() {
return new FieldSet(
new TextField('Description', 'Beschreibung'),
new ImageField('Screen', 'Screenshot')
);}
}?>
I'm trying to get the page title of my ReferencePage
(<a href="$Screen.url" rel="lightbox-$Title" title="$Description">$Screen.setWidth(430)</a>)But i just get the image title.
if i try it like this
<% control Screens %>
<div class="refimg">
<a href="$Screen.url" rel="lightbox-<% control Parent %>$Title<% end_control %>" title="$Description">$Screen.setWidth(430)</a>
</div>
<% end_control %>
<div class="clear"></div>it also didn't work :/
any solutions?
Thanks Benni
-
Re: access the variables from a parent out of an <% control ?

29 July 2011 at 7:36am
You can use $Parent.Title or $Top.Title to temporally escape out of the control.
http://doc.silverstripe.org/sapphire/en/reference/built-in-page-controls#top -
Re: access the variables from a parent out of an <% control ?

29 July 2011 at 8:05am
Thx, $Top.Title works
$Parent.Title didn't
| 462 Views | ||
|
Page:
1
|
Go to Top |


