Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Kristian Gil
Carousel portlet
May 12, 2011 8:33 AM
Answer

Kristian Gil

Rank: New Member

Posts: 22

Join Date: July 14, 2010

Recent Posts

Hi,

We're planning on implementing a Carousel portlet like the one at Yahoo's home page.
Does anyone have a suggestion if there is already an existing portlet for this or if it's better to develop one from scratch?
One idea we had was to create another view for the Asset Publisher portlet using JQuery or maybe AlloyUI.
We're running on Liferay 5.1.7.

Any suggestion is appreciated, thanks!
Sergio Sanchez
RE: Carousel portlet
May 12, 2011 10:07 AM
Answer

Sergio Sanchez

Rank: Junior Member

Posts: 41

Join Date: February 3, 2011

Recent Posts

I did that using the Jquery jcarousel plugin. This plugin needs the elements to move to be list items inside an unordered list, so I had to wrap the HTML that the asset publisher produced in li tags inside journal/asset/abstract.jsp and print ul tags inside asset_publisher/display/abstracts.jsp. Those JSPs need to be deployed inside a hook plugin.

Hope this helps
gofri _
RE: Carousel portlet
May 13, 2011 6:48 AM
Answer

gofri _

Rank: Junior Member

Posts: 94

Join Date: March 2, 2007

Recent Posts

The simplest way:

 1<script type="text/javascript" charset="utf-8">
 2AUI().ready('aui-carousel', function(A) {
 3
 4    var component = new A.Carousel(
 5        {
 6            intervalTime: 5,
 7            contentBox: '#divanim',
 8            activeIndex: 'rand',
 9            height: 28,
10            width: 780
11        }
12    )
13    .render();
14
15});
16</script>
Jelmer Kuperus
RE: Carousel portlet
May 13, 2011 9:15 AM
Answer

Jelmer Kuperus

Rank: Liferay Legend

Posts: 1190

Join Date: March 10, 2010

Recent Posts

You can use webcontent :

structure :

 1<root>
 2  <dynamic-element name='duration' type='list' index-type='' repeatable='false'>
 3  <meta-data>
 4            <entry name="displayAsTooltip"><![CDATA[false]]></entry>
 5            <entry name="required"><![CDATA[false]]></entry>
 6            <entry name="instructions"><![CDATA[Select how long, in seconds, you would prefer to display an item before switching to the next slide]]></entry>
 7            <entry name="label"><![CDATA[Item Duration]]></entry>
 8            <entry name="predefinedValue"><![CDATA[]]></entry>
 9        </meta-data>
10
11    <dynamic-element name='1' type='1' index-type='' repeatable='false'>  </dynamic-element>
12    <dynamic-element name='2' type='2' index-type='' repeatable='false'>  </dynamic-element>
13    <dynamic-element name='3' type='3' index-type='' repeatable='false'>  </dynamic-element>
14    <dynamic-element name='4' type='4' index-type='' repeatable='false'>  </dynamic-element>
15    <dynamic-element name='5' type='5' index-type='' repeatable='false'>  </dynamic-element>
16    <dynamic-element name='6' type='6' index-type='' repeatable='false'>  </dynamic-element>
17    <dynamic-element name='7' type='7' index-type='' repeatable='false'>  </dynamic-element>
18    <dynamic-element name='8' type='8' index-type='' repeatable='false'>  </dynamic-element>
19    <dynamic-element name='9' type='9' index-type='' repeatable='false'>  </dynamic-element>
20    <dynamic-element name='10' type='10' index-type='' repeatable='false'></dynamic-element>
21  </dynamic-element>
22  <dynamic-element name='height' type='text' index-type='' repeatable='false'>
23  <meta-data>
24            <entry name="displayAsTooltip"><![CDATA[false]]></entry>
25            <entry name="required"><![CDATA[true]]></entry>
26            <entry name="instructions"><![CDATA[This defines the height of the carousel, in pixels(px). Do not add "px" at the end of the value]]></entry>
27            <entry name="label"><![CDATA[Height]]></entry>
28            <entry name="predefinedValue"><![CDATA[]]></entry>
29        </meta-data>
30</dynamic-element>
31  <dynamic-element name='width' type='text' index-type='' repeatable='false'>
32  <meta-data>
33            <entry name="displayAsTooltip"><![CDATA[false]]></entry>
34            <entry name="required"><![CDATA[true]]></entry>
35            <entry name="instructions"><![CDATA[This defines the width of the carousel, in pixels(px). Do not add "px" at the end of the value]]></entry>
36            <entry name="label"><![CDATA[Width]]></entry>
37            <entry name="predefinedValue"><![CDATA[]]></entry>
38        </meta-data>
39</dynamic-element>
40  <dynamic-element name='content' type='text_area' index-type='text' repeatable='true'>
41  <meta-data>
42            <entry name="displayAsTooltip"><![CDATA[false]]></entry>
43            <entry name="required"><![CDATA[true]]></entry>
44            <entry name="instructions"><![CDATA[This is the content of this slide. To create more slides, click on the " " button]]></entry>
45            <entry name="label"><![CDATA[content]]></entry>
46            <entry name="predefinedValue"><![CDATA[]]></entry>
47        </meta-data>
48</dynamic-element>
49</root>


Template


 1#set ($contentId = $reserved-article-id.getData())
 2#set ($contentClass = "multiple-items-" + $contentId + "-carousel")
 3
 4<style type="text/css" media="screen">
 5    #$contentClass {
 6        height: $height.getData()px;
 7        position: relative;
 8        width: $width.getData()px;
 9    }
