quardas
quardas

Reputation: 691

MODX - how to listing Static Resources of certain document ID?

I'm playing with MODx 2.2. Does anyone knows how to easy listing "Static Resourses" from certain document ID? In my system there is a file attachments list below the content of article based on that "Static Resourses"

Upvotes: 0

Views: 534

Answers (2)

Sean Kimball
Sean Kimball

Reputation: 4494

ok- thanks, much clearer now.

So out of the box? 'No'. But you can probably get the job done by writing a little plugin that whips through the resource content looking for the static resources [if you are unfamiliar with plugins, they are just basically snippets that execute on a system event that you define], see here: http://rtfm.modx.com/display/revolution20/Plugins [and at the bottom an incomplete list of events] I'm thinking you have 2 options:

  1. Write a plugin that fires on the OnWebPagePrerender event that basically just whips through the resource content looking for your [[~xxx]] - It should be easy to extract these & pass them to either a custom script or getResources. I would expect some problems with caching here.

  2. If it's actually just a list of static resources, and not scattered through out the resource content: a. place your static resource id's in a template variable [http://rtfm.modx.com/display/revolution20/Template+Variables] & extract them with getResources. b. follow Ben's answer and setup your static resources as children of your document resource.

Upvotes: 1

Ben
Ben

Reputation: 1022

Not 100% sure if this is what you are trying to do. But are you trying to list the child resources of a particular partent resource? For example:

Parent - child - child - child

If so you will need to use the getResource snippet: http://rtfm.modx.com/display/ADDON/getResources

and example call that you would place on the page you want to display the list would be, if the parent's ID=20

[[getResources? &parents=`20`]]

If you wish to use the current page as id to list all child resources change 20 to

[[*id]]

Upvotes: 1

Related Questions