Hi, I have been following an online tut over at ssbits on creating a Static Sidebar (in my case though it needs to be a footer) that can be edited in SS Admin CMS, basically it is to hold images, heres how i have gone about it (its also my first dive into dataobject_manager).
firstly created StaticFooter.php
<?php
class StaticFooter extends Page
{
static $has_many = array (
'Images' => 'ImageFooter'
);
public static $db = array(
);
public static $has_one = array(
);
public function getCMSFields()
{
$fields = parent::getCMSFields();
$managerfooter = new ImageDataObjectManager(
$this, // Controller
'Images', // Source name
'ImageFooter', // Source class
'Attachment', // Name on DataObject
array(
'Title' => 'Title',
'Caption' => 'Caption'
),
'getCMSFields_forPopup'
);
$fields->addFieldToTab("Root.Content.FooterGallery",$managerfooter);
return $fields;
}
static $allowed_children = array("none");
}
class StaticFooter_Controller extends Page_Controller {
}
now my class:
<?php
class ImageFooter extends DataObject
{
static $db = array (
'Title' => 'Text',
'Caption' => 'Text'
);
static $has_one = array (
'Attachment' => 'Image',
'StaticFooter' => 'StaticFooter'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Title'),
new TextareaField('Caption'),
new FileIFrameField('Attachment')
);
}
}
footer.ss
<div class="clear"></div><!-- / clear -->
</div><!-- / content -->
<div id="footer">
$Footerhp
<div style="margin:0px 0px 0px 35px; text-align:center;">
<% include StaticFooter %>
<div class="clear"></div>
</div>
</div><!-- / footer -->
</div><!-- / wrapper -->
</body>
</html>
and now finally StaticFooter.ss
<% control GetStaticFooter %>
<% control Images%>
<div class="fimages" style="float:left; margin-left:10px;">
<p style="color:#ffffff; font-size:0.7em"><strong>$Title</strong></p>
$Caption
$Attachment.SetRatioSize(133, 100)
</div>
<% end_control %>
<% end_control %>
Mostly all is working good, fields are there in Admin CMS etc, i can create the footer and add the images, no problem, however when im rendering the page to view im getting this error Parse error: syntax error, unexpected '}' in /home/wwwkevin/public_html/silverstripe-cache/.cache.themes.flyscreens.templates.GalleryPage.ss on line 246
try as i might i cant pin it down (now 6 hours and i've gone bald, aged rapidly and nearly done a packet of cigarettes,not foaming at the mouth yet so theres still hope.)
im thinking the fault is in StaticFooter.ss or footer.ss as when i dont include footer.ss i dont get the error, is anybody out there with an experienced eye who wouldnt mind casting it over the code and point me in the right direction?
regards
Martin
edit: am i supposed to be able to delete my own posts?... i just went to edit this post (in its former state, and hit delete by mistake. oops!