Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

get_themes()

Description

Get collections linked to featured collcetion categories

Parameters

ColumnTypeDefaultDescription
$themes array array"" Array of featured collection categories
$subthemes boolean false Include subthemes

Return

array Array of colllection results

Location

include/collections_functions.php lines 1221 to 1269

Definition

 
function get_themes($themes=array(""),$subthemes=false)
    {    
    
$themes_order_by=getvalescaped("themes_order_by",getvalescaped("saved_themes_order_by","name"));
    
$sort=getvalescaped("sort",getvalescaped("saved_themes_sort","ASC"));    
    global 
$themes_column_sorting,$themes_with_resources_only,$descthemesorder;
    if (!
$themes_column_sorting && !$descthemesorder)
        {
        
$themes_order_by="name";
        
$sort="ASC";
        } 
// necessary to avoid using a cookie that can't be changed if this is turned off.
    
$sort = ($descthemesorder)? "DESC" $sort;
    
# Return a list of themes under a given header (theme category).
    
$sql="select *,(select count(*) from collection_resource cr where cr.collection=c.ref) c from collection c  where c.theme='" escape_check($themes[0]) . "' ";
    
    for (
$x=1;$x<count($themes)+1;$x++){
        if (isset(
$themes[$x])&&$themes[$x]!=""){
            
$sql.=" and theme".($x+1)."='" escape_check($themes[$x]) . "' ";
        }
        else {
            global 
$theme_category_levels;
            if ((
$x+1)<=$theme_category_levels && !$subthemes){
            
$sql.=" and (theme".($x+1)."='' or theme".($x+1)." is null) ";
            }
        }
    }

    
$order_sort="";
    if (
$themes_order_by!="name"){$order_sort=" order by $themes_order_by $sort";}
    
$sql.=" and c.public=1    $order_sort;";
    
//echo $sql . "\n";
    
$collections=sql_query($sql);
    if (
$themes_order_by=="name"){
        if (
$sort=="ASC"){usort($collections'collections_comparator');}
        else if (
$sort=="DESC"){usort($collections,'collections_comparator_desc');}
    }
    
    if (
$themes_with_resources_only) {
        
$collections_orig $collections;
        
$collections = array();
        for (
$i=0;$i<count($collections_orig);$i++) {
            
$resources do_search('!collection'.$collections_orig[$i]['ref']);
            if (
count($resources) > 0) {
                
$collections[] = $collections_orig[$i];
            }
        }
    }    

    return 
$collections;
    }

This article was last updated 22nd October 2020 11:35 Europe/London time based on the source file dated 2nd October 2020 15:40 Europe/London time.