Results 1 to 2 of 2

Thread: Using functions in vardefs

  1. #1
    wyred is offline Sugar Community Member
    Join Date
    Mar 2005
    Posts
    56

    Default Using functions in vardefs

    Hi,

    I'm trying to use functions in vardefs to retrieve values for a custom module. The reference I used comes from the vardefs.php pdf documentation.

    Following is what I've added:

    vardefs.php:
    PHP Code:
    'num_rooms' => array(
        
    'source'=>'function',
        
    'function_name'=>'get_num_rooms',
        
    'function_class'=>'Property',
        
    'function_params'=> array('id'),
        
    'function_params_source'=>'this',
        
    'type'=>'function',
        
    'name'=>'num_rooms',
    ), 
    property.php:
    PHP Code:
    function get_num_rooms($property) {
        
    $db = &PearDatabase::getInstance();
        
    $query "SELECT SUM(num_rooms) as sum_num_rooms FROM properties_roomtypes WHERE fldProperty='$property'";
        
    $result $db->query($query);
        
    $row $db->fetchByAssoc($result);
        if (
    $row != null) return $row['sum_num_rooms'];

    listview.html
    PHP Code:
    <td scope='row' valign=TOP class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}"><slot>{PROPERTY.NUM_ROOMS}</slot></td

    What other files do I need to make modifications in order to get it to work?

  2. #2
    wyred is offline Sugar Community Member
    Join Date
    Mar 2005
    Posts
    56

    Default Re: Using functions in vardefs

    Ok, I found out that functions in vardefs work only for subpanels and not "listview.php"s.

Thread Information

Users Browsing this Thread

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

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
  •