Developer Challenge

Permalink
Is there any way to get a PageList from only a Collection AttributeKeyCategory object.

ijessup
 
jordanlev replied on at Permalink Reply
jordanlev
What do you mean? Like retrieve all pages that have a certain custom attribute? (and if so, what kind of attribute)?
ijessup replied on at Permalink Reply
ijessup
No I mean, say you have 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.
jelthure replied on at Permalink Best Answer Reply
jelthure
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();
ijessup replied on at Permalink Reply
ijessup
Wow... that's actually pretty elegant too!