silverstripe-catalogmanager icon indicating copy to clipboard operation
silverstripe-catalogmanager copied to clipboard

Nested CatalogPages

Open thezenmonkey opened this issue 11 years ago • 6 comments

I have the following two catalog pages

  • Artwork
  • Artist

I'd love to give the client the ability to add/modify Artwork from it's own CatalogPageAdmin or from a Gridfield on Artist. However, when I add CatalogPageGridFieldDetailForm to either a RecordEditor or RelationEditor on Artist it always saves the Artwork to the first Artist and boots me back to teh ArtistAdmin when publishing the Artwork

thezenmonkey avatar Mar 08 '15 03:03 thezenmonkey

Hey @thezenmonkey We've used this for nested catalog pages previously and have had to make some changes to the way which we instantiate the gridfield to allow for the ParentID to be passed through. Do you have an example of this we can use to go through and work out the best way to make this work natively?

stevie-mayhew avatar Mar 12 '15 21:03 stevie-mayhew

I worked through something like this a while back on frankmullenger/silverstripe-gallery It required adding the ParentID to the constructor Pull Request.

I don't know enough about GridField currently, and I swamped trying to get that site to launch.

I can launch without, and circle back after and try and help tackle it.

The basic version of it is: ArtistHolder is the Parent Page for Artist while the Artist Pages are the Parent Pages for Artwork. I have seperate CatalogPageAdmins set up for Artist and Artwork (ArtworkAdmin and ArtistAdmin).

I can post my (ugly) code if it will help.

thezenmonkey avatar Mar 12 '15 22:03 thezenmonkey

Please post your ugly code - we can try get it working.

We've added the ParentID in the model constructor previously by overloading the GridField instantiation like the below:

        $gridField = GridField::create(
            'Artwork',
            'Artwork Page',
            Artwork::get()->filter('ParentID', $this->ID),
            $gridFieldConfig = CatalogDataObjectGridFieldDetailForm::create()
        );

        $gridFieldConfig->setItemRequestClass('CatalogPageGridFieldDetailForm_ItemRequest');

        if ($this->exists()) {
            $model = new Artwork();
            $model->ParentID = $this->ID;
            $gridFieldConfig->setFields($model->getCMSFields());
        }

Then on Artwork's getCMSFields()

        $fields->addFieldsToTab("Root.Main", new HiddenField("ParentID", "ParentID",$this->ParentID), "Content");

stevie-mayhew avatar Mar 12 '15 22:03 stevie-mayhew

@thezenmonkey are you still having issues with this?

stevie-mayhew avatar Sep 23 '15 20:09 stevie-mayhew

Sorry for the silance. I abandonded that implementation and changed the child object t DataObject instead of a Page

thezenmonkey avatar Sep 23 '15 21:09 thezenmonkey

@thezenmonkey thats okay :) I think this is still an issue which needs to be solved so will leave this one open

stevie-mayhew avatar Sep 23 '15 21:09 stevie-mayhew