filterByCollectionAttribute in the Collection object is not working??
Permalink
I have created a custom attribute called PageGroup and i am trying to get a list of pages that has this attribute set to 'main':
Loader::model('page_list');
$pl = new PageList(); $pl->filterByCollectionAttribute('LanguageGroup', 'main', '=');
$pages = $pl->get(100, 0);
But i get the following MySql error:
mysql error: [1054: Unknown column 'ak_collection_attribute' in 'where clause'] ...
If you look at the MySql statement Generated, i notice that its trying to compare a column name call ak_collection_attribute while in fact it should look at ak_LanguageGroup.
Is this a knowned issue?
Thank you,
Frank
Loader::model('page_list');
$pl = new PageList(); $pl->filterByCollectionAttribute('LanguageGroup', 'main', '=');
$pages = $pl->get(100, 0);
But i get the following MySql error:
mysql error: [1054: Unknown column 'ak_collection_attribute' in 'where clause'] ...
If you look at the MySql statement Generated, i notice that its trying to compare a column name call ak_collection_attribute while in fact it should look at ak_LanguageGroup.
Is this a knowned issue?
Thank you,
Frank
I looked in the CollectionSearchIndexAttributes table and the column name is really ak_LanguageGroup
So was i right to pass 'LanguageGroup' as the first parameter?
So was i right to pass 'LanguageGroup' as the first parameter?
I'm having a similar issue. Am I doing something wrong? I have a custom attribute with handle ViewQuality and one value is Oceanfront. I want to display a list with only pages with Oceanfront views. I tried
and got the following mysql errror - I never see the value I'm filtering on: 'Oceanfront' anywhere in the query
Thanks!
Loader::model('page_list'); $pl = new PageList(); $pl->filterByParentID($parentID); $pl->setItemsPerPage(25); $pl->filterByPageAttribute('ViewQuality','Oceanfront','='); $pages = $pl->getPage(); foreach($pages as $p) { ?> <a href="<?=Loader::helper('navigation')->getLinkToCollection($p)?>"> <?=$p->getCollectionName()?></a><br/> <? } ?>
and got the following mysql errror - I never see the value I'm filtering on: 'Oceanfront' anywhere in the query
mysql error: [1054: Unknown column 'ak_page_attribute' in 'where clause'] in EXECUTE("select p1.cID, pt.ctHandle from Pages p1 left join Pages p2 on (p1.cPointerID = p2.cID) left join PageTypes pt on (pt.ctID = (if (p2.cID is null, p1.ctID, p2.cID))) left join PagePaths on (PagePaths.cID = p1.cID and PagePaths.ppIsCanonical = 1) left join PageSearchIndex psi on (psi.cID = if(p2.cID is null, p1.cID, p2.cID)) inner join CollectionVersions cv on (cv.cID = if(p2.cID is null, p1.cID, p2.cID) and cvID = (select max(cvID) from CollectionVersions where cID = cv.cID)) inner join Collections c on (c.cID = if(p2.cID is null, p1.cID, p2.cID)) left join CollectionSearchIndexAttributes on (CollectionSearchIndexAttributes.cID = if (p2.cID is null, p1.cID, p2.cID)) where 1=1 and p1.cParentID = '97' and cvIsApproved = '1' and (p1.cIsTemplate = 0 or p2.cIsTemplate = 0) and ak_page_attribute = 'ViewQuality' limit 0,25 ")
Thanks!
i think the handle must be lowercased. i'm not 100% sure, but i think i stumbled about this some time ago.
I've had this issue as well. It seems to work properly if you set your attribute handles like so. this_is_my_handle. No spaces no uppercases.
That was it. thanks_so_much!
So i guess its just like when you give a name to your custom blocks, you can't put uppercase letters.
Thanks guys!
Thanks guys!
I know its been a while but i wanted to get rid of my hack and use this in another project and it still does'nt work if you put lowecase attribute name...
Doublecheck the naming there. Make sure you're referencing the handle and not the name of the attribute. I could be wrong, but it seems that your code can't find the attribute handle so it's defaulting to the database column name 'ak_collection_name'.
Relevant API Information: