RE: Error using PhotoCarousel in Liferay 7.2 GA1

BRODY HIGGS JR, modified 6 Years ago. Junior Member Posts: 61 Join Date: 5/16/14 Recent Posts
I am trying to add images and publish a carousel to a site page using the built-in PhotoCarousel in Liferay 7.2 GA1, but I am receiving an error. The error is received after selecting an image and clicking Publish.

Error: Your request failed to complete
Error: Please select at least one category for Publication 1.
You cannot select more than one category for Publication 1.
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hey Brody,

When you say PhotoCarousel ... are you referring to the Media Gallery Widget with the Carousel template applied to it? (I'm trying to reproduce your issue to see if I can help, but I don't see any widgets in my 7.2 GA1 called "PhotoCarousel")aj
BRODY HIGGS JR, modified 6 Years ago. Junior Member Posts: 61 Join Date: 5/16/14 Recent Posts
I searched for ‘carousel’ under ‘Content’ and tried to use ‘PhotoCarousel’ (version 6.2.0.1). I am looking for a carousel to use in Liferay 7.2 CE GA1. I used a carousel in Liferay 6.2 CE.
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Ah, that's not what I understood from your original post. Alright, in that case, you could try this.

1. Add the "Media gallery" portlet to the page

2. Under the portlet configuration, there is an option for display template, you can choose carousel as the template

You can then use the + in the portlet title bar to add content items. If the results are not what you are looking for in terms of template presentation, you can always create your own template.


​​​​​​​
BRODY HIGGS JR, modified 6 Years ago. Junior Member Posts: 61 Join Date: 5/16/14 Recent Posts
Your suggestion works, but I would like each image to be a link to a URL. Also, how can I increase the size of the images being displayed. Would I need to add custom css? In Liferay 6.2, the carousel was 1020 x 300 pixels (width x height).
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hey Brody,

Glad to hear that you are part way there. Too bad the template doesn't meet your needs out of the box, but the good news is that you are now in control of hte template as this is an ADT enabled portlet.

1. Go back to where you picked the Carousel template and this time choose Manage Templates

2. The resulting dialog is likely empty, but you can use the + in the upper right hand corner to add a new item

3. Fill in the fields at the top and then you template at the bottom. Here is te code for the our of the box carousel you selected earlier -- which you can use as a baseline and change as you need to for your case

<#if entries?has_content>
   <style>
      #<@portlet.namespace />carousel .carousel-item {
         background-color: #000;
         height: 250px;
         overflow: hidden;
         text-align: center;
         width: 700px;
      }

      #<@portlet.namespace />carousel .carousel-item img {
         max-height: 250px;
         max-width: 700px;
      }
   </style>

   <div id="<@portlet.namespace />carousel">
      &lt;#assign imageMimeTypes = propsUtil.getArray("dl.file.entry.preview.image.mime.types") /&gt;

      &lt;#list entries as entry&gt;
         &lt;#if imageMimeTypes?seq_contains(entry.getMimeType())&gt;
            <div class="carousel-item image-viewer-base-image">
               <img src="${dlUtil.getPreviewURL(entry, entry.getFileVersion(), themeDisplay, " ")}">
            </div>
         <!--#if-->
      <!--#list-->
   </div>

   &lt;@liferay_aui.script use="aui-carousel"&gt;
      var carousel = new A.Carousel(
         {
            after: {
               responsive: function(event) {
                  event.stopImmediatePropagation();

                  var boundingBox = event.currentTarget.get('boundingBox');

                  boundingBox.all('.image-viewer-base-image-list, .image-viewer-base-image').setStyles(
                     {
                        height: 'auto',
                        maxHeight: event.height,
                        maxWidth: event.width,
                        width: 'auto'
                     }
                  );
               }
            },

            contentBox: '#&lt;@portlet.namespace /&gt;carousel',
            height: 250,
            intervalTime: 2,
            width: 700
         }
      ).render();
   <!--@liferay_aui.script-->
<!--#if-->
​​​​​​​
4. Now save, and exit out of everything, including the portlet preferences

5. Go back into the portlet preferences and you should see your custom template now as an option
BRODY HIGGS JR, modified 6 Years ago. Junior Member Posts: 61 Join Date: 5/16/14 Recent Posts
I do not see a ‘Manage Templates’ option. The ‘Media Gallery’ portlet has the following options.

Look/Feel Configuration,
Export/Import,
Configuration (Display Template: Default or Carousel),
Permissions,
Configuration Templates (Save Current Configuration as Template),
Remove
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Are you logged in as the administrator? .. this is what I see (attached)
BRODY HIGGS JR, modified 6 Years ago. Junior Member Posts: 61 Join Date: 5/16/14 Recent Posts
I see ‘Manage Template’ now. I was able to resize images on the carousel using your code, but how can I add a link or URL for each image? Thank you.
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
I don't think that is how the Media Gallery was intended to be used. From what I can make out, it's just supposed to provide a flip book of sorts. To do what you want I think you have a couple options.

1. Check the Liferay Marketplace (https://web.liferay.com/marketplace) to see if there is a plugin there that someone has contributed.

2. Roll your own -- but rather than creating your own entire portlet for this you can just leverage the Asset Publisher.
a. Define a new structure with an image field and field to specify the link
b. Create a new WCM template with just the code to render the item (<li><a href="...)
c. Create new web content items, one for each image (I would probably organize them into a folder)
d. Go to the page where you want the carousel and add a Asset Publisher portlet
e. Configure the portlet to pull only the Web Content of your structure type
f. Manage templates, as you did for the Media Gallery, and add your template -- it will be a little different from what you did in the media gallery. You're basically going to loop over the list of asset entries and add define everything around the list items, and then use the loop to render then the asset entries which will actually render your WCM Template (<li>'s)

3. Is gross so I am not going to write it here because people just shouldn't do it emoticon

#1, if you can find a candidate is the quickest, but # gives you the most control.