Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

render_featured_collections()

Description

Render featured collections (as tiles on the collections_featured.php page)

Parameters

ColumnTypeDefaultDescription
$ctx array Context data to allow caller code to decide rendering requirements
$items array List of items to render (featured collection category, actual collection or smart collection)

Location

include/render_functions.php lines 4878 to 5083

Definition

 
function render_featured_collections(array $ctx, array $items)
    {
    global 
$baseurl_short$lang$k$themes_simple_images$FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS$themes_simple_view,$show_theme_collection_stats;

    
$is_smart_featured_collection = (isset($ctx["smart"]) ? (bool) $ctx["smart"] : false);
    
$general_url_params = (isset($ctx["general_url_params"]) && is_array($ctx["general_url_params"]) ? $ctx["general_url_params"] : array());
    
$all_fcs = (isset($ctx["all_fcs"]) && is_array($ctx["all_fcs"]) ? $ctx["all_fcs"] : array());

    foreach(
$items as $fc)
        {
        
$render_ctx $ctx;
        
$is_featured_collection_category is_featured_collection_category($fc);
        
$is_featured_collection = (!$is_featured_collection_category && !$is_smart_featured_collection);

        
$tool_edit = array(
            
"href" => generateURL("{$baseurl_short}pages/collection_edit.php",
                array(
                    
"ref" => $fc["ref"],
                    
"redirection_endpoint" => urlencode(
                        
generateURL(
                            
"{$baseurl_short}pages/collections_featured.php",
                            
$general_url_params,
                            array(
"parent" => $fc["parent"])
                        )
                    )
                )
            ),
            
"icon" => 'fa-solid fa-fw fa-pen-to-square',
            
"text" => $lang['action-edit'],
            
"modal_load" => true,
            
"redirect" => true
        
);
        
$tool_select = array(
            
"icon" => 'fa-solid fa-fw fa-circle-check',
            
"text" => $lang['action-select'],
            
'custom_onclick' => sprintf("return ChangeCollection(%s, '');"escape($fc['ref'])),
        );
        
$tool_upload_to_collection = [
            
'href' => $GLOBALS['upload_then_edit']
                ? 
generateURL("{$baseurl_short}pages/upload_batch.php", ['collection_add' => $fc['ref']])
                : 
generateURL(
                    
"{$baseurl_short}pages/edit.php",
                    [
                        
'uploader' => $GLOBALS['upload_then_edit'],
                        
'ref' => -$GLOBALS['userref'],
                        
'collection_add' => $fc['ref']
                    ]
                ),
            
'icon' => 'fa fa-fw fa-upload',
            
'text' => $lang["action-upload-to-collection"],
        ];

        
// Prepare FC images
        
$thumbnail_selection_method $fc["thumbnail_selection_method"];
        
$show_images = ($themes_simple_view && in_array($thumbnail_selection_method$FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS) && $thumbnail_selection_method != $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["no_image"]);
        unset(
$fc_resources);
        if(
$themes_simple_images && $show_images)
            {
            
$fc_resources get_featured_collection_resources(
                
$fc,
                array(
                    
"smart" => $is_smart_featured_collection,
                    
"use_thumbnail_selection_method" => !$is_smart_featured_collection,
                    
"all_fcs" => $all_fcs,
                ));
            
$fc_images generate_featured_collection_image_urls($fc_resources"pre");

            if(!empty(
$fc_images))
                {
                
$render_ctx["images"] = $fc_images;
                }
            }

        
// Featured collection default tools
        
if ($is_featured_collection && checkPermission_dashmanage()) {
            
$render_ctx["tools"][] = array(
                
"href" => generateURL(
                    
"{$baseurl_short}pages/dash_tile.php",
                    array(
                        
'create'            => 'true',
                        
'tltype'            => 'srch',
                        
'title'             => "{$fc['name']}",
                        
'freetext'          => 'true',
                        
'tile_audience'     => 'false',
                        
'all_users'         => 1,
                        
'promoted_resource' => (isset($render_ctx["images"]) ? 'true' ""),
                        
'link'              => "{$baseurl_short}pages/search.php?search=!collection{$fc['ref']}",
                    )
                ),
                
"icon" => 'fa fa-fw fa-grip',
                
"text" => $lang['add_to_dash'],
            );
        }
        if(
$is_featured_collection && allow_featured_collection_share($fc))
            {
            
$render_ctx["tools"][] = array(
                
"href" => generateURL("{$baseurl_short}pages/collection_share.php", array("ref" => $fc["ref"])),
                
"icon" => 'fa-solid fa-fw fa-share-nodes',
                
"text" => $lang["share"]);
            }
        if(
$is_featured_collection && collection_readable($fc['ref']))
            {
            
$render_ctx["tools"][] = $tool_select;
            }
        if(
$is_featured_collection && collection_writeable($fc['ref']))
            {
            
$render_ctx["tools"][] = $tool_edit;
            }
        if(
$is_featured_collection && $show_theme_collection_stats)
            {
            
$render_ctx['show_resources_count'] = true;
            }
        if (
            
$is_featured_collection
            
&& !$is_smart_featured_collection
            
&& ($collection_data get_collection($fc['ref']))
            && 
allow_upload_to_collection(is_array($collection_data) ? $collection_data : [])
        ) {
            
$render_ctx['tools'][] = $tool_upload_to_collection;
        }


        if (
$is_featured_collection_category && !$is_smart_featured_collection) {
            global 
$enable_theme_category_edit;

            
$fc_category_url generateURL("{$baseurl_short}pages/collections_featured.php"$general_url_params, array("parent" => $fc["ref"]));
            
$fc_category_has_children = (isset($fc["has_children"]) ? (bool) $fc["has_children"] : false);

            
$render_ctx["href"] = $fc_category_url;
            
$render_ctx["icon"] = ICON_FOLDER;
            
$render_ctx["tools"] = array();

            if(
checkPermission_dashmanage())
                {
                
$render_ctx["tools"][] = array(
                    
"href" => generateURL(
                        
"{$baseurl_short}pages/dash_tile.php",
                        array(
                            
'create'            => 'true',
                            
'tltype'            => 'fcthm',
                            
'tlstyle'           => 'thmbs',
                            
'title'             => "{$fc['name']}",
                            
'freetext'          => 'true',
                            
'tile_audience'     => 'false',
                            
'promoted_resource' => (isset($render_ctx["images"]) ? 'true' ""),
                            
'link'              => $fc_category_url
                        
)
                    ),
                    
"icon" => 'fa fa-fw fa-grip',
                    
"text" => $lang["add_to_dash"]);
                }

            
$render_ctx["tools"][] = array(
                
"href" => generateURL("{$baseurl_short}pages/collection_share.php", array("ref" => $fc["ref"])),
                
"icon" => 'fa-solid fa-fw fa-share-nodes',
                
"text" => $lang["share"],
            );


            if(!
$fc_category_has_children && collection_readable($fc['ref']))
                {
                
$render_ctx["tools"][] = $tool_select;
                }

            if(
can_edit_featured_collection_category())
                {
                
$render_ctx["tools"][] = $tool_edit;
                }

            if (
                !
$fc_category_has_children
                
&& ($collection_data get_collection($fc['ref']))
                && 
allow_upload_to_collection(is_array($collection_data) ? $collection_data : [])
            ) {
                
$render_ctx['tools'][] = $tool_upload_to_collection;
            }
        }

        if(
$is_smart_featured_collection)
            {
            
$search NODE_TOKEN_PREFIX $fc["ref"];
            
$render_ctx["href"] = generateURL("{$baseurl_short}pages/search.php", array("search" => $search"resetrestypes" => "true"));

            
$node_is_parent = (isset($fc["node_is_parent"]) ? $fc["node_is_parent"] : true);
            if(
$node_is_parent)
                {
                
$render_ctx["href"] = generateURL(
                    
"{$baseurl_short}pages/collections_featured.php",
                    array(
                        
"smart_rtf" => $fc["resource_type_field"],
                        
"smart_fc_parent" => $fc["parent"],
                    ));
                }
            
$render_ctx["icon"] = ICON_FOLDER;
            
$render_ctx["tools"] = array();
            }
            
        
// Don't show the tools for external shares
        
if (trim($k) != "")
            {
            
$render_ctx["tools"] = array();
            }

        
render_featured_collection($render_ctx$fc);
        }
    }

This article was last updated 12th September 2025 21:35 Europe/London time based on the source file dated 5th September 2025 13:20 Europe/London time.