Yii Framework Forum: Bootstrap Thumbnails - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Bootstrap Thumbnails Newbie Bootstrap Thumbnails Rate Topic: -----

#1 User is offline   Davos 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 16-July 13

Posted 16 July 2013 - 11:07 AM

Hi,

Can anyone point a newbie to an example that may help me out?

I'm trying to use the bootstrap.widgets.TbThumbnails widget in conjunction with images that have been uploaded using the redactor widget to display thumbnails of the uploaded images within a view.

Is there anyone out there that could supply me an example or at least point me in the right direction?

I've trawled the docs and cant figure it.

BTW awesome extension!
0

#2 User is offline   leandroc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 24-July 13

Posted 24 July 2013 - 02:49 PM

View PostDavos, on 16 July 2013 - 11:07 AM, said:

Hi,

Can anyone point a newbie to an example that may help me out?

I'm trying to use the bootstrap.widgets.TbThumbnails widget in conjunction with images that have been uploaded using the redactor widget to display thumbnails of the uploaded images within a view.

Is there anyone out there that could supply me an example or at least point me in the right direction?

I've trawled the docs and cant figure it.

BTW awesome extension!


Hi Davos,

I'm new on Yii framework as well and also experienced some problems to understand how this component works.
It's pretty simple and I'll explain how it is working on my project.

I have a table called "images" with 3 fields (id, image_name, image_tooltip). The images are stored in a folder called "example" inside "images" folder (images/example) and the table is just to keep the name of the images that I have into this folder (image1.jpg).

I also have a view called "store.php", (protected/views/store/store.php).
the content of this view is:

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'store-form',
'enableAjaxValidation'=>false,
));

$dataProvider = new CActiveDataProvider('store'); // that's the table

$this->widget('bootstrap.widgets.TbThumbnails', array(
//'dataProvider'=>$thumbDataProvider,
'dataProvider'=>$dataProvider,
'template'=>"{items}\n{pager}",
'itemView'=>'_formTemplate2',
));

?>

<?php $this->endWidget(); ?>

</div><!-- form -->

As you can notice, I have another view called "_formTemplate2" (protected/views/store/_formTemplate2.php) where the component will render my images.
The content of this file is:

<li>
<a href="#" class="thumbnail" rel="tooltip" data-title="<?=$data['image_tooltip']?>" data-original-title="" title="">
<img src="<?php echo Yii::app()->getBaseUrl() .'/../images/example/'. $data['image_name'] ?>" alt="">
</a>
</li>


That's pretty much what I've done to make it work.

If you have any doubts feel free to contact me and I'll try to help u :).

I hope I could help you to solve you doubts.
0

#3 User is offline   Shahcheraghean 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 478
  • Joined: 12-December 12
  • Location:Mashhad, IRAN

Posted 25 July 2013 - 05:46 AM

look here for more informations.
http://www.cniska.ne...ml#tbThumbnails
www.shgn.ir
www.shgn.ir/yii-framework/
yii2.swsco.ir
In a world without any fences or walls,Who needs Gates or Windows!
0

#4 User is offline   Utopian 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 10-September 13

Posted 21 July 2014 - 03:40 AM

Hey,

Not sure if this thread is still watched upon. How can I do the same by returning images from the folder? I tried to return an array of image urls. But that doesn't work.

$this->widget('bootstrap.widgets.TbThumbnails', array(
'dataProvider'=>new CArrayDataProvider(array('images'=>array('1'=>'/../images/carousel/1.jpg','2'=>'/../images/carousel/ground-2.jpg'))),
'template'=>"{items}\n{pager}",
'itemView'=>'_thumbs',
));

And my _thumbs.php is:
<li class="span3">
<?php var_dump($data); ?>
<img src="<?php echo $data['images'] ?>" alt="<?php echo $data ?>">
</li>

My error is:
Undefined index: images

How do I access the image urls here?
0

#5 User is offline   leandroc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 24-July 13

Posted 21 July 2014 - 09:16 AM

View PostUtopian, on 21 July 2014 - 03:40 AM, said:

Hey,

Not sure if this thread is still watched upon. How can I do the same by returning images from the folder? I tried to return an array of image urls. But that doesn't work.

$this->widget('bootstrap.widgets.TbThumbnails', array(
'dataProvider'=>new CArrayDataProvider(array('images'=>array('1'=>'/../images/carousel/1.jpg','2'=>'/../images/carousel/ground-2.jpg'))),
'template'=>"{items}\n{pager}",
'itemView'=>'_thumbs',
));

And my _thumbs.php is:
<li class="span3">
<?php var_dump($data); ?>
<img src="<?php echo $data['images'] ?>" alt="<?php echo $data ?>">
</li>

My error is:
Undefined index: images

How do I access the image urls here?



Hi Mate,

you can access the image urls using the numbered index, just like that:

<img src="<?php echo $data[1] ?>" alt="<?php echo $data[1] ?>">

You gonna need some kind of control to change the index number in the iteration but I'm not sure how to do that..
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users