If I have 2 parents.. "Active" site.com/active and "Inactive" site.com/inactive.. would it be possible to move a page from site.com/active/childpage02 to site.com/inactive/childpage02 if childpage02 has a TV Dropdown menu with 2 options Active and Inactive?
I want the page to move to another parent depending on the TV option if thats possible
If not a TV is there another way to do this?
I don’t think a TV alone will do it. You’d need a plugin connected to OnBeforeDocFormSave that reads the TV and sets the parent.
This should get you started:
http://modxcms.com/forums/index.php?topic=27829.0
I’m not positive, but I think you’ll want to change $_POST[’parent’] on the basis of the TV. This will happen just before the doc is saved so the parent should get set the way you want it.
I mean that in the plugin code, you’d have something like this (assuming your two parents have IDs 3 and 7):
<?php
$tv = $_POST['YourTvName'];
If $tv == 'active' {
$_POST['parent'] = 3;
} else {
$_POST['parent'] = 7;
}
Where YourTvName is the name of your TV.
?>
so far I know, this does not work, because $_POST is stored in vars before OnBeforeDocFormSave and is no more called after that.
what you can try instaed is change the parent after saving in OnDocFormSave with:
<?php
$parent=$_POST['tvYourTvName']=='active'?'3':'7';
if ($parent !==$_POST['parent']){
$modx->db->update(array('parent'=>$parent),$modx->getFullTablename('site_content'),'id='.$_POST['id']);
}
?>
[Edit]
Its better to use $params[’id’] than $_POST[’id’], because on new documents there is no $_POST[’id’]
Thanks for correcting that. I hadn’t tested it.
I think you need a tv prefix on ’status’ so it should be