Fórumok

Application Dispaly Templates Code for Getting Article Small Image Id

Muhammad Umer Zubair, módosítva 10 év-val korábban

Application Dispaly Templates Code for Getting Article Small Image Id

New Member Bejegyzések: 18 Csatlakozás dátuma: 2014.01.01. Legújabb bejegyzések
Hi,

Can any body guide about the code for Application Display Templates for getting Article Small Image Id (mentioned in abstracts section of the article) to be used in Asset Publisher. This will help in getting latest news, etc. Like built in display style "Abstract" shows Article Title, abstract small image, abstract summary, etc.

Thanks in advance.
thumbnail
James Falkner, módosítva 10 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id (Válasz)

Liferay Legend Bejegyzések: 1399 Csatlakozás dátuma: 2010.09.17. Legújabb bejegyzések
Muhammad Umer Zubair:
Hi,

Can any body guide about the code for Application Display Templates for getting Article Small Image Id (mentioned in abstracts section of the article) to be used in Asset Publisher. This will help in getting latest news, etc. Like built in display style "Abstract" shows Article Title, abstract small image, abstract summary, etc.

Thanks in advance.


here ya go...


<#list entries as curEntry>
    <#assign renderer = curEntry.getAssetRenderer() >
    <#assign className = renderer.getClassName() >
    <#if className == "com.liferay.portlet.journal.model.JournalArticle">
        <#assign article = renderer.getArticle() >
        <#assign img = article.getSmallImageURL() >
        <p>Image: <img src="${img}"></p>
    <!--#if-->
<!--#list-->
Muhammad Umer Zubair, módosítva 10 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

New Member Bejegyzések: 18 Csatlakozás dátuma: 2014.01.01. Legújabb bejegyzések
Hi,

Thanks for the prompt solution. It really helped me to get the required results.
Miguel Ángel Figueora, módosítva 9 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

New Member Bejegyzés: 1 Csatlakozás dátuma: 2014.05.21. Legújabb bejegyzések
Hi, I'm stating with Liferay (6.2), I'm trying to do the same but in the version I'm using I have Blogs (com.liferay.portlet.blogs.model.BlogsEntry) instead of Journal and I can't access to smallImage using your code (getArticle fails). Could you help me please?

Thanks in advance.
Miguel
thumbnail
Frederik Voordeckers, módosítva 9 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

New Member Bejegyzések: 2 Csatlakozás dátuma: 2014.03.20. Legújabb bejegyzések
Miguel Ángel Figueora:
Hi, I'm stating with Liferay (6.2), I'm trying to do the same but in the version I'm using I have Blogs (com.liferay.portlet.blogs.model.BlogsEntry) instead of Journal and I can't access to smallImage using your code (getArticle fails). Could you help me please?

Thanks in advance.
Miguel


If you are using the BlogEntry, you won't need to get the article.
If you look at the docs you'll see you can accomplish this with the code below:

#if (!$entries.isEmpty())
    #foreach ($curEntry in $entries)
        Title: $curEntry.title<br>
        Description: $curEntry.description <br>      
        #if($curEntry.smallImage)
            <br>
            Image: <img src="$curEntry.getEntryImageURL($themeDisplay)"> <br>
        #end
        <hr>
    #end
#end
Klaus Bachmaier, módosítva 9 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

Regular Member Bejegyzések: 223 Csatlakozás dátuma: 2013.09.30. Legújabb bejegyzések
I created a small ADT just for testing purposes with exactly the code James mentioned above, but I can't get the small Image URL's for my Articles this way.

"img" always returns an empty String when doing this:

&lt;#assign img = article.getSmallImageURL() &gt;


Of course my Articles all have small Images applied, and other method calls on the article Object like i.e. "article.getDecription()" are working fine. I'm on 6.2 EE SP8
thumbnail
Andew Jardine, módosítva 9 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

Liferay Legend Bejegyzések: 2416 Csatlakozás dátuma: 2010.12.22. Legújabb bejegyzések
Klaus,

