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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Staging content showing on published pages


Reply


3 Posts   1198 Views

Avatar
Aaron Brockhurst

Community Member, 30 Posts

1 October 2009 at 3:51am

Hi Uncle Cheese

I've found that content in the dataobjectmanager is showing on the published page when the page is in staging. For instance if I create a page and publish it, then make an edit, add some images through DOM and save the images are displayed on the published site.

Is there a way to hide the images?

My code is as follows:

ImageBlock.php

<?php

class ImageBlock extends DataObject {
static $db = array(
   'ImageBlockTitle' => 'Varchar',
   'ImageBlockAltText' => 'Text',
   'ImageBlockText' => 'HTMLText'
);

static $has_one = array(
      //'ImageBlockLinkPage' => 'SiteTree',
       'ImageBlockImage' => 'Image',
      'ContentPage' => 'ContentPage',
      'SectionPage' => 'SectionPage',
      'HomePage' => 'HomePage'
);

   
public function getCMSFields_forPopup()
   {
      return new FieldSet(
         new TextField('ImageBlockTitle','Enter the Title'),
         new FileIFrameField('ImageBlockImage'),
         new TextField('ImageBlockAltText','Enter the ALT (Roll over) text for the image')//,
         //new TextField('ImageBlockText','Enter the link text'),
         //new SimpleTreeDropdownField("ImageBlockLinkPageID", "Select the page to link", "SiteTree")
      );
   }

   
}

?>

DOM code in Page.php

public static $has_many = array(
    'PageImages' => 'ImageBlock',
   );

function getCMSFields() {
      $fields = parent::getCMSFields();
   //Image Block
      $ImageBlockmanager = new FileDataObjectManager(
         $this, // Controller
         'PageImages', // Source name
         'ImageBlock', // Source class
         'ImageBlockImage', // File name on DataObject
         array(
            'ImageBlockTitle' => 'ImageBlockTitle',
            'ImageBlockAltText' => 'ImageBlockAltText',
            //'ImageBlockText' => 'ImageBlockText'
            //'ImageBlockLinkPage' => 'ImageBlockLinkPage'
         ), // Headings
         'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
         // Filter clause
         // Sort clause
         // Join clause
      );
      
      
      // If undefined, all types are allowed. Pass with or without a leading "."      
      $ImageBlockmanager->setAllowedFileTypes(array('jpg','gif'));
      
      // Label for the upload button in the popup
      $ImageBlockmanager->setBrowseButtonText("Upload image (jpg or gif only)");
      
      // In grid view, what field will appear underneath the icon. If left out, it defaults to the file title.
      $ImageBlockmanager->setGridLabelField('ImageBlockTitle');
      
      // Plural form of the objects being managed. Used on the "Add" button.
      // If left out, this defaults to [MyObjectName]s
      $ImageBlockmanager->setPluralTitle('Page Images');
   return $fields;
   
   }

Any suggestions?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

1 October 2009 at 4:13am

Yeah, dataobjects don't have a live/published state AFAIK. If the client really wants it, usually i just add a "published" checkbox to my dataobject components.

Avatar
Aaron Brockhurst

Community Member, 30 Posts

1 October 2009 at 4:15am

OK, Cool, that's a good idea

Thanks