10
11    #$contentClass .carousel-item {
12        height: $height.getData()px;
13        overflow: hidden;
14        width: $width.getData()px;
15        position: absolute;
16        top: 0;
17    }
18</style>
19
20<div id="$contentClass">
21    #foreach ($item in $content.getSiblings())
22        <div class="carousel-item">
23            $item.getData()
24        </div>
25    #end
26</div>
27
28<script type="text/javascript">
29    AUI().ready(
30    'aui-carousel',
31    function(A) {
32        var component = new A.Carousel(
33            {
34                activeIndex: 'rand',
35                contentBox: '#$contentClass',
36                height: $height.getData(),
37                intervalTime: $duration.getData(),
38                width: $width.getData()
39            }
40        )
41        .render();
42    });
43</script>
Armando Ponce
RE: Carousel portlet
May 16, 2011 9:11 AM
Answer

Armando Ponce

Rank: New Member

Posts: 8

Join Date: May 16, 2011

Recent Posts

In Liferay 5.1.7 there is no Alloy UI, is it? I think the way to go is with Jquery.
Nilesh Gundecha
RE: Carousel portlet
May 17, 2011 12:40 AM
Answer

Nilesh Gundecha

Rank: Regular Member

Posts: 188

Join Date: November 30, 2009

Recent Posts

I tried using the Alloy UI and could successfully achieve it. But the problem what I faced was that every time my portal page use to get refreshed, the Carousel use to get reloaded. And whenever the Carousel gets reloaded, it displays all the <div>'s for few seconds and then starts its carousel effect. I want to avoid this. Is there any way I can configure this?

Thanks and Regards,
Nilesh.
Oliver Bayer
RE: Carousel portlet
May 17, 2011 1:10 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 866

Join Date: February 18, 2009

Recent Posts

Hi Nilesh,

I don't think you can avoid this "feature". It all depends on your network connection speed because the page has to be completely loaded before the carousel script is run. So all html has to be loaded before the js effect can start and redisplay the carousel contents. Testing it at localhost you shouldn't see the divs.

HTH Oli
Nilesh Gundecha
RE: Carousel portlet
May 17, 2011 1:22 AM
Answer

Nilesh Gundecha

Rank: Regular Member

Posts: 188

Join Date: November 30, 2009

Recent Posts

Hi Oliver,

Many Thanks for your reply. But I dont see this to be a network connection speed problem. As I am not facing the same problem when I am surfing the liferay.com. As we know in liferay.com, on its home page itself, Alloy Carousel is used where different images are embedded inside the div are is carousel effect.

But while surfing this, I am not facing any problem. There is no reloading delay which makes all the content to be seen first, and then effect.

I am facing problem in my local system itself. I will post my code here.

Regards,
Nilesh.
gofri _
RE: Carousel portlet
May 17, 2011 2:03 AM
Answer

gofri _

Rank: Junior Member

Posts: 94

Join Date: March 2, 2007

Recent Posts

hi, try to position your divs to overlap each other
Christopher Jimenez
RE: Carousel portlet
January 30, 2012 10:15 AM
Answer

Christopher Jimenez

Rank: New Member

Posts: 10

Join Date: December 23, 2011

Recent Posts

I dont want to have all the information in the same web content... I like to do the same but web content with a special tag or categories
Mika Koivisto
RE: Carousel portlet
August 22, 2012 8:26 PM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1499

Join Date: August 7, 2006

Recent Posts

Just thought I'd let everyone know that I recently made a photo carousel portlet that uses Alloy UI carousel which you can quite conveniently configure and it pulls the images from Document's and Media.
Matus Ferko
RE: Carousel portlet
September 4, 2012 12:59 PM
Answer

Matus Ferko

Rank: Junior Member

Posts: 26

Join Date: June 5, 2009

Recent Posts

Mika I am not able to build the portlet with build-css goal enabled
1<executions>
2        <execution>
3            <phase>generate-sources</phase>
4                <goals>
5                    <goal>build-css</goal>
6                </goals>
7        </execution>
8    </executions>


Edit 1:
I use plugin version 6.1.1
I receive error
Failed to execute goal com.liferay.maven.plugins:liferay-maven-plugin:6.1.1:build-css (default) on project photo-carousel-portlet: basedir C:\...\photo-carousel-portlet\target\photo-carousel-portlet-0.1-SNAPSHOT does not exist. -> [Help 1]
Mika Koivisto
RE: Carousel portlet
September 4, 2012 11:46 AM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1499

Join Date: August 7, 2006

Recent Posts

It requires 6.1.1 or 6.1.20 version of the Liferay maven plugin which has the build-css goal.
Hans-Jörg Alles
RE: Carousel portlet
January 11, 2013 5:12 AM
Answer

Hans-Jörg Alles

Rank: New Member

Posts: 1

Join Date: May 30, 2012

Recent Posts

Hello Mika,

i tried your photo portlet. It have everything on board i need, thank you very much.
But could it be, that if you enable link and store url per picture, that this works ( mouse / hyperlink ) in FF but not in IE 8 ?

Greatings

Hans-Jörg
Valérie barbot
RE: Carousel portlet
December 12, 2013 6:52 AM
Answer

Valérie barbot

Rank: Junior Member

Posts: 71

Join Date: April 7, 2009

Recent Posts

photo carousel portlet is very useful. i have a problem with rights because guest must not view the folder but only access. i have the error :

Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /view.jsp at line 29
thanks