Selecting Child Assets


(Citizen Gold) #1

Hey guys,


The current task I’m working on involves deleteing the content of a Standard Page and replacing it with new content. I’m having a few problems locateing the assets to delete. I know where they are but I need to better target them.



I’ve been using;

    $page_children = &$GLOBALS[‘SQ_SYSTEM’]->am->getChildren($page->id, “bodycopy_div”);
This, however, retrieves all the bodycopy_div assets no matter how deeply nested. e.g. I have a page_standard with Page Contents. As a child asset of this page_standard I have another page_standard. The above code also retreives the bodycopy_div of this page_standard asset. I don’t want to delete this one though.



My question: Is there a way to retreive/identify assets along a specific path?



e.g. I have a page_standard and below that a bodycopy and any number of other assets that may also have bodycopy_div’s. I just want the bodycopy_div’s of the bodycopy directly below the initial(selected) page_standard.

(Avi Miller) #2

This should work:

    $page_children = &$GLOBALS['SQ_SYSTEM']->am->getDependantChildren($page->id, "bodycopy_div");

(Greg Sherwood) #3

A little explanation of this for anyone interested…


Assets can be dependantly linked to each other. This is really just a flag in the DB, and it can only be set within the code itself. It signifies that two assets a related and should be considered as a single unit rather than as completly seperate assets.



A page_standard, bodycopy, bodycopy_div, bodycopy_table and content_type_* are all linked dependantly when they are created.



This is why the system know to change the status of bodycopy, bodycopy_div etc assets linked under standard page when the status of the page is changed - but it does not automatically change the status of sub-pages.


(Citizen Gold) #4

Thanks for that guys.


This is exactly what I needed to know.