Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Issues with static footer and editable content


Reply


3 Posts   982 Views

Avatar
Mrfixer

Community Member, 49 Posts

7 May 2011 at 5:58am

Edited: 07/05/2011 6:00am

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!

Avatar
duskydesigns

Community Member, 15 Posts

7 May 2011 at 11:30am

Try to change this
<% control Images%>

to

<% control Images %>

had that a while ago as well, can be annoying. hope thats the issue

Avatar
Mrfixer

Community Member, 49 Posts

7 May 2011 at 5:54pm

you my friend are an absolute hero, a silly noob error like that corrected as you kindly pointed out and now all is well, as for me well i have learnt a lesson on this one and that is not to edit files directly on my server using notepad, next time connecting notepad++ so i can have a little bit of syntax highling..

kind regards
Martin