Silverstripe Tips

Posted by on 12 December 2011

I have been working with SilverStripe lately and thought I would add some tips for a few various things as documentation is pretty hard to find what you are looking for.

1. Page comments moderation

By default moderation for page comments is turned off. To turn it back on again so all comments require admin approval before being visible, add this code to /mysite/_config.php

PageComment::enableModeration();

2. Page comments members only

If you want to restrict who is able to enter a page comment then you can also add this to /mysite/_config.php. This ensures only logged in users are allowed to leave a page comment.

PageCommentInterface::set_comments_require_login(true);

3. Enable search in Silverstripe

To enable the search engine add the following code to /mysite/_config.php

FulltextSearchable::enable();

You will also need to set up the search box. See http://doc.silverstripe.org/sapphire/en/tutorials/4-site-search for more details.

4. Add styles to Silverstripe WYSIWYG editor in admin area

I really don't like the way that TinyMCE is integrated with Silverstripe at the moment. It is too tightly enmeshed with Silverstripe functionality so leaves little room to modify it. It would be nice to know if the Silverstripe team plan on upgrading to the latest version of tinyMCE.

If you want to add your own formatting and restrict the block level elements add the following code (example only) to /mysite/_config.php.

HtmlEditorConfig::get('cms')->setOption('theme_advanced_blockformats', 'div,p,h1,h2,h3,h4,h5,h6,pre');
HtmlEditorConfig::get('cms')->setOption('theme_advanced_styles','Left=left;Right=right;Link Button=button;Table Emphasis=emphasis;');
HtmlEditorConfig::get('cms')->setOption('theme_advanced_statusbar_location','bottom');

5. Turn off DataObjectManager in Asset Manager

If you have added the DataObjectManager you may have noticed that the Asset Manager has lost some functionality. To revert to the original Asset Manager add the following code to /mysite/_config.php

DataObjectManager::allow_assets_override(false);

 

Like to make an inquiry? Contact Us