Build a Carousel (Bootstrap)

In this example the 'home' string points to a predefined gallery specified in the module settings.

    $api = new CollectionApi;
    $carousel = $api->getGalleryCarousel('home');
<div id="some" 
    class="carousel slide mainfont carousel-font" data-ride="carousel">
    <a class="left carousel-control" 
        href="#<?=$id;?>" role="button" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
            <span class="sr-only">Anterior</span>
    <a class="right carousel-control" 
        href="#<?=$id;?>" role="button" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
            <span class="sr-only">Siguiente</span>

Render a Page

Retrieve the content for a given page. Pages are previously defined in the module settings, via page attribute.

A .htaccess rule is usefull:

RewriteRule ^some123|anypage|another$ index.php?r=site/page&name=$0 [L]

So you can render content for a url similar to:

Add a action similar to this one:

    // in your SiteController.php
    public function actionPage($name){
        $api = new CollectionApi;
        $data = $api->expandMacros($api->loadPage($name));
        $this->layout = 'page';

About expandMacros

The page content can include macros to render content inside the CMS:

"Display some text and this collection : "@129891829@"

Where 12989... is the numerical ID of the collection to be expanded.


At first place, this module property should be defined, it will drive the links:


Also, the html content is generated by this call (see below). The links to more content are created using the url pattern above. The images are displayed using a different url format.

    $api = new CollectionApi;
    $services = $api->getGalleryHtml('home-services');
    echo $services;

This two .htaccess rule takes place here:

# render pictures
RewriteRule ^media/(.*)/(.*)/(.*)$ \
    index.php?r=/cms/lightcmsresources&id=$3&m=mediapicture [L]

# gives you the control of the link action
# see also 'gallery_url_pattern' at top of this chapter.
RewriteRule ^content/([a-z0-9A-Z\=]+)$ \
    index.php?r=/site/content&data=$1 [QSA]

Finnaly in your site controller define the Action 'content' to extract the content:

    public function actionContent($data=''){
        list($_a, $_b) = unserialize(base64_decode($data));
        $id = "{$_a}-{$_b}";
        $api = new CollectionApi;
        $rows = $api->enumGalleryFiles($id,true);
        $page = null; $pictures = array();
        foreach($rows as $item)
            if(is_array($item)) {$page = $item;}else{$pictures[] = $item;}