Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Custom data object with custom 'Published' field

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: 571 Views
  • kharmer
    Avatar
    Community Member
    8 Posts

    Custom data object with custom 'Published' field Link to this post

    Hi all,

    I have a problem with a custom dataobject called articles in my clients project.

    They want the ability to start writing an article belonging to my custom dataobject but not show it on the front end until they flag it as Published. I have created a custom field in the popup called Published and all is working great accept...

    I need to use the Odd and Even page controls to close rows off in the template. However as the items flagged as Unpublished are still counted towards the number of items (I'm using 'if Publsihed' in my template to show/hide).

    So, how would I go about removing items in my custom dataobject based on a custom field within it? I'm not too sure if it should be done from the custom dataobject file or the page type that is using it and I'm also not quite sure how it should be done, if it is possible!

    Any pointers would be great.

    Best regards,
    K...

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Custom data object with custom 'Published' field Link to this post

    How have you got your list of objects? You can simply filter that list by published flag.

    return Articles::get()->filter(array("Published" => 1));

    http://doc.silverstripe.org/framework/en/topics/datamodel

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