17488 Posts in 4473 Topics by 1978 members
| Go to End | Next > | |
| Author | Topic: | 4941 Views |
-
Re: How to create a generic (editable) content block

14 November 2007 at 7:26am
Instead of creating a separate page. Just add the custom fields to the homepage (in a separate tab "student of the month tab"). Then use these fields in your template.
-
Re: How to create a generic (editable) content block

14 November 2007 at 8:03am
Thanks for the reply. I'm new to SS and not great at PHP but can fumble my way through usually. How would I add new tabs? I'm assuming I would do that in Page.php and Page.ss.
-
Re: How to create a generic (editable) content block

14 November 2007 at 9:56am
Add the fields to the homepage class, then stick them in the backend in the function getCMSFields(). Good luck !
Quick copy-paste , so please don't mind any errors :
class HomePage extends Page {
static $db = array(
"sStudentName" => "Text"
);function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.StudentOfTheMonth', new TextField('sStudentName'), 'Content');
return $fields;
} -
Re: How to create a generic (editable) content block

14 November 2007 at 12:26pm
OK. This is working out pretty well. I do have a couple of issues though. I need it to be displayed on everypage but when I have the code you gave me in HomePage.php I have to put the putput in HomePage.ss. That works gret for having it on the home page but how do I get it to output to page.ss?
Also. How do I adjust the text box size for the admin. Is that a CSS thing or is there something else I need to put in the code?
Thanks! I'm on the right track.
-
Re: How to create a generic (editable) content block

14 November 2007 at 1:36pm
You should be able to put $Page(home).SideBarContent into your Page.ss to get the SideBarContent of the home page put onto every page.
-
Re: How to create a generic (editable) content block

14 November 2007 at 1:47pm Last edited: 14 November 2007 1:49pm
OK. I got the larger Text box by using HtmlEditorField rather than TextField. I'm still having issues with outputting it to ever page. Ideally I think having it outpout to an include file would be the best. That's what I really want to do. So I can put a tab on the homepage or create a new page type and go that route. Either way I don't want it only on the Homepage or only on it's own page using a layout template. I trie dputting it in page.php while it works great there it gives me individual content for each page. Which won't work for me.
Basically I need an include file that's editable from the CMS with 3 input fields:
1. Student Name
2. Student Photo (Image field. I got it psuedo working. It uploads but it just won't display the image.
3. Student Bio (HtmlEditorField)Thanks for all the help.
Edit: I just saw your reply Sam. I will try that although I'm not sure where .SideBarContent is coming from.
Brad
-
Re: How to create a generic (editable) content block

14 November 2007 at 3:04pm Last edited: 14 November 2007 3:05pm
SideBarContent was what I thought the name of the field was.
You might want to try this putting this on your Page.ss file - either the layout or the main template, whichever is most logical for where you're positioning the content
<% control Page(home) %>
$Title <br />
$Content <br />
<% end_control %>That piece of code would show the home page's title and content fields on your template, on every page.
The <% control Page(home) %> ... <% end_control %> syntax tells the system "instead of getting this page's content for this part of the template, get the home page's content."
By changing $Title and $Content to the fields that you would like to use, you should be able to achieve the effect you're after.
-
Re: How to create a generic (editable) content block

14 November 2007 at 5:11pm
Brilliant! That did it! Thanks, Sam!
Now all I have to figure out is why the image field isn't working. I'm liking SS a lot so far. Thanks!
| 4941 Views | ||
| Go to Top | Next > |



