Best way to extend .tpl file for a custom ListView?

you’re right, i don’t even know why i assumed that that’s the file I’ll need to change. I wanted to change how the URLs are displayed inside a given list view.

Solution was to create a new bean in the custom/modules folder, extend the original bean class from the /modules folder and override the get_list_view_data() method

    require_once("modules/strg_storage/strg_storage.php");

    // Extend the original class found in the require_once()
    class strg_storage_c extends strg_storage //
    {

        function get_list_view_data(){

            // Get the default output
            $temp_array = parent::get_list_view_data();

            // Build up the custom link
            $temp_array['NAME']  =  '<a href=\'index.php';
            $temp_array['NAME'] .= '?module=strg_storage';
            $temp_array['NAME'] .= '&action=AssignstoragetoinventoryEdit';
            $temp_array['NAME'] .= '&return_module=strg_storage';
            $temp_array['NAME'] .= '&return_action=DetailView';
            $temp_array['NAME'] .= '&record='.$this->id;
            $temp_array['NAME'] .= '&inventory_unit_id='.$_REQUEST['un_inventory_id'];
            $temp_array['NAME'] .= '&storage_unit_id='.$this->id;
            $temp_array['NAME'] .= '\'>';
            $temp_array['NAME'] .= $this->name;
            $temp_array['NAME'] .= '</a>';

            return $temp_array;
        }


    }

Then I created a custom listview and then in controller.php I registered that custom listview (showprojectunitslis) and pointed to the custom bean class which overrides the get_list_view_data() when that view is fired up

Like so:


<?php

// The custom bean file that we created above
require_once("custom/modules/strg_storage/strg_storage_c.php");

class strg_storageController extends SugarController
{

    // If this custom action is called then instantiate our custom bean in /custom/modules/strg_storage/strg_storage_c.php so it can override how the URLs are displayed inside the custom listview
    public function action_showprojectunitslist() {

        // Register the custom action
        $this->view = 'showprojectunitslist';

        // Assign the custom bean
        $this->bean = new strg_storage_c();


    }

Anyways, yeah. Really didn’t need to extend the .tpl file

1 Like