Hey all,
Struggling a little here. I think I've located the right functions though. This is the code I'm currently working with.
foreach ($page_children as $asset_id => $asset_type) {
echo "Fetch link for $asset_id";
if ($this_link = &$GLOBALS['SQ_SYSTEM']->am->getLinkByID($asset_id)) {
echo "Got link!. This would be deleted.";
print_r($this_link);
echo "";
echo "Delete $asset_id";
//$GLOBALS['SQ_SYSTEM']->am->deleteAssetLink($this_link["linkid"]);
echo "Done $asset_id";
} else {
echo "bugger<pre>";
print_r($this_link);
echo "</pre>";
trigger_error("bugger", E_USER_ERROR);
}
}</pre><br />
This is the structure I'm working on;
[img]http://www.babel.com.au/gold/d.php/msm_sample1.png[/img]
What I'm trying to do is delete "anything" and "Content DIV". I'm able to narrow it down to just these assets fine. I have the following being used for the loop in the above code snippet.
Array
(
[905] => bodycopy_div
[881] => bodycopy_div
)
The first time I ran the code I got no feedback when 905 was worked on and an error (I missed it, sorry) on 881. I assumed the lack of feedback meant no error occured. I was expecting 905 ("anything") to have disappeared from the asset manager. However, the above image is the current state (after reloading the AM.
Now when I run the same code I get the following;
The destination assetid (page_standard) that was selected is: 879
WORKING: page_standard
The destination asset is a page_standard. We need to delete the content and insert the new content.
AssetManager :
children:
Array
(
[905] => bodycopy_div
[881] => bodycopy_div
)
Fetch link for 905
bugger
MySource Error
File: [SYSTEM_ROOT]/packages/babelext/system/doc_importer/doc_importer_edit_fns.inc Line: 234
Message: bugger
Backtrace: Show</pre><br />
This suggests that the link no longer exists. If that's the case why is the asset still appearing in the Asset Manager?
Or have I approached this all wrong?