View Single Post
  #1  
Old 02-12-2010, 05:16 PM
dknight dknight is online now
Mosets Team - Lead Developer
 
Join Date: Dec 2004
Posts: 26,213
Lightbulb How to: Access individual fields in property page

It's often useful to be able to access individual field's data in property page for customization. Here's a quick how to to achieve this.

Place this code near the top of this file - /components/com_hotproperty/views/properties/tmpl/property.php:
PHP Code:
    <?php foreach ($this->extrafields as $extrafield) : 
        foreach (
$this->row->PropertyField as $pf) : 
            if( 
$extrafield->id == $pf->field ) :
                
$fields->{$extrafield->name} = $pf->value;
                break;
            endif;
        endforeach;
    endforeach;
    
?>
This will store all extra fields in $fields variable. Once you have that snippet in property.php view, you can call any extra field value by using the following:
PHP Code:

<?php echo $fields>extrafieldname?>
To do this in summary level (where you view a list of properties for example), use the following codes at /components/com_hotproperty/views/properties/tmpl/_summary.php
PHP Code:
<?php 
    
foreach ($this->extrafields as $extrafield) :  
        if( isset(
$this->property->PropertyField) ) :
            foreach (
$this->property->PropertyField as $pf) :  
                if( 
$extrafield->id == $pf->field ) : 
                    
$fields->{$extrafield->name} = $pf->value
                    break; 
                endif; 
            endforeach; 
        endif; 
    endforeach; 
?>
__________________
Lee
Lead Developer
Mosets.com - Quality Joomla! Solutions

Last edited by dknight; 04-13-2010 at 07:12 PM.