Have you tried using the getArticleImageURL( ThemeDisplay themeDisplay ) method instead to see what that returns?
Klaus Bachmaier, módosítva 9 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

Regular Member Bejegyzések: 223 Csatlakozás dátuma: 2013.09.30. Legújabb bejegyzések
Jep! That did the trick! Thanks a lot Andrew.


&lt;#list entries as entry&gt;
	&lt;#assign entry = entry /&gt;
    &lt;#assign assetRenderer = entry.getAssetRenderer() /&gt;
    &lt;#assign journalArticle = assetRenderer.getArticle() /&gt;
    &lt;#assign img = journalArticle.getArticleImageURL(themeDisplay) /&gt;


Anyway, I'm courious why .getSmallImageURL() didn't work.
thumbnail
s s, módosítva 8 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

Junior Member Bejegyzések: 28 Csatlakozás dátuma: 2010.01.29. Legújabb bejegyzések
Hi, I found the answer to this one - Klaus question (using hints in this thread). getSmallImageURL does work, however in the article abstract the content-creator can specify either a Small Image URL or a Small Image (directly). The getSmallImage returns a true or false. The following code determines which is in use an sets a variable to it.
&lt;#if aArticle.getSmallImage()&gt;
     &lt;#assign aSmallImgURL = aArticle.getArticleImageURL(themeDisplay)&gt;
 &lt;#else&gt;
      &lt;#assign aSmallImgURL = aArticle.getSmallImageURL()&gt;
<!--#if-->
Duong Nguyen, módosítva 7 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

New Member Bejegyzés: 1 Csatlakozás dátuma: 2016.11.29. Legújabb bejegyzések
Klaus Bachmaier:
I created a small ADT just for testing purposes with exactly the code James mentioned above, but I can't get the small Image URL's for my Articles this way.

"img" always returns an empty String when doing this:

&lt;#assign img = article.getSmallImageURL() &gt;


Of course my Articles all have small Images applied, and other method calls on the article Object like i.e. "article.getDecription()" are working fine. I'm on 6.2 EE SP8



Exactly, the same, i saw in db, smallImgUrl in journalArticle always empty, even it's have imgId. What wrong with me ?
sagar aher, módosítva 7 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

New Member Bejegyzések: 3 Csatlakozás dátuma: 2015.10.01. Legújabb bejegyzések
Frederik Voordeckers:
Miguel Ángel Figueora:
Hi, I'm stating with Liferay (6.2), I'm trying to do the same but in the version I'm using I have Blogs (com.liferay.portlet.blogs.model.BlogsEntry) instead of Journal and I can't access to smallImage using your code (getArticle fails). Could you help me please?

Thanks in advance.
Miguel


If you are using the BlogEntry, you won't need to get the article.
If you look at the docs you'll see you can accomplish this with the code below:

#if (!$entries.isEmpty())
    #foreach ($curEntry in $entries)
        Title: $curEntry.title<br>
        Description: $curEntry.description <br>      
        #if($curEntry.smallImage)
            <br>
            Image: <img src="$curEntry.getEntryImageURL($themeDisplay)"> <br>
        #end
        <hr>
    #end
#end




Hi Frederik,

i have tried your code.
Its showing title and description correctly but image is not appearing even though its added in abstract while creating blog.

Please help.
thumbnail
gnp present, módosítva 6 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

Junior Member Bejegyzések: 54 Csatlakozás dátuma: 2010.06.09. Legújabb bejegyzések
hello..

How get small image url ( freemarker) in ADT for Liferay 7 GA 4? also how can import to ADT ( freemarker ) custom fields from structure article?

thx
shima shima, módosítva 9 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

Junior Member Bejegyzések: 46 Csatlakozás dátuma: 2014.04.14. Legújabb bejegyzések
Hi
thank u ,it is very usefulemoticon , now I want to have a default image so if the user do not upload any image in abstract , the default will be shown . would u please guide me?
thumbnail
James Falkner, módosítva 9 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

