5093 Posts in 1516 Topics by 1113 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1792 Views |
-
Adding custom content to the backend

10 March 2010 at 9:14am
hi there,
I want add custom content on some tabs in the backend. For example this way I can add a new field to a tab:
$fields->addFieldToTab('Root.Content.Main', new HTMLEditorField('Field', 'Field'));
But how can I add own content, for example just a string or the result of a function or a class?
If I want to call a own class there, is it enough to just put my class into /mysite/ direcotry? Will SS loads that automaticly?
thx
danzzz -
Re: Adding custom content to the backend

10 March 2010 at 10:19am Last edited: 10 March 2010 10:20am
Hi Danzzz,
You could try adding a new LiteralField to that tab.
Example:
$fields->addFieldToTab('Root.Content.Main', new LiteralField('','<p>Hello World</p>'),"Content");Check out the documentation too for other available fieldtypes and examples. http://doc.silverstripe.org/doku.php?id=form-field-types
-chango
-
Re: Adding custom content to the backend

10 March 2010 at 4:41pm
If I want to call a own class there, is it enough to just put my class into /mysite/ direcotry? Will SS loads that automaticly?
Yes. SS picks up any files in any folder which has a _config.php file at the second level but will ignore a folder / not include classes if a '_manifest_exclude' file is present.
-
Re: Adding custom content to the backend

12 March 2010 at 1:05am
thx,
willr:
are there other methods to include or load own content to tabs than literalfield?
what I want to do is:
create a new tab.
in this tab I want show extern news articels grabbed from rss feeds.
the user can activate the news items which should shown on the frontpage.thx for your input ...
daniel
-
Re: Adding custom content to the backend

12 March 2010 at 11:19am
Well you can only insert subclasses of form fields in the backend tabs (since it is one big form). You could always make your own form field type which had whatever you wanted. Have alook at how LiteralField does it. The key function is Field() which returns the object to insert. So you could define that function in your own form field to render with a different template or some more hard core things.
-
Re: Adding custom content to the backend

16 December 2010 at 2:59pm
hmmm i've tried this:
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Availability', new LiteralField('','<p>Hello World</p>'),"Content");return $fields;
}and the tab is just blank?
-
Re: Adding custom content to the backend

16 December 2010 at 3:14pm
oooops, ignore that. i was messing around with the " & '!
final code:
$fields->addFieldToTab('Root.Content.Availability', new LiteralField("","<p>Hello World</p>"));
| 1792 Views | ||
|
Page:
1
|
Go to Top |




