craftsmancoding / repoman

Repoman allows for easy package development in MODX Revolution. Take back the simplicity!
30 stars 7 forks source link

Write Tutorial for Creating/Managing Resources #13

Closed remixlearning closed 9 years ago

remixlearning commented 10 years ago

Is it possible to use repoman to store and update the resources?

IF so how would that be done?

fireproofsocks commented 10 years ago

Yes: that's one of the tutorials I would like to write before releasing this publicly. Resources are difficult because so often you rely on the page IDs -- they are the only object in MODX that use the ids like that (e.g. for links), but the id is only a side-effect of the database where it's installed. So be careful if you have to link between pages.

All Repoman objects other than Elements are stored as Seed Data -- see https://github.com/craftsmancoding/repoman/wiki/Seed-Data

That means that to create an object, you must create a file that returns an array that represents that object. To know which attributes each object might have, there is the "graph" tool, e.g. "php repoman graph modChunk" -- it prints out all available attributes and also all available relations. The relations are usually optional unless you need to have the 2 objects related -- MODX handles the foreign key relations. For example, look at the related objects of modMenu and modAction that are linked when you create a CMP: https://github.com/craftsmancoding/repoman/wiki/Sample-Objects

I'm changing the name of this ticket so it reflects the need for a tutorial here.

remixlearning commented 10 years ago

Cool, thanks, yes I noticed the horrible use of ids to link between resources, also the fact that they are linked to templates.

pk-informatics commented 9 years ago

Hello,

How did you get it working? I cant get it working to create multiple resources => they overwrite each other so i only get one resource I have tried it with id set, emtpy id and without id and even the php and the json way?

fireproofsocks commented 9 years ago

Here's a tutorial: https://github.com/craftsmancoding/repoman/wiki/Tutorial--Resources

pk-informatics commented 9 years ago

Hello,

Thank you for the tutorial :) I have a little improvement for the tutorial: Highlight the Part with build_attributes => "To correctly seed Resources you also have to add "build_attributes": { "modResource": { "preserve_keys": true, "update_object": true, "unique_key": "alias" } } in your composer.json file "

fireproofsocks commented 9 years ago

Good idea. Done.