Liferay Legend Bejegyzések: 1399 Csatlakozás dátuma: 2010.09.17. Legújabb bejegyzések
shima shima:
Hi
thank u ,it is very usefulemoticon , now I want to have a default image so if the user do not upload any image in abstract , the default will be shown . would u please guide me?


Just add an "if/else" clause in your script, to show the small image if it is not null, otherwise show some other image (you could upload the image to the document library, then use that URL as your 'default' image).
thumbnail
Shashikant Sharma, módosítva 9 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

New Member Bejegyzések: 7 Csatlakozás dátuma: 2013.08.16. Legújabb bejegyzések
hi,

I am trying to do the same thing but using VM.
Below is the detailed code...

#if (!$entries.isEmpty())
     #foreach ($curEntry in $entries)
         #set($renderer = $curEntry.getAssetRenderer() )
         #set($className = $renderer.getClassName() )
         
         #if( $className == "com.liferay.portlet.journal.model.JournalArticle" )
    
            #set( $Article = $renderer.getArticle() )
            #set( $image = $Article.getSmallImageURL()  )
            Title: $curEntry.getTitle($locale)<br>
            Summary: $renderer.getSummary($locale) <br>
            Views: $curEntry.getViewCount()<br>      
            Image: <img src="$image"> <br>
            <hr>
        #end
    #end
#end


$image is returning Blank.

Pls help...
thumbnail
selam Aweke selam, módosítva 9 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

Junior Member Bejegyzések: 60 Csatlakozás dátuma: 2012.11.14. Legújabb bejegyzések
Hi James Falkner, or any other that can help me this question. I have one question , how can I display document library image thumbnail using ADT.

To make it clear as it is known it is possible to display document library information like image, video by using asset publisher like its abstract, title , etc. But I want to have my own ADT (template) that displays document library information like title, video thumbnail like that of the default abstract. pls help me
thumbnail
James Falkner, módosítva 9 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

Liferay Legend Bejegyzések: 1399 Csatlakozás dátuma: 2010.09.17. Legújabb bejegyzések
selam Aweke selam:
Hi James Falkner, or any other that can help me this question. I have one question , how can I display document library image thumbnail using ADT.

To make it clear as it is known it is possible to display document library information like image, video by using asset publisher like its abstract, title , etc. But I want to have my own ADT (template) that displays document library information like title, video thumbnail like that of the default abstract. pls help me


selam! Welcome to our community. you should read Juan's excellent Rich Summary for Asset Publisher wiki, but here's a cheat sheet:


&lt;#if entries?has_content&gt;
  &lt;#list entries as entry&gt;

    &lt;#assign assetRenderer = entry.getAssetRenderer() /&gt;

    &lt;#assign viewURL = assetPublisherHelper.getAssetViewURL(renderRequest, renderResponse, entry) /&gt;

    &lt;#if assetLinkBehavior != "showFullContent"&gt;
      &lt;#assign viewURL = assetRenderer.getURLViewInContext(renderRequest, renderResponse, viewURL) /&gt;
    <!--#if-->

  <a href="${viewURL}">
	  <img src="${assetRenderer.getThumbnailPath(renderRequest)}">
  </a>

  <!--#list-->
<!--#if-->
thumbnail
selam Aweke selam, módosítva 8 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

Junior Member Bejegyzések: 60 Csatlakozás dátuma: 2012.11.14. Legújabb bejegyzések
James Falkner:
selam Aweke selam:
Hi James Falkner, or any other that can help me this question. I have one question , how can I display document library image thumbnail using ADT.

To make it clear as it is known it is possible to display document library information like image, video by using asset publisher like its abstract, title , etc. But I want to have my own ADT (template) that displays document library information like title, video thumbnail like that of the default abstract. pls help me


selam! Welcome to our community. you should read Juan's excellent Rich Summary for Asset Publisher wiki, but here's a cheat sheet:


&lt;#if entries?has_content&gt;
  &lt;#list entries as entry&gt;

    &lt;#assign assetRenderer = entry.getAssetRenderer() /&gt;

    &lt;#assign viewURL = assetPublisherHelper.getAssetViewURL(renderRequest, renderResponse, entry) /&gt;

    &lt;#if assetLinkBehavior != "showFullContent"&gt;
      &lt;#assign viewURL = assetRenderer.getURLViewInContext(renderRequest, renderResponse, viewURL) /&gt;
    <!--#if-->

  <a href="${viewURL}">
	  <img src="${assetRenderer.getThumbnailPath(renderRequest)}">
  </a>

  <!--#list-->
<!--#if-->



thank you in advance James, It worked fine for me.
thumbnail
selam Aweke selam, módosítva 8 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

Junior Member Bejegyzések: 60 Csatlakozás dátuma: 2012.11.14. Legújabb bejegyzések
thank you James, the ADT template code works fine. thank you in advance again
thumbnail
James Falkner, módosítva 8 év-val korábban

Thread Split

Liferay Legend Bejegyzések: 1399 Csatlakozás dátuma: 2010.09.17. Legújabb bejegyzések
You should not ask two different questions in the same thread emoticon I have spit this into a separate thread, please in the future start a new thread for unrelated questions. Thanks!

The new thread can be found at https://www.liferay.com/community/forums/-/message_boards/view_message/51998044.
sagar aher, módosítva 7 év-val korábban

RE: Application Dispaly Templates Code for Getting Article Small Image Id

New Member Bejegyzések: 3 Csatlakozás dátuma: 2015.10.01. Legújabb bejegyzések
Hi all,

I have tried every method form this post mentioned below but no luck.
I dont know if am doing smthing wrong.

not able to retrieve small image or URL.
but if i hardcode image id with URL - "/image/image_gallery?img_id=1479906070688" it appears on page.

Please help me to get small image from blog.
here is my code --


#set($lcaselocale = $locale.toString().toLowerCase())
#set($cnt=0)
#if (!$entries.isEmpty())
#set($blogsAvailable = "no")
<section class="portlet" id="portlet_84">
<header class="portlet-topper">
<h1 class="portlet-title">
<span class="" onmouseover="Liferay.Portal.ToolTip.show(this, 'Announcements')">
<span class="taglib-text hide-accessible">Recent Blog Posts</span>
</span>
<span class="portlet-title-text"><small>Recent Blog Posts</small></span>
</h1>
</header>
<div class="portlet-content">
<div class=" portlet-content-container" style="">
<div class="portlet-body">
<ul class="blogPost">
#foreach ($curEntry in $entries)
#set ($UserLocalService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($MBMesaggeLocalService = $serviceLocator.findService("com.liferay.portlet.messageboards.service.MBMessageLocalService"))
#set($cnt = $cnt + 1)
#if($cnt <= 4 )
#set($renderer = $curEntry.getAssetRenderer() )
#set($className = $renderer.getClassName() )
#if( $className == "com.liferay.portlet.blogs.model.BlogsEntry" )
#set( $blogsEntry = $renderer.getArticle() )
#set( $document = $saxReaderUtil.read($blogsEntry.getContent()) )
#set( $rootElement = $document.getRootElement() )
#set( $link = $renderer.getURLViewInContext($renderRequest, $renderResponse, '') )
#set($blogUser = $UserLocalService.getUser($curEntry.userId))
#set($aSmallImgURL = $blogsEntry.getSmallImageURL())
<li>
<div class="blogPic"><img src="$blogUser.getPortraitURL($themeDisplay)"/>
<img src="/image/image_gallery?img_id=$aSmallImgURL"/>
<img src="$aSmallImgURL"/>
</div>
<div class="blogTitle"><a href="$link">$curEntry.getTitle($locale)</a></div>
<div class="blogAuthor">$curEntry.getUserName()</div>
<div class="blogText">$curEntry.description</div>
</li>
#end
#end
#end
</ul>
</div>
</div>
</div>
</section>
#end