掲示板

Application Dispaly Templates Code for Getting Article Small Image Id

10年前 に Muhammad Umer Zubair によって更新されました。

Application Dispaly Templates Code for Getting Article Small Image Id

New Member 投稿: 18 参加年月日: 14/01/01 最新の投稿
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
10年前 に James Falkner によって更新されました。

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

Liferay Legend 投稿: 1399 参加年月日: 10/09/17 最新の投稿
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-->
10年前 に Muhammad Umer Zubair によって更新されました。

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

New Member 投稿: 18 参加年月日: 14/01/01 最新の投稿
Hi,

Thanks for the prompt solution. It really helped me to get the required results.
9年前 に Miguel Ángel Figueora によって更新されました。

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

New Member 投稿: 1 参加年月日: 14/05/21 最新の投稿
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
9年前 に Frederik Voordeckers によって更新されました。

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

New Member 投稿: 2 参加年月日: 14/03/20 最新の投稿
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
9年前 に Klaus Bachmaier によって更新されました。

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

Regular Member 投稿: 223 参加年月日: 13/09/30 最新の投稿
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
9年前 に Andew Jardine によって更新されました。

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

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Klaus,

Have you tried using the getArticleImageURL( ThemeDisplay themeDisplay ) method instead to see what that returns?
9年前 に Klaus Bachmaier によって更新されました。

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

Regular Member 投稿: 223 参加年月日: 13/09/30 最新の投稿
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
8年前 に s s によって更新されました。

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

Junior Member 投稿: 28 参加年月日: 10/01/29 最新の投稿
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-->
7年前 に Duong Nguyen によって更新されました。

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

New Member 投稿: 1 参加年月日: 16/11/29 最新の投稿
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 ?
7年前 に sagar aher によって更新されました。

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

New Member 投稿: 3 参加年月日: 15/10/01 最新の投稿
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
6年前 に gnp present によって更新されました。

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

Junior Member 投稿: 54 参加年月日: 10/06/09 最新の投稿
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
9年前 に shima shima によって更新されました。

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

Junior Member 投稿: 46 参加年月日: 14/04/14 最新の投稿
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
9年前 に James Falkner によって更新されました。

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

Liferay Legend 投稿: 1399 参加年月日: 10/09/17 最新の投稿
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
9年前 に Shashikant Sharma によって更新されました。

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

New Member 投稿: 7 参加年月日: 13/08/16 最新の投稿
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
9年前 に selam Aweke selam によって更新されました。

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

Junior Member 投稿: 60 参加年月日: 12/11/14 最新の投稿
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
9年前 に James Falkner によって更新されました。

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

Liferay Legend 投稿: 1399 参加年月日: 10/09/17 最新の投稿
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
8年前 に selam Aweke selam によって更新されました。

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

Junior Member 投稿: 60 参加年月日: 12/11/14 最新の投稿
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
8年前 に selam Aweke selam によって更新されました。

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

Junior Member 投稿: 60 参加年月日: 12/11/14 最新の投稿
thank you James, the ADT template code works fine. thank you in advance again
thumbnail
8年前 に James Falkner によって更新されました。

Thread Split

Liferay Legend 投稿: 1399 参加年月日: 10/09/17 最新の投稿
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.
7年前 に sagar aher によって更新されました。

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

New Member 投稿: 3 参加年月日: 15/10/01 最新の投稿
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