Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap Carousel with links #682

Closed
mrfatguy opened this issue Sep 25, 2013 · 2 comments
Closed

Bootstrap Carousel with links #682

mrfatguy opened this issue Sep 25, 2013 · 2 comments
Milestone

Comments

@mrfatguy
Copy link

Adding this:

if(isset($item['link']))
{
    if(!is_array($item['link'])) $item['link'] = array('href'=>$item['link']);

    echo CHtml::openTag('a', $item['link']);
}

in line 152 of TbCarousel.php and this:

if(isset($item['link'])) echo CHtml::closeTag('a');

in line 184 would let you use Bootstrap Carousel with links -- i.e. make each image clickable.

Link can be given as just string (only URL, passed to href):

'link'=>Yii::app()->createAbsoluteUrl('main/show', array('id'=>$video->id))

or as an array, where you specify each <a> tag's attributes by yourself:

'link'=>array
(
    'title'=>$title,
    'href'=>"Yii::app()->createAbsoluteUrl('main/show', array('id'=>$video->id))"
),

That's all folks! :] Sorry, but due to high time pressure, I'm unable to create commit myself and prepare pull request for you. You'll have to merge this with your code yourself, if you're willing to extend Bootstrap Carousel with link-like functionality.

@hijarian
Copy link
Contributor

hijarian commented Oct 3, 2013

Thanks! Will integrate it when I will get opportunity myself. :)

@digitalcrab
Copy link
Contributor

Hello @trejder
Thank you for your issue. Now it is done in master branch and will be included to the next release!

Now you can add links this way:

$this->widget('bootstrap.widgets.TbCarousel', array(
    'items' => array(
        array(
            'image' => 'http://yiibooster.clevertech.biz/images/first-placeholder830x400.gif',
            'label' => 'First Thumbnail label',
            'caption' => 'Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.',

            // URL as string
            'link' => 'http://yiibooster.clevertech.biz/',

            // Any kind of options for "A' tag
            'linkOptions' => array(
                'title' => 'Yii Booster',
            ),
        ),
        array(
            'image' => 'http://yiibooster.clevertech.biz/images/second-placeholder830x400.gif',
            'label' => 'Second Thumbnail label',
            'caption' => 'Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.',

            // You can specify URL like for 'redirect' function of controller
            'link' => array('site/index', 'param1' => 'value1'),
        ),
    ),
));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants