How to filterByAttribute?
Permalink
I'm overriding the 'search' block and want to filter by custom page attributes, e.g. attribute handle = 'continent' and the attribute value = 'Europe', attribute type is 'select', so (for testing purposes I put explicit values, rather than those from a form) my code is
but I get this error
What does this mean? Thank you.
$ipl->filterByAttribute('continent', '%Europe%', 'like');
but I get this error
An unexpected error occurred. mysql error: [1054: Unknown column 'cIndexScore' in 'order 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 cvIsApproved = '1' and (p1.cIsTemplate = 0 or p2.cIsTemplate = 0) and (((select count(cID) from PagePermissions pp1 where pp1.cID = if(p2.cID is null, p1.cInheritPermissionsFromCID, p2.cInheritPermissionsFromCID) and pp1.cgPermissions like 'r%' and (pp1.gID in (1) or pp1.uID = -1))) > 0 or (p1.cPointerExternalLink !='' AND p1.cPointerExternalLink IS NOT NULL)) and ak_continent like '%Europe%' and (p1.cID not in (5,6,7,8,10,11,12,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,46,47,48,49,50,51,52,53,54,55) or p2.cID not in (5,6,7,8,10,11,12,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,46,47,48,49,50,51,52,53,54,55)) order by cIndexScore desc, cDatePublic desc limit 0,20 ")
What does this mean? Thank you.
Now I've tried this:
and I have this error: "Fatal error: Class 'IndexedSearchResult' not found in /srv/www/htdocs/c5/blocks/search/controller.php on line 153"
function do_search() { $q = $_REQUEST['query']; $length = $_REQUEST['length']; $continent = $_REQUEST['continent']; $adventure = $_REQUEST['adventure']; $interest = $_REQUEST['interest']; $attributeKeyHandle = 'continent'; //Loader::library('database_indexed_search'); //$ipl = new IndexedPageList(); //$ipl->filterByKeywords($q); Loader::model('page_list'); $ipl = new PageList(); $ipl->filterByAttribute($attributeKeyHandle, '%' . $continent . '%', 'like'); if( is_array($_REQUEST['search_paths']) ){ foreach($_REQUEST['search_paths'] as $path) {
Viewing 15 lines of 28 lines. View entire code block.
and I have this error: "Fatal error: Class 'IndexedSearchResult' not found in /srv/www/htdocs/c5/blocks/search/controller.php on line 153"
Thank you.