HTTPS SSH

Build a Carousel (Bootstrap)

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

<?php
    $api = new CollectionApi;
    $carousel = $api->getGalleryCarousel('home');
?>
<div id="some" 
    class="carousel slide mainfont carousel-font" data-ride="carousel">
    <?=$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>
    <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>
    </a>
</div>

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:

http://yoursite.com/some123

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';
        $this->render('page',
            array(
                'page_title'=>$data['title'],
                'page_subtext'=>$data['subtext'],
                'page_col1'=>$data['col1'],
                'page_col2'=>$data['col2'],
                'page_col3'=>$data['col3'],
            ));
    }

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.

Galleries

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

'gallery_url_pattern'=>'http:/mysite.com/content/%data%',

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.

<?php
    Yii::import("application.modules.yii-lightcms.components.CollectionApi");
    $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;}
        $this->renderText(
        "<pre>".print_r(array("page"=>$page,"pics"=>$pictures),true)."</pre>");
    }