Functions/set current collection

set_current_collection allows you to set a particular collection as the current collection, so you can later use any available collection helpers for that particular collection.

Usage

<?php
    set_current_collection($collection);
?>

Arguments

  • collection - An collection object, which can be retrieved through a variety of methods. See get_collection_by_id for one such method.

Examples

The following example sets the current collection to an collection with a ID of 2:

<?php set_current_collection(get_collection_by_id(2)); ?>

After setting the current collection, you can use the collection, or other collection helpers, to get collection metadata. The following example sets the current collection as described before, then uses the collection helper to echo the Name and Description of that particular collection:

<?php set_current_collection(get_collection_by_id(12)); ?>
<h2><?php echo collection('Name'); ?></h2>
<div id="collection-description"><?php echo collection('Description'); ?></div>