Jump to:

1851 Posts in 1606 Topics by 561 members

Blog Module

SilverStripe Forums » Blog Module » show BlogHolder content on HomePage

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 227 Views
  • shellsuper
    Avatar
    Community Member
    1 Post

    show BlogHolder content on HomePage Link to this post

    Hi there,

    I just learn a bit about SS 3.1 and blog module. I have 2 questions at the moment:
    1. I am developing some kind of online learning website which provides several courses (e.g. math, chemistry, etc). Therefore, I made each course to have its own blog module. At this moment I want to add one image as a banner for each course and it is embedded in blogHolder. I added the code on the blog/code/BolgHolder.php like this:

    class BlogHolder extends BlogTree implements PermissionProvider {
    .....
       static $has_one = array(
          'Owner' => 'Member',
          'Photo' => 'Image',
       );

    .....
       function getCMSFields() {
          $blogOwners = $this->blogOwners();

          SiteTree::disableCMSFieldsExtensions();
          $fields = parent::getCMSFields();
          SiteTree::enableCMSFieldsExtensions();
          
          //sets the ID and Name Map for Blog Ownership
          $owners = new DropdownField('OwnerID', 'Blog owner', $blogOwners->map('ID', 'Name')->toArray());
          $owners->setEmptyString('(None)');
          $owners->setHasEmptyDefault(true);

          $fields->addFieldToTab('Root.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'), "Content");
          $fields->addFieldToTab('Root.Main', $owners, "Content");
          $fields->addFieldToTab('Root.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'), "Content");
          $fields->addFieldToTab("Root.Main", new CheckboxField("ShowFullEntry", "Show Full Entry"), "Content");
          $fields->addFieldToTab("Root.Images", new UploadField('Photo'));

          $this->extend('updateCMSFields', $fields);

          return $fields;
       }
    .....

    Although it works like the way I want it, is it the right way to do it? I hacked in into the code instead of creating a new Holder page.

    2. How do I get the content & image from the BlogHolder (not the BlogEntry) so it can be shown on the HomePage?

    Thank you

    227 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.