Jump to:

7938 Posts in 1541 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Staging content showing on published pages

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1108 Views
  • Aaron Brockhurst
    Avatar
    Community Member
    30 Posts

    Staging content showing on published pages Link to this post

    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?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Staging content showing on published pages Link to this post

    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.

  • Aaron Brockhurst
    Avatar
    Community Member
    30 Posts

    Re: Staging content showing on published pages Link to this post

    OK, Cool, that's a good idea

    Thanks

    1108 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.