Quote from: BobRay at Aug 07, 2011, 03:12 AM
If all you really want is the ID, though, you can do this:
$children = $modx->getChildIds($modx->resource->get('id'));
That will get you an array containing the child ids.
I think if there is only one, the id will be available this way:
Hi Bob, thanks a lot. We only need the id because of transfering a site by a API-connection to our newsletter-tool what we realize by $urlofthefinishedmailing = $modx->makeUrl($idofthemailinginmodx); and $mailing = file_get_contents($urlofthefinishedmailing) and transferring afterwards the variable $mailing by our API-Connection to the newsletter-tool.
On your site:
http://bobsguides.com/revolution-objects.html you mentioned concerning "Creating New objects" that this "should be done with care". When we create a new mailing from MODx via API-connetion in our newsletter-tool we also have to create a new document in MODx containing the mailing and amongst others the mailing-id of the mailing in our newsletter-tool. For this we were thinking to realize this by this code. Is this OK or are there any pitfalls we are not aware of:
$object = $modx->newObject('modResource');
$object->set('pagetitle', $mailing-name);
$object->set('alias', $mailing-name);
$object->set('template', '51');
$object->set('OurTemplateVariableForTheMailingID', '2982882'); // To set the Mailing-ID 2982882 to our TV
$object->save();
The resource should be in one case a modDocument and in another case a modSymLink. Is it possible to realize this by something like $object->set(’class_key’, ’modDocument’); I couldn´t find anything in the list at the bottom of your page "Understanding MODx Revolution Objects" concerning this point. Or do we have to realize this in another way?
The same question for defining the ’parent’ where the resource should be a child of. Is it possible to add something like this: $object->set(’parent’, ’1299’);
After created this new resource we would get the id of this new resource by this:
$doc = $modx->getObject('modResource', array('pagetitle'=>'thenewgivenpagetitle'));
$idofnewresource = $doc->get('id');
$modx->sendRedirect("https://www.thedomain.com/manager/?a=30&id=".$idofnewresource);
Is this way OK? Or does maybe exist a better one??
Thanks again for your great work concerning MODx
Letti