Page 1 of 2

Broad-leaf home page banner.

Posted: Mon Mar 24, 2014 11:34 am
by boseseb
Need help on BLC banner and priority:
I am able to create multiple banners through BLC admin and if all the banner are set with priority “1”, on refresh banner is changing on BLC site. Is this approach correct ? or I need to use the Rule(Restrict to certain times?) to get different banners on different time? As per my understanding if banner priority is not “1”, it’s not displayed on the site. Please correct me if I am wrong.

Thanks in advance,
Bose Sebastian

Re: Broad-leaf home page banner.

Posted: Mon Mar 24, 2014 2:53 pm
by phillipuniverse
Yes, if you want a rotating banner than the correct approach is to set them all with the same priority. There is nothing special about the priority '1', just that when you pull back all of the content items within Thymeleaf they are sorted by the priority (lowest priority first).

So, if you had 5 banner ads that had these priorities:

1, 0, 3, 2, 8

And you were just displaying a single item, that first item would ALWAYS be the content with a priority of 0. If you changed it like this:

0, 0, 3, 2, 8

Then the system would randomly determine which 0-priority content item to display.

That said, you could also get the entire list and pick yourself which one to display, or do a rotating banner which some have also done. This is done basically like this with the 'contentItems' variable that the blc:content processor returns:

Code: Select all

<blc:content contentType="Homepage Banner Ad" />       
<div id="banners" th:if="${contentItem !=null and contentItem['targetUrl'] != null and contentItem['imageUrl'] != null}">
    <ul>
        <li th:each="${item} : contentItems">
            <a th:href="@{${item['targetUrl']}}"><img th:src="@{${item['imageUrl']}}" /></a>
        </li>
    </ul>
</div>

Re: Broad-leaf home page banner.

Posted: Tue Mar 25, 2014 1:01 am
by boseseb
Thanks phillipuniverse..

Re: Broad-leaf home page banner.

Posted: Tue Mar 25, 2014 7:38 am
by boseseb
I tried with this code:

<blc:content contentType="Homepage Banner Ad" />
<div id="banners" th:if="${contentItem !=null and contentItem['targetUrl'] != null and contentItem['imageUrl'] != null}">
<ul>
<li th:each="${item} : contentItems">
<a th:href="@{${item['targetUrl']}}"><img th:src="@{${item['imageUrl']}}" /></a>
</li>
</ul>
</div>


But is throwing exception like:
org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as each: "${item} : contentItems" (layout/home:25)
at org.thymeleaf.standard.expression.StandardExpressionParser.parseEach(StandardExpressionParser.java:283)
at org.thymeleaf.standard.expression.StandardExpressionParser.parseEach(StandardExpressionParser.java:129)
at org.thymeleaf.standard.expression.StandardExpressionProcessor.parseEach(StandardExpressionProcessor.java:94)
at org.thymeleaf.standard.processor.attr.AbstractStandardIterationAttrProcessor.getIterationSpec(AbstractStandardIterationAttrProcessor.java:67)
at org.thymeleaf.processor.attr.AbstractIterationAttrProcessor.processAttribute(AbstractIterationAttrProcessor.java:70)
at org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:74)
at org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212)

Can u pleas help on the same. I am using BLC 3.0.3

Thanks in advance,
Bose Sebastian

Re: Broad-leaf home page banner.

Posted: Tue Mar 25, 2014 12:08 pm
by phillipuniverse
Sorry, got that backwards. It should be:

Code: Select all

<li th:each="item : ${contentItems}">

Re: Broad-leaf home page banner.

Posted: Tue Mar 25, 2014 12:08 pm
by phillipuniverse
Also, I would strongly encourage you to use the latest 3.0 patch release which is currently 3.0.10-GA.

Re: Broad-leaf home page banner.

Posted: Wed Mar 26, 2014 1:48 am
by boseseb
My current code:

Code: Select all

<div id="banners" th:if="${contentItem !=null and contentItem['targetUrl'] != null and contentItem['imageUrl'] != null}">
                  <ul>
                     <li th:each="item : ${contentItems}">
                        <a th:href="@{${item['targetUrl']}}"><img th:src="@{${item['imageUrl']}}" /></a>
                     </li>
                  </ul>
</div>

The bug is gone but now the banner itself is not displaying. I have 2 banners with priority 1 and its working (on refresh it will reload 2nd banner) with basic BLC code.

Thanks in advance,
Bose Sebastian

Re: Broad-leaf home page banner.

Posted: Wed Jun 11, 2014 3:30 pm
by Singha1
I want to make carousel type banner with rotating images. I am not able to figure out how to achieve this. Please guide me on this.

Re: Broad-leaf home page banner.

Posted: Wed Jun 11, 2014 5:38 pm
by Singha1
solution as suggested is not working. this is the code i have

Code: Select all

<blc:content contentType="Homepage Banner Ad" />       
        <div id="banners" th:if="${contentItem !=null and contentItem['targetUrl'] != null and contentItem['imageUrl'] != null}">
           <ul>
           <li th:each="contentItem : ${contentItems}">
               <a th:href="@{${contentItem['targetUrl']}}"><img th:src="@{${contentItem['imageUrl']}}" style="width:100%;"/></a>
         </li>

            </ul>
        </div>


Please share if somebody got it working. I have 2 contents with same priority 0

Re: Broad-leaf home page banner.

Posted: Thu Jun 12, 2014 3:40 am
by Singha1
I got this solved thanks!!