Results 1 to 6 of 6

Thread: Display images in listview of documents

  1. #1
    sarunas.lazauskas@gmail.com's Avatar
    sarunas.lazauskas@gmail.com is offline Sugar Community Member
    Join Date
    Mar 2011
    Location
    Lithuania
    Posts
    28

    Question Display images in listview of documents

    Hello, is there a way to display image in listview of documents? For example i would like to have image displayed instead of file name. Where the structure of listview can be modified? (but i need it only on documents and it should be upgrade safe). Any ideas, suggestions, advices, examples would be grate. Thanks in advance!

  2. #2
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: Display images in listview of documents

    Hello,

    There seems to be a product bug again. So it turns out to be an unupgrade safe change. Still if you have to go for it, just do it!

    Add following piece of code in your custom/modules/<module_name>/metadata/listviewdefs.php

    PHP Code:
    'FILE_URL' => 
      array (
        
    'width' => '2%',
        
    'label' => '&nbsp;',
        
    'link' => true,
        
    'default' => true,
        
    'related_fields' => 
        array (
          
    => 'document_revision_id',
        ),
        
    'sortable' => false,
        
    'studio' => false,
      ), 
    Then, go to modules/Documents/Document.php and search for word "getImageURL" and add a second argument there like,

    PHP Code:
    getImageURL(strtolower($row['file_ext'])."_image_inline.gif"false
    And then try refreshing the list view. It should work. If you want to have upgrade safe change, customCode is an alternative.
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

  3. #3
    sarunas.lazauskas@gmail.com's Avatar
    sarunas.lazauskas@gmail.com is offline Sugar Community Member
    Join Date
    Mar 2011
    Location
    Lithuania
    Posts
    28

    Lightbulb Re: Display images in listview of documents

    Thanks for reply, this thing is useful, but it provides only download button in listview, i want to show image itself and for that i needed to edit ListView.tpl, i have managed to do what i wanted i have created extension for sugar file field.
    In /custom/include/SugarFields/Fields/File i have created 3 files:

    SugarFieldFile.php
    PHP Code:
    <?php

    require_once('include/SugarFields/Fields/File/SugarFieldFile.php');

    class 
    CustomSugarFieldFile extends SugarFieldFile
    {
        function 
    getDetailViewSmarty($parentFieldArray$vardef$displayParams$tabindex
        {
            
    $displayParams['site_url'] = $GLOBALS['sugar_config']['site_url'];
            
            return 
    parent::getDetailViewSmarty($parentFieldArray$vardef$displayParams$tabindex);
        }
    }
    DetailView.tpl
    PHP Code:
    {{include file="include/SugarFields/Fields/File/DetailView.tpl"}}

    {
    capture assign=fileName}
    {{
    $displayParams.site_url}}/index.php?entryPoint=download&id={$fields.{{$vardef.fileId}}.value}&type={{$vardef.linkModule}}
    {/
    capture}
    <
    div style="float:right">
    <
    img src="{{$displayParams.site_url}}/index.php?entryPoint=download&id={$fields.{{$vardef.fileId}}.value}&type={{$vardef.linkModule}}" style="width:150px;"/>
    </
    div
    ListView.tpl
    PHP Code:
    {*
    /*********************************************************************************
     * SugarCRM Community Edition is a customer relationship management program developed by
     * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
     * 
     * This program is free software; you can redistribute it and/or modify it under
     * the terms of the GNU Affero General Public License version 3 as published by the
     * Free Software Foundation with the addition of the following permission added
     * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
     * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
     * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
     * 
     * This program is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
     * details.
     * 
     * You should have received a copy of the GNU Affero General Public License along with
     * this program; if not, see http://www.gnu.org/licenses or write to the Free
     * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
     * 02110-1301 USA.
     * 
     * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
     * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
     * 
     * The interactive user interfaces in modified source and object code versions
     * of this program must display Appropriate Legal Notices, as required under
     * Section 5 of the GNU Affero General Public License version 3.
     * 
     * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
     * these Appropriate Legal Notices must retain the display of the "Powered by
     * SugarCRM" logo. If the display of the logo is not reasonably feasible for
     * technical reasons, the Appropriate Legal Notices must display the words
     * "Powered by SugarCRM".
     ********************************************************************************/

    *}
    <
    a href="index.php?entryPoint=download&id={$parentFieldArray.ID}&type={$displayParams.module}{$vardef.displayParams.module}" class="tabDetailViewDFLink" target='_blank'>{sugar_fetch object=$parentFieldArray key=$col}
    {if isset(
    $vardef.allowEapm) && $vardef.allowEapm && isset($parentFieldArray.DOC_TYPE) }
    {
    capture name=imageNameCapture assign=imageName}
    {
    sugar_fetch object=$parentFieldArray key=DOC_TYPE}_image_inline.png
    {/capture}
    {
    capture name=imageURLCapture assign=imageURL}
    {
    sugar_getimagepath file=$imageName}
    {/
    capture}
    {if 
    strlen($imageURL)>1}{sugar_getimage name=$imageName alt=$imageName other_attributes='border="0" '}{/if}
    {/if}
    </
    a>
    <
    div style="float:right">
    <
    img src="http://yourcrm.com/index.php?entryPoint=download&id={$parentFieldArray.ID}&type={$displayParams.module}{$vardef.displayParams.module}" style="width:150px;"/>
    </
    div
    These updates adds an image near file field in detailview and in listview, this is probably not the best way to implement it but for now it satisfy me. Just one thing is not right in here i couldnt get site_url dynamically in list view any ideas how to get it?

  4. #4
    phpdon is offline Member
    Join Date
    Dec 2010
    Location
    New delhi ,India
    Posts
    11

    Default Re: Display images in listview of documents

    Hi
    see the below change i have did in a modules

    function listViewProcess(){

    $this->processSearchForm();



    $this->lv->searchColumns = $this->searchForm->searchColumns;
    if(!$this->headers)
    return;
    if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
    $this->lv->ss->assign("SEARCH",true);
    $this->lv->setup($this->seed, 'custom/modules/Project/tpls/ListViewGeneric.tpl', $this->where, $this->params);
    $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
    echo $this->lv->display();
    }
    }


    ///

    You need to change in ListViewGeneric.tpl file

  5. #5
    rafael.q.g@hotmail.com's Avatar
    rafael.q.g@hotmail.com is offline Sugar Community Member
    Join Date
    Jun 2011
    Location
    Florianópolis - Brazil
    Posts
    782

    Default Re: Display images in listview of documents

    Also a very good way to display images on list view is using customCode with '<img src=url?atribute={$fields.field_name.value}>'
    Rafael Queiroz Gonçalves
    Advanced OMG UML Certified Professional
    Sun Certified Enterprise Architect for the Java Platform
    Sun Certified Programmer for the Java 2 Platform
    IBM Certified Advanced Application Developer - Lotus Notes and Domino
    IBM Certified Application Developer - IBM WebSphere Portlet Factory
    Computer Science Mastering / UFSC - PPGCC

  6. #6
    sarunas.lazauskas@gmail.com's Avatar
    sarunas.lazauskas@gmail.com is offline Sugar Community Member
    Join Date
    Mar 2011
    Location
    Lithuania
    Posts
    28

    Default Re: Display images in listview of documents

    Thanks for reply's. Custom code way is also good but then i would need to add custom code in every subpanel file. Well i think this question is solved. Thanks for those who help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Display Gravatar Images on Contacts and Employees
    By bickart68 in forum General Discussion
    Replies: 0
    Last Post: 2011-10-31, 03:58 PM
  2. Display data in listview
    By nimjec101 in forum Developer Help
    Replies: 3
    Last Post: 2010-11-30, 07:45 AM
  3. Wrong display in listview
    By Iggby in forum Help
    Replies: 5
    Last Post: 2009-03-10, 05:19 PM
  4. Only display Listview
    By shyam007 in forum Developer Help
    Replies: 1
    Last Post: 2009-02-13, 03:31 PM
  5. display in listview.
    By sandeeps in forum Developer Help
    Replies: 4
    Last Post: 2008-11-15, 06:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •