Quantcast

images in template

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

images in template

Emilio Otero
Hi I'm newbie using the templates to show a query. My question is this. I'm trying to display images in my template, I have multiple images for an unique code, for example, code X23 has four images, and i don't know how to show only a code and the images it has associated.
This is my code:

<#list features as feature>
<div id="box">
<div id="boxCODE">Code: </div>
<div id="box2"><div id="boxCO">${feature.code.value}</div></div>
<div id="boxMAT">Mat: </div>
<div id="boxOB2"><div id="box3">${feature.mat.value}</div></div>
<div id="boxOB">Obj:</div>
<div id="boxOB2"><div id="box3">${feature.obj.value}</div></div>
<img src="<a href="http://localhost:8080/thumb/${feature.foto.value}">http://localhost:8080/thumb/${feature.foto.value}">
</div>
</#list>

anyone, could help me with this?

thanks!!

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: images in template

Daniel Dekany
You mean multiple `feature`-s has the same code? Then maybe it's the
duty of the what prepares the data-model to group them together.
Especially if the features aren't sorted by code.


Monday, October 20, 2014, 2:05:05 PM, Emilio Otero wrote:

> Hi I'm newbie using the templates to show a query. My question is
> this. I'm trying to display images in my template, I have multiple
> images for an unique code, for example, code X23 has four images,
> and i don't know how to show only a code and the images it has associated.
> This is my code:
>
> <#list features as feature>
>     <div id="box">
>      <div id="boxCODE">Code: </div>
>      <div id="box2"><div id="boxCO">${feature.code.value}</div></div>
>      <div id="boxMAT">Mat: </div>
>      <div id="boxOB2"><div id="box3">${feature.mat.value}</div></div>
>      <div id="boxOB">Obj:</div>
>      <div id="boxOB2"><div id="box3">${feature.obj.value}</div></div>
>      <img src="http://localhost:8080/thumb/${feature.foto.value}">
>     </div>
>  </#list>
>
> anyone, could help me with this?
>
> thanks!!

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: images in template

Daniel Dekany
Since then I have seen the data model. Apparently, it's the result of
a SQL join that's not transformed to something object oriented with
JPA or such, but thrown at poor template as is. Thus, each row repeats
the same values, except for the joined columns (the foto). So either
do that grouping in Java before passing the rows to the data-model, or
ensure that the rows are sorted by ID (and hence by "code") and then
it could be done like:

  <@listInGroups someRows 'code'; grpRows, grpFirstRow>
    Code: ${grpFirstRow.code}
    Fotos:
    <#list grpRows as row>
    - ${row.foto}
    </#list>
  </@listInGroups>

where "listInGroups" was defined as:

  <#macro listInGroups rows colName>
    <#local idx = 0>
    <#list 0..100000000 as _>
      <#local grp = getGroup(rows, colName, idx)>
      <#if grp?size != 0>
        <#nested grp grp[0] />
        <#local idx = idx + grp?size>
      <#else>
        <#break>
      </#if>  
    </#list>
  </#macro>

  <#function getGroup rows colName startIdx>
    <#if rows?size == startIdx>
      <#return []>
    </#if>
    <#local endIdx = startIdx + 1>
    <#local grpVal = rows[startIdx][colName]>
    <#list 0..100000000 as _>
      <#if endIdx == rows?size || rows[endIdx][colName] != grpVal>
        <#break>
      </#if>
      <#local endIdx = endIdx + 1>
    </#list>
    <#return rows[startIdx .. endIdx - 1]>
  </#function>

The above could come from an #import or #include of course. I wonder
if this issue is frequent enough to warrant built-in support.

--
Thanks,
 Daniel Dekany


Monday, October 20, 2014, 7:08:50 PM, Daniel Dekany wrote:

> You mean multiple `feature`-s has the same code? Then maybe it's the
> duty of the what prepares the data-model to group them together.
> Especially if the features aren't sorted by code.
>
>
> Monday, October 20, 2014, 2:05:05 PM, Emilio Otero wrote:
>
>> Hi I'm newbie using the templates to show a query. My question is
>> this. I'm trying to display images in my template, I have multiple
>> images for an unique code, for example, code X23 has four images,
>> and i don't know how to show only a code and the images it has associated.
>> This is my code:
>>
>> <#list features as feature>
>>     <div id="box">
>>      <div id="boxCODE">Code: </div>
>>      <div id="box2"><div id="boxCO">${feature.code.value}</div></div>
>>      <div id="boxMAT">Mat: </div>
>>      <div id="boxOB2"><div id="box3">${feature.mat.value}</div></div>
>>      <div id="boxOB">Obj:</div>
>>      <div id="boxOB2"><div id="box3">${feature.obj.value}</div></div>
>>      <img src="http://localhost:8080/thumb/${feature.foto.value}">
>>     </div>
>>  </#list>
>>
>> anyone, could help me with this?
>>
>> thanks!!
>


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Loading...