Hello,
I'd like to get the context-key of a specific resource (or resource container) from within a Custom Manager Page. All I have is the ID of the resource/container document.
The getContext method from the modx.class returns the actual context-key. Inside a CMP this will always return "mgr".
Is there something like "getContextByResourceID"?
Or how can this be done?
--
Greetings,
Martin
discuss.answer
If you have the resource object, it would be:
$resource->get('context_key');
If all you have is the ID, you could do this:
$res = $modx->getObject('modResource', $id);
$ctx = $res->get('context_key');
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
Hi Bob,
as always fast and simple answer! Thank you again!
Looking at your answer this is so easy. As a beginner (with MODx and PHP) it's hard to figure out how to do such things...
Are there good programming tutorials regarding the MODx Revo API and xPDO (best would be step by stept tuts)?
Looking at the core code might help if you are an advanced developer - but without knowing the basics it's hard to read the code. Its even hard to know where to look for!
How did you pros come to such an advanced level?
Greetings,
Martin
-
☆ A M B ☆
- 24,524 Posts
Time. I've just begun to examine Revo a few months ago, and I'm finally beginning to understand the way it works.
You can also examine the class reference and the API reference, although it takes a bit of studying to figure out the API reference material.
http://rtfm.modx.com/display/revolution20/Class+Reference
http://api.modx.com/revolution/2.2/
Bob's guides and tutorials are invaluable! And
his book is said to be great. I don't have that one, but I do have
Shaun Wlkerson's book, and am quite pleased with it. Shaun also has some good articles and tutorials on his site.
[ed. note: sottwell last edited this post 14 years ago.]
Hi Susan,
thanks for your hints! I already know the class reference and the api doc. What I miss in the docs are examples, use cases and more detailed descriptions.
By the way - is it only me or causes the usage of the search input in the api documentation a complete browser freeze?
Greetings,
Martin
I don't know. I always look in the MODX code rather than searching the API. My editor (PhpStorm) has a nice regular-expression, multi-file search function and will also jump to a method declaration anywhere in MODX if I right-click on a call.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
-
☆ A M B ☆
- 24,524 Posts
I bought myself a copy of that when they had it half-price, now I just need to get myself motivated to learn how to use it!
I got one then too. I think you'll like it. I made a complete MODX install into a PhpStorm project and put my own projects in the assets directory. Just do File -> New Project, and select the MODX root directory.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html