Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested CatalogPages #22

Open
thezenmonkey opened this issue Mar 8, 2015 · 6 comments
Open

Nested CatalogPages #22

thezenmonkey opened this issue Mar 8, 2015 · 6 comments

Comments

@thezenmonkey
Copy link

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

@stevie-mayhew
Copy link
Contributor

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?

@thezenmonkey
Copy link
Author

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.

@stevie-mayhew
Copy link
Contributor

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
Copy link
Contributor

@thezenmonkey are you still having issues with this?

@thezenmonkey
Copy link
Author

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

@stevie-mayhew
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants