Hi,
I'm trying to add dom to siteconfig (ss2.4.7) that holds logo's which have to be visible on every page. All goes well.
I created logo.php, CustomSiteConfig.php and so i can add logo's and their description to the siteconfig. To test, i added 2 of them.
The problem starts when i want to display the logo's in the template
in the include file is
<div id="logos">
<% control SiteConfig.Logos %>
<p>$SiteConfig.description</p>
<% end_control %>
</div>
When i display the page in the browser, i can see in the pagesource that i finds 2 records (2 times p tag). However. It doesn't display the description from the database. Tried to display the logo itself (which is the final goal) using $SiteConfig.LogoImage and $SiteConfig.LogoImage.URL, but no luck.
solution anyone?
This is the code for CustomSiteConfig.php
<?php
class CustomSiteConfig extends DataObjectDecorator {
function extraStatics() {
return array(
'db' => array(
'Headertext' => 'HTMLText'
),
'has_many' => array(
'Logos' => 'Logo'
)
);
}
public function updateCMSFields(FieldSet &$fields) {
$manager = new SiteConfig_DataObjectManager(
$this->owner,
'Logos',
'Logo',
array('LogoImage' => 'logo',
'description' => 'Omschrijving'
),
'getCMSFields_forPopup'
);
$manager->setParentClass("SiteConfig");
$manager->setSourceID($this->owner->ID);
$fields->addFieldToTab("Root.logos", $manager);
}
}
class SiteConfig_DataObjectManager extends DataObjectManager {
function setSourceID($val) {
if (is_numeric($val)) {
$this->sourceID = $val;
}
}
function sourceID() {
if (isset($this->sourceID) && $this->sourceID !== null && is_numeric($this->sourceID)) {
return $this->sourceID;
}
return parent::sourceID();
}
}
this is Logo.php
<?php
class Logo extends DataObject
{
static $db = array (
'description' => 'Text'
);
static $has_one = array (
'SiteConfig' => 'SiteConfig',
'LogoImage' => 'Image'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('description'),
new FileIFrameField('LogoImage')
);
}
}
?>