Why does $modx->documentObject[’id’] does not work in a plugin?
I am trying to get the current document id (or pagetitle) but
it does not give me a result.
Edit: Tried $modx->documentIdentifier and I dont get a result either...
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
Try using:
$pageId = $_REQUEST['pid'];
for the current page ID and
$pageInfo = $modx->getPageInfo();
For the document info.
http://wiki.modxcms.com/index.php/API:getPageInfo
@Bob - I get the following error with your solution for id. Undefined index: pid
and getPageInfo needs the page id, which is what I am after...
@mrhaw - even though I am using it outside the switch in the plugin, it did not work referenced...
really frustrating!
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
I think you’ll have to track down where in the code your plugin event is called and see what variables are accessible at that time the event is triggered.
Which event(s) are you using to trigger your code?
OnBeforeDocFormSave
I am trying to read and modify TVs between {creating or editing a document}
and saving it...
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
In that case, you should be able to use
$id to access the document id.
refer to save_content.processor.php:
line 283 (for a newly created document)
line 476 (for an edited document)
hope this helps
Odd. I copied that code from existing plugins in Evo. I assume they work.
@breezer -- thanks for the response, it lead me to the answer and also
allowed me to discover the processors and all the goodies that one can
find in there. $id was not the answer but the definition of $id,
which is $_POST[’id’] and it works fine...
@bob -- maybe they defined ’pid’ somewhere else... thanks a lot bob for
your constant help in the forums, appreciate it a lot...
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner