Foren

Application Dispaly Templates Code for Getting Article Small Image Id

Muhammad Umer Zubair, geändert vor 10 Jahren.

Application Dispaly Templates Code for Getting Article Small Image Id

New Member Beiträge: 18 Beitrittsdatum: 01.01.14 Neueste Beiträge
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, geändert vor 10 Jahren.

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

Liferay Legend Beiträge: 1399 Beitrittsdatum: 17.09.10 Neueste Beiträge
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, geändert vor 10 Jahren.

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

New Member Beiträge: 18 Beitrittsdatum: 01.01.14 Neueste Beiträge
Hi,

Thanks for the prompt solution. It really helped me to get the required results.
Miguel Ángel Figueora, geändert vor 9 Jahren.

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

New Member Beitrag: 1 Beitrittsdatum: 21.05.14 Neueste Beiträge
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, geändert vor 9 Jahren.

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

New Member Beiträge: 2 Beitrittsdatum: 20.03.14 Neueste Beiträge
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, geändert vor 9 Jahren.

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

Regular Member Beiträge: 223 Beitrittsdatum: 30.09.13 Neueste Beiträge
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, geändert vor 9 Jahren.

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

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Klaus,

Have you tried using the getArticleImageURL( ThemeDisplay themeDisplay ) method instead to see what that returns?
Klaus Bachmaier, geändert vor 9 Jahren.

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

Regular Member Beiträge: 223 Beitrittsdatum: 30.09.13 Neueste Beiträge
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, geändert vor 8 Jahren.

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

Junior Member Beiträge: 28 Beitrittsdatum: 29.01.10 Neueste Beiträge
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, geändert vor 7 Jahren.

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

New Member Beitrag: 1 Beitrittsdatum: 29.11.16 Neueste Beiträge
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, geändert vor 7 Jahren.

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

New Member Beiträge: 3 Beitrittsdatum: 01.10.15 Neueste Beiträge
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, geändert vor 6 Jahren.

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

Junior Member Beiträge: 54 Beitrittsdatum: 09.06.10 Neueste Beiträge
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, geändert vor 9 Jahren.

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

Junior Member Beiträge: 46 Beitrittsdatum: 14.04.14 Neueste Beiträge
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, geändert vor 9 Jahren.

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

Liferay Legend Beiträge: 1399 Beitrittsdatum: 17.09.10 Neueste Beiträge
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, geändert vor 9 Jahren.

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

New Member Beiträge: 7 Beitrittsdatum: 16.08.13 Neueste Beiträge
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, geändert vor 9 Jahren.

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

Junior Member Beiträge: 60 Beitrittsdatum: 14.11.12 Neueste Beiträge
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, geändert vor 9 Jahren.

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

Liferay Legend Beiträge: 1399 Beitrittsdatum: 17.09.10 Neueste Beiträge
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, geändert vor 9 Jahren.

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

Junior Member Beiträge: 60 Beitrittsdatum: 14.11.12 Neueste Beiträge
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, geändert vor 9 Jahren.

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

Junior Member Beiträge: 60 Beitrittsdatum: 14.11.12 Neueste Beiträge
thank you James, the ADT template code works fine. thank you in advance again
thumbnail
James Falkner, geändert vor 9 Jahren.

Thread Split

Liferay Legend Beiträge: 1399 Beitrittsdatum: 17.09.10 Neueste Beiträge
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, geändert vor 7 Jahren.

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

New Member Beiträge: 3 Beitrittsdatum: 01.10.15 Neueste Beiträge
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