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.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
- Previous 10 entries
- 1
- Page 22(current)
- 3
- Next 10 entries
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.
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;
}
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.
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.
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
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.
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!
- Previous 10 entries
- 1
- Page 22(current)
- 3
- Next 10 entries