how to use getresources to retrieve content of articles in modx
Articles are basically Resources, so you do it the same way you would normally use getResources.
http://rtfm.modx.com/extras/revo/getresources
-
☆ A M B ☆
- 24,524 Posts
One gotcha - individual Articles are automatically set to "not show in menu", so you have to add the showHidden property to your getResources (or pdoResources) snippet.
You know what would be nice? If these listing snippets had more than just binary showUnpublished, showHidden, etc properties. There have been any number of times when it would be useful to have these work three ways, show only published/visible items, show only unpublished/invisible items or show all items.
You could do that with getResources' &where property. You might be able to put the various 'where' JSON strings in aptly named chunks or TVs for future use (and those could be called cached, since they would never change). I think using chunks would be faster and easier.
I believe that if the &where property is present, the unpublished and hidden resources are no longer excluded by default. I could be wrong.
[ed. note: BobRay last edited this post 12 years, 9 months ago.]
-
☆ A M B ☆
- 24,524 Posts
Oh, yes, there's always a dozen different ways to do just about anything you might want to do in MODx, but it would just be convenient (as well as more logical) to have the showHidden and showUnpublished properties handle all three options - 0 for hide them, 1 for show only them, and 2 for show all.
I ran into this problem today and thought to myself (after trying all the basic of the basics): surely there are more ways to skin an ant.
I was working on a user page (with
Articles extra) that was to show in one section "My Published Articles", and in the other "My Drafts."
I looked high and low for something like &showPublished=`0/1`, I even dreamt that getResources had some Easter egg I might be the only one finding.
I ended up with
[[!getResources? &where=`{"createdby:=":[[!+modx.user.id]], "published:=":0}` &showUnpublished=`1` &showHidden=`1`]]
Any one missing parameter ruins the lot.
[ed. note: donshakespeare last edited this post 12 years, 9 months ago.]
TinymceWrapper: Complete back/frontend content solution.
Harden your MODX site by
passwording your three main folders:
core, manager, connectors and renaming your
assets (thank me later!)
5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
Hi,
Does Articles require getResources xtra? I prefer using pdoTools, but articles pages seems to get broken without getResources extra? I don't have any getResources call in Articles resources, templates, chunks etc?
articles uses getResources internally.
Many of us don't use articles anymore.
We use collections to organize articles and stuff like that.
That's much more flexible and you can use any listing-snippets, any commenting-extra ,any tagging-system and so on.
Ok. I'll go that way too.
Thanks.
pdoResources should work fine with Articles. There are a few subtle differences in the arguments that require adjustment if you're converting a getResources tag, though, especially when it comes to TVs. My guess is that was your problem.