Developer Challenge
Permalink
Is there any way to get a PageList from only a Collection AttributeKeyCategory object.
What do you mean? Like retrieve all pages that have a certain custom attribute? (and if so, what kind of attribute)?
No I mean, say you have this:
Using only that object, can you generate a PageList object.
I'm looking for a silver bullet so that if I have either an array of AttributeKeyCategories (Collection, User, File), I can cycle through them and get their respective DatabaseItemLists without any extreme logic to figure out which model file to load.
Frankly, I think this is an impossibility. But I'm wondering if anyone has ever tried, or knows of, a way to do this.
$akc = AttributeKeyCategory::getByHandle('collection');
Using only that object, can you generate a PageList object.
I'm looking for a silver bullet so that if I have either an array of AttributeKeyCategories (Collection, User, File), I can cycle through them and get their respective DatabaseItemLists without any extreme logic to figure out which model file to load.
Frankly, I think this is an impossibility. But I'm wondering if anyone has ever tried, or knows of, a way to do this.
something like this?
<?php $akList = AttributeKeyCategory::getList(); foreach($akList as $ak){ switch($ak->akCategoryHandle){ case 'collection': $pList = new PageList(); $pages = $pList->get(); break; case 'file': $fList = new FileList(); $files = $fList->get(); break; case 'user': $uList = new UserList(); $users = $uList->get();
Viewing 15 lines of 19 lines. View entire code block.
Wow... that's actually pretty elegant too!