Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module

Discuss the Blog Module.

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

show BlogHolder content on HomePage


Reply

287 Views

Avatar
shellsuper

3 June 2014 at 7:28pm Community Member, 1 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