CRM Open Source Business & Social CRM Software

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: HOW TO: Override a Template

  1. #1
    luisfdo's Avatar
    luisfdo is offline Member
    Join Date
    Apr 2008
    Posts
    8

    Default HOW TO: Override a Template

    Overriding a template from detailview, listview or editview:

    1. Create a directory called /modules/<YOUR_MODULE>/views

    2. Create the file /modules/<YOUR_MODULE>/views/view.list.php
    You can change list to detail or edit, to another view.

    3. Put the following code on view.list.php

    PHP Code:
    <?php
        
    require_once('include/MVC/View/views/view.list.php');

        class <
    YOUR_MODULE>ViewList extends ViewList{    
        function <
    YOUR_MODULE>ViewList(){        
            
    parent::ViewList();    
        }
            function 
    display(){
                    
    parent::display();
            }
            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){
                
    //here we are overriding with your custom template, in my case I just modified ListViewGeneric.
                            
    $this->lv->setup($this->seed'custom/modules/<YOUR_MODULE>/tpls/ListViewGeneric.tpl'$this->where$this->params);
                
    $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' $_REQUEST['saved_search_select_name']);
                echo 
    get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName''false);
                echo 
    $this->lv->display();
            }
         } 

    ?>
    4. Create a file ListViewGeneric.tpl in /custom/modules/<YOUR_MODULE>/tpls.
    You can copy the original template from /include/ListView/ListViewGeneric.tpl
    Here you can modified the template in many ways.


    Enjoy it.

  2. #2
    genius786's Avatar
    genius786 is offline Sugar Community Member
    Join Date
    Nov 2008
    Location
    Karachi, Pakistan
    Posts
    119

    Smile Re: HOW TO: Override a Template

    Hi,

    A great description you provided which is very helpful to me.


    Best regards,
    SARFARAZ AHMED KHAN
    Karachi, Pakistan
    skype: genius_crystal
    genius_crystal@hotmail.com
    92-314-2595624

  3. #3
    monicaDC is offline Sugar Community Member
    Join Date
    Feb 2009
    Posts
    175

    Default Re: HOW TO: Override a Template

    this is good stuff!!! Thank you!!

  4. #4
    Qamrun is offline Senior Member
    Join Date
    Mar 2009
    Location
    New Delhi
    Posts
    46

    Smile Re: HOW TO: Override a Template

    Its very helpful.... Thanks a lot

  5. #5
    carlaa is offline Member
    Join Date
    Jul 2009
    Posts
    16

    Default Re: HOW TO: Override a Template

    I follow this tutorial but nothing change, my list is showing no itens

    there is a similar way to change a subpanel 's template ?

  6. #6
    notestopies is offline Member
    Join Date
    Jul 2009
    Posts
    10

    Default Re: HOW TO: Override a Template

    hi all,
    thanks a lot luisfdo's Avatar luisfdo!
    I could create customized temlate as per instructions.

    Now, my need is to disable checkbox in listview. Does anyone how to display 'checked n disabled' checkbox based on condition in ListView?

    i tried this in custom ListViewGeneric.tpl

    changed

    <input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='{$rowData.ID}'>

    to

    <input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='{$rowData.ID}' checked disabled>

    result: App is displaying checked n disabled chekbox for a while and again app is reverting back to unchecked enabled checkbox. WHY?

    regards,
    prashant.y
    Last edited by notestopies; 2009-08-23 at 04:15 AM.

  7. #7
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: HOW TO: Override a Template

    If you are doing this tutorial, always check for an existing override in modules/<module>/views/view.list.php. If there is one, use that one instead of the code above.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  8. #8
    Rom_ is offline Member
    Join Date
    Sep 2009
    Posts
    7

    Default Re: HOW TO: Override a Template

    Quote Originally Posted by luisfdo View Post
    3. Put the following code on view.list.php

    PHP Code:
    <?php
        
    require_once('include/MVC/View/views/view.list.php');

        class <
    YOUR_MODULE>ViewList extends ViewList{    
        function <
    YOUR_MODULE>ViewList(){        
            
    parent::ViewList();    
        }
            function 
    display(){
                    
    parent::display();
            }
            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){
                
    //here we are overriding with your custom template, in my case I just modified ListViewGeneric.
                            
    $this->lv->setup($this->seed'custom/modules/<YOUR_MODULE>/tpls/ListViewGeneric.tpl'$this->where$this->params);
                
    $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' $_REQUEST['saved_search_select_name']);
                echo 
    get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName''false);
                echo 
    $this->lv->display();
            }
         } 

    ?>
    Someone can give me the code PHP for detail view and edit detail please ?

  9. #9
    cchiu is offline Senior Member
    Join Date
    Feb 2009
    Posts
    56

    Default Re: HOW TO: Override a Template

    can anyone answer this? how do you do it for detail or edit?

  10. #10
    Join Date
    Jun 2010
    Posts
    10

    Default Re: HOW TO: Override a Template

    Thanks for sharing the description .I solved my problem that way
    Techstore for all your Website Design and Online Marketing needs

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. I want to override SugarObjects
    By SugarDev.net in forum Developer Help
    Replies: 7
    Last Post: 2010-11-23, 03:45 AM
  2. listview override help
    By marketadvantage in forum Developer Help
    Replies: 1
    Last Post: 2008-08-22, 08:31 PM
  3. Override files -version5.0.0
    By vsaranya in forum General Discussion
    Replies: 1
    Last Post: 2008-01-24, 08:59 AM
  4. Override files
    By vsaranya in forum Developer Help
    Replies: 0
    Last Post: 2008-01-24, 07:26 AM
  5. Override functionality
    By florent in forum Help
    Replies: 0
    Last Post: 2005-03-23, 05:35 PM

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
  •