Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I want to take advantage of Twitter Bootstrap responsive features and create a Twitter Bootstrap Carousel (photo slideshow) on the homepage. http://twitter.github.com/bootstrap/javascript.html#carousel, but how do I create the view?
I have try with view_slidershow http://www.brightwebsitedesign.com/how-to-install-views-slideshow-module...
I don't know how to:
1) add the slideshow to the homepage
2) how to customize the markup
thanks
Comment | File | Size | Author |
---|---|---|---|
Schermata 2013-04-10 a 17.16.57.png | 856.21 KB | Tiziano1974 |
Comments
Comment #1
Pomliane CreditAttribution: Pomliane commentedViews and Views bootstrap and you're good to go.
Comment #2
Tiziano1974 CreditAttribution: Tiziano1974 commentedI did ok but how to make the example: http://twitter.github.com/bootstrap/javascript.html#carousel
thanks
Comment #3
Pomliane CreditAttribution: Pomliane commentedIt seems the first thing you need is to read Views documentation: http://drupal.org/node/109604
Once you understand the way Views works, it shouldn't be a problem to build the slideshow/carousel in your example — or is there anything I'm missing in your support request?
Comment #5
markojovanovich CreditAttribution: markojovanovich commentedHi there,
For implementing TB carousel you could do next:
1. Create view:
2. Showing fields
3. Find Theme: Information - for this view
In Display output add:
I will assume that you have all ready included bootstrap.js and jquery. Now you can add initialization for TB carousel:
$('.carousel').carousel()
Comment #6
Adam Wood CreditAttribution: Adam Wood commentedJust to add to markojovanovich's good instructions above, one thing you'll struggle with is adding the
.active
to the first row/item. We found jQuery the best solution:$(".carousel-inner div:first").addClass("active");
... or create an ID for the '.carousel-inner' div and use that for slightly better performance.
Comment #7
Chennard CreditAttribution: Chennard commentedHi,
I want to display the carousel on my front page.
Where in my theme do create the file and what name should i give it? and where do i add the above php code from markojovanovich? i'm trying to display the carousel on my front page in using blocks.
Grtz,
Chennard
Comment #8
stephen Piscura CreditAttribution: stephen Piscura commentedI'm using the 7.x-3.0 branch and here's what's working for me so far in the style template:
Granted, the carousel indicators are hardcoded (i'd love to hear how folks may have had success in making these dynamic related to the number of rows in the view), but the first row finally has the "active" class without the need for additional scripts! As a non-developer, that took more time than i care to admit...
Comment #9
Adam Wood CreditAttribution: Adam Wood commentedTry this for dynamically generated indicators...
You're just using the same process for the indicators as you are the items, i.e., looping through them and doing something different for the first one.
Comment #10
stephen Piscura CreditAttribution: stephen Piscura commentedAdam,
Brilliant, works like a charm. Thank you!
One final question: Do you know how to/if it's possible to print the machine name of the display in this view? For example i'd like to do something like:
Which for me would yield:
The reason i want to do this is because i plan to use the same view (with multiple displays) to create all the Bootstrap Carousels for my website. This seems like an efficient way to eliminate the need for a whole bunch of (almost) identical templates while at the same time ensuring each instance is unique (in the case, for example, that i'm displaying two carousel blocks on the same page).
Comment #11
Adam Wood CreditAttribution: Adam Wood commentedYou can use:
<?php print $view->name; ?>
Comment #12
stephen Piscura CreditAttribution: stephen Piscura commentedAdam,
Thanks again for getting me one step closer. In this case i'm actually trying to drill one level deeper into the display ID or machine name of the display within the view.
That is to say, using:
<?php print $view->name; ?>
i end up printing the name of my entire view, which is called "bootstrap_carousel". But what i really want to do is print the specific display ID or machine name. Something like:
<?php print $view->name>display_id; ?>
In my case, this would print, "front_featured_block".
Maybe this is super simple, or maybe that isn't available to this template?
Comment #13
Adam Wood CreditAttribution: Adam Wood commentedYou can see all of the data available to you by adding this to your template file:
If you just want the display ID, then use:
<?php echo $view->current_display; ?>
, however this wont provide a truly unique id, as another view could have the same display id. Using a combination of the view machine name and display id would be best. So:<?php echo $view->name . '-' . $view->current_display; ?>
You may want to tidy that, to change the underscores used, i.e., block_1, to hyphens. To do that:
<?php $view_id = str_replace('_', '-', $view->name . '-' . $view->current_display); echo $view_id; ?>
Comment #14
stephen Piscura CreditAttribution: stephen Piscura commentedAdam,
I really owe you one. Everything you've shared is super helpful. The string-replace stuff was the icing on the cake...
Mission accomplished!
Comment #15
Adam Wood CreditAttribution: Adam Wood commentedNo problem. I think we've created a perfect Views style template for Bootstrap carousels with these different elements.
Here's a tidied up version incorporating everything from this thread...
Comment #16
stephen Piscura CreditAttribution: stephen Piscura commentedFantastic.
I do hope folks using things like:
will find a way to access this option more easily.
Maybe the maintainers of this and/or those modules could somehow feature this views recipe more prominently. Would it be ridiculous to think this .tpl could even go into the Bootstrap theme itself (with a good README)?
Thanks again markojovanovich, Adam Wood and others for your valuable input!
Comment #17
stephen Piscura CreditAttribution: stephen Piscura commentedChanging category and status just in case the maintainers want to consider this. Of course they can close it right away if not.
Comment #18
markhalliwellDrupal wiki pages are editable by everyone. Please edit the Bootstrap Documentation sub-pages directly. This base theme's code base is not an appropriate place for this information.