Go Back   Mosets Community > Archives > Mosets Hot Property 1.0 > Discussions, Troubleshooting and Problems

 
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-12-2010, 05:16 PM
dknight dknight is offline
Mosets Team - Lead Developer
 
Join Date: Dec 2004
Posts: 25,851
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.
  #2  
Old 02-12-2010, 10:12 PM
kathrynjsykes kathrynjsykes is offline
Mosets'd
 
Join Date: Feb 2010
Posts: 1
Default

can you tell me how can i get the price from the "Price" field (or target any specific field for that matter) because i'd like to put the actual price as part of the title on the property page?

no doubt you've explained it above but my php skill is rubbish!

thanks beforehand
  #3  
Old 02-14-2010, 04:03 AM
zandunga zandunga is offline
Member
 
Join Date: Dec 2009
Posts: 31
Default

In Joomlamotor.com are making efforts to minimize disruptions to the core of Hot Property for easy deployment.

A notable example of our achievements is represented by the Super Slide Listing, which substantially affects a single file, and alter a line of code in 7 files more.

Our method for synthesizing the previous example is limited to just one line of code:
PHP Code:
<?php echo $this->row->extrafieldname ;//name, address, price,etc. ?>
Taking data output to minimum epresentation to facilitate the design of templates for Hot Property is only possible thanks to the robust program platform of Hot Property, we must be grateful to Mr. Lee.

Last edited by zandunga; 02-15-2010 at 01:00 AM. Reason: best representation
  #4  
Old 03-22-2010, 03:15 AM
-TS- -TS- is offline
Mosets'd
 
Join Date: Jan 2007
Posts: 16
Default

Thanks dknight,

How can i access to core fields? this method allows only extrafields..

edit:
forget it, i found a way..

br
-TS-

Last edited by -TS-; 03-22-2010 at 04:53 AM.
  #5  
Old 03-22-2010, 05:22 PM
giuseppemorea giuseppemorea is offline
Mosets'd
 
Join Date: Jul 2009
Posts: 69
Default

TS, would you kindly tell us which way?
  #6  
Old 03-22-2010, 06:12 PM
-TS- -TS- is offline
Mosets'd
 
Join Date: Jan 2007
Posts: 16
Default

Quote:
Originally Posted by giuseppemorea View Post
TS, would you kindly tell us which way?
Zandunga wrote:
PHP Code:
<?php echo $this->row->corefieldname ;//name, address, price,etc. ?>
LOL, i didn't even notice that code above, i tried all kind of stuff and ended same code:-)
  #7  
Old 04-08-2010, 11:06 PM
jessevandersteur jessevandersteur is offline
Mosets'd
 
Join Date: Feb 2010
Posts: 33
Default

This is very useful, but as stated above my php skill is rubbish too. Can you please give a example how to call a core field like price and an extra field like swimmingpool.

I understand the codes above but I dont have an idea how to put them to use

Hope I'm gonna understand one day.
  #8  
Old 04-10-2010, 01:37 AM
-TS- -TS- is offline
Mosets'd
 
Join Date: Jan 2007
Posts: 16
Default

well, what i have done, and i'm no saying that this is the right way to do things, is as follows:

as dknight stated earlier, place following code at the top of file property.php in folder
components\com_hotproperty\views\properties\tmpl\
(i've added one line more to get also the extrafield captions)

PHP Code:
?>
    <?php foreach ($this->extrafields as $extrafield) :
        foreach (
$this->row->PropertyField as $pf) : 
            if( 
$extrafield->id == $pf->field ) :
                
$fields->{$extrafield->name} = $pf->value;
                
$fieldcaption->{$extrafield->name} = $extrafield->caption;
                break;
            endif;
        endforeach;
    endforeach;
?>
Then in the same file, if you want to display extrafield called swimmingpool (swimmingpool is the field name of that extrafield) and caption for that you do as follows:

PHP Code:
<?php echo $fieldcaption->swimmingpool;
    echo 
$fields->swimmingpool;
?>
and almost same goes for corefield, but you do it like follows:

PHP Code:
<?php echo $this->row->price ?>
and you get corefield value called price.

Hope this helps you :-)
  #9  
Old 04-11-2010, 08:24 AM
williamborque williamborque is offline
Mosets'd
 
Join Date: Mar 2010
Posts: 23
Default Property Listing Page

Lee,

Does this apply to the property listing page. I used your suggestions and received an error with the foreach syntax and also the fields did not show anything when I changes the PHP code.

If you need any additional details, please let me know as I am trying to wrap up a project this week.

Thank You,
Bill Borque, MBA
Owner, Creative Director
Zonegig Design, LLC
www.zonegig.com
  #10  
Old 04-13-2010, 07:13 PM
dknight dknight is offline
Mosets Team - Lead Developer
 
Join Date: Dec 2004
Posts: 25,851
Default

I've added additional note in my original thread on a variation of the codes usable on _summary.php.
__________________
Lee
Lead Developer
Mosets.com - Quality Joomla! Solutions
  #11  
Old 08-30-2010, 11:50 PM
williamdswanepoel williamdswanepoel is offline
Mosets'd
 
Join Date: Aug 2010
Posts: 28
Default Only shows a number and not name ?

Hi

I have inserted the code and it works nicely with the Price but I would like to use the type option as well so I insert the following code:

Code:
<?php echo $this->row->type ?>
Within my type field there are options like Residential, Commercial etc.
But on my page it only displays the ID field. So I only get a 1 for Residential and 2 for Commercial, how do I display the name.

Secondly I also noticed that in the normal attributes section in the property.php page when it loads on explorer, the fields like type and company are blue as they are links that link to the Residential section or to that specific company. Does this happen automatically or how do I create this.

Thank You
  #12  
Old 08-31-2010, 05:27 AM
williamdswanepoel williamdswanepoel is offline
Mosets'd
 
Join Date: Aug 2010
Posts: 28
Default Progress but not finished yet!

I have changed the code to insert the HP core "type" field as follows:

Code:
<?php echo MosetsHTML::_('link', 2, MosetsHTML::_('link', JRoute::_(MosetsRoute::getLink('hotproperty', array('view' => 'types', 'layout' => 'properties', 'id' => $this->row->Agent->id))), $this->escape($this->row->Agent->name)), $this->row->Agent->name); ?>
This does show a link on my page and when I click on the link it goes to the correct place, but the links name is incorrect. Currently it shows an "agents" name as the link and not the "type" name.

I changed the code as follows but then the link totally disapears:

Code:
<?php echo MosetsHTML::_('link', 2, MosetsHTML::_('link', JRoute::_(MosetsRoute::getLink('hotproperty', array('view' => 'types', 'layout' => 'properties', 'id' => $this->row->type->id))), $this->escape($this->row->type->name)), $this->row->type->name); ?>
Can somebody please help and give a suggestion of what is wrong.
Thanks
  #13  
Old 08-31-2010, 06:16 AM
williamdswanepoel williamdswanepoel is offline
Mosets'd
 
Join Date: Aug 2010
Posts: 28
Default

Ok I figured it out... The code is case sensitive and as follows:

Code:
<?php echo MosetsHTML::_('link', 2, MosetsHTML::_('link', JRoute::_(MosetsRoute::getLink('hotproperty', array('view' => 'types', 'layout' => 'properties', 'id' => $this->row->Type->id))), $this->escape($this->row->Type->name)), $this->row->Type->name); ?>
  #14  
Old 08-31-2010, 06:19 AM
williamdswanepoel williamdswanepoel is offline
Mosets'd
 
Join Date: Aug 2010
Posts: 28
Default How to insert individual field but must be skipped if empty?

Hi. I am inserting the individual fields, but if the field has no value what code must I use to skip that field, or any other empty fields that follow ?

Please Help
Thanks
  #15  
Old 08-31-2010, 01:31 PM
gray gray is offline
Mosets'd
 
Join Date: Apr 2006
Posts: 901
Default

Quote:
Originally Posted by williamdswanepoel View Post
Hi. I am inserting the individual fields, but if the field has no value what code must I use to skip that field, or any other empty fields that follow ?

Please Help
Thanks
It's is controlled in respective tmpl file. For example for property view in views/properties/tmpl/property.php the following code is used in HP1.0
PHP Code:
if (!empty($extrafield_value)) : ?> 
So, empty fields should not be displayed at all.

If you want to control values before they are submitted to tmpl file, use
if(!emtpy($field)) // should be universal
or
if($field > '') // for strings
or
if(count($field) > 0) // for arrays
__________________
4HP: Slideshow Module New!
www.topcomhomes.com
  #16  
Old 09-06-2010, 08:10 PM
williamdswanepoel williamdswanepoel is offline
Mosets'd
 
Join Date: Aug 2010
Posts: 28
Default In more detail?

Hi gray

Thanks for the help, but I am not a expert with PHP. Can you maybe help me a bit more...
You can view my site at: http://square-sites.com/greensquare9...id=2&Itemid=57

I have taken some of the extra fields and hard coded them into my property.php as explained above. All hard coded fields are above the picture on my site.
I don't want those fields to be repeated in the extrafields section below the picture so I need to modify the following code:
Code:
<?php foreach ($this->extrafields as $extrafield) : ?>
        <?php
        $extrafield_value = MosetsHTML::_('hotproperty.content.extrafield', $extrafield, $this->row);
        if (!empty($extrafield_value)) : ?>
            <?php if (!$extrafield->hideCaption && !empty($extrafield->caption)) : ?>
                <dt class="caption <?php echo $extrafield->name; ?>"><?php echo $this->escape($extrafield->iscore ? JText::_($extrafield->caption) : $extrafield->caption); ?></dt>
            <?php endif; ?>
            <dd class="value <?php echo $extrafield->name; ?>"><?php echo $extrafield_value; ?></dd>
        <?php endif; ?>
    <?php endforeach; ?>
So that I only call the fields I would like to. Please let me know how I can use your suggestion with this code to only include certain fields.

Thank You.
  #17  
Old 09-07-2010, 01:34 AM
gray gray is offline
Mosets'd
 
Join Date: Apr 2006
Posts: 901
Default

I don't see them repeating in the property details section. Anyway, try this

PHP Code:
    <?php foreach ($this->extrafields as $extrafield) : ?>
        <?php
    
if ($extrafield->name !='NAME1' || $extrafield->name != 'NAME2' || $extrafield->name != 'NAME3'):
        
$extrafield_value MosetsHTML::_('hotproperty.content.extrafield'$extrafield$this->row);
        if (!empty(
$extrafield_value)) : ?>
            <?php if (!$extrafield->hideCaption && !empty($extrafield->caption)) : ?>
                <dt class="caption <?php echo $extrafield->name?>"><?php echo $this->escape($extrafield->iscore JText::_($extrafield->caption) : $extrafield->caption); ?></dt>
            <?php endif; ?>
            <dd class="value <?php echo $extrafield->name?>"><?php echo $extrafield_value?></dd>
        <?php endif; 
            endif; 
?>
    <?php endforeach; ?>
where NAME1, NAME2, NAME3 and so on are the names of fields you'd like to exclude.

Try and see if it helps.
__________________
4HP: Slideshow Module New!
www.topcomhomes.com
  #18  
Old 09-07-2010, 08:30 AM
williamdswanepoel williamdswanepoel is offline
Mosets'd
 
Join Date: Aug 2010
Posts: 28
Default Thanks alot, but one last question?

Hi gray

Thanks for your solution. I did not use your exact solution but used the following to be able to change each field like I wanted to. Code follows:
Code:
<table width="400px">
    <tr width="400px">
        <td width="200px">    
            <?php 
                if (!empty($fields->bedrooms))
                    echo '<b>Bedrooms: </b>' . $fields->bedrooms . '<br />';
            ?>
            <?php 
                if (!empty($fields->bathrooms))
                    echo '<b>Bathrooms: </b>' . $fields->bathrooms . '<br />';
            ?>
            <?php 
                if (!empty($fields->garages))
                    echo '<b>Garages: </b>' . $fields->garages . '<br />';
            ?>
            <?php 
                if (!empty($fields->parkingbay))
                    echo '<b>Parking Bays: </b>' . $fields->parkingbay . '<br />';
            ?>
        </td>
        <td>
            <?php 
                if (!empty($fields->propertysize))
                    echo '<b>Property [Erf] Size: </b>' . $fields->propertysize . 'm&sup2<br />';
            ?>
            <?php 
                if (!empty($fields->buildingareasize))
                    echo '<b>Building Area Size: </b>' . $fields->buildingareasize . 'm&sup2<br />';
            ?>
            <?php 
                if (!empty($fields->levies))
                    echo '<b>Levies: </b>N$ ' . $fields->levies . ' per month<br />';
            ?>
        </td>
    </tr>
</table>
My last question is with _summary.php. I used the same code that I used in property.php that is:
Code:
<?php foreach ($this->extrafields as $extrafield) :
        foreach ($this->row->PropertyField as $pf) : 
            if( $extrafield->id == $pf->field ) :
                $fields->{$extrafield->name} = $pf->value;
                $fieldcaption->{$extrafield->name} = $extrafield->caption;
                break;
            endif;
        endforeach;
    endforeach;
?>
and

Code:
<?php $new_price = number_format ($this->row->price); ?>
            <font color="red">
                <b>Price: N$ <?php echo $new_price; ?></b>
            </font>
            <br />
            <?php
But I keep on getting an error "Warning: Invalid argument supplied for foreach() on line 36.

The Code on line 36 is:
Code:
foreach ($this->row->PropertyField as $pf) :
Why does that line work on property.php but not in _summary.php

Any solution will help. Thanks for all the help so far...
  #19  
Old 09-07-2010, 08:48 AM
williamdswanepoel williamdswanepoel is offline
Mosets'd
 
Join Date: Aug 2010
Posts: 28
Default Changed code for _summary.php

Ok I changed the code in _summary.php to code as recommended at top of thread to:
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; 
?>
But now the price does not show any value? So I guess there must be a problem with getting the price?
Code:
<?php $new_price = number_format ($this->row->price); ?>
             <font color="red">
                 <b>Price: N$ <?php echo $new_price; ?></b>
             </font>
            <br />
          <?php
Looks like none of my core fields are displayed, only my extra fields are displayed. What could be the problem as I also use the following code for the other core field that is not displayed:
Code:
<?php echo $this->row->suburb; ?>
This code works on the property.php page but not on _summary.php.

Thanks
  #20  
Old 09-07-2010, 09:00 AM
williamdswanepoel williamdswanepoel is offline
Mosets'd
 
Join Date: Aug 2010
Posts: 28
Default Ok solved it...

Thanks for all the help, would not have been able to solve this without your help...

I used the following code on _summary.php to show the core fields:
Code:
<?php echo $this->property->suburb; ?>
Thanks again for everything...
  #21  
Old 09-07-2010, 11:00 AM
williamdswanepoel williamdswanepoel is offline
Mosets'd
 
Join Date: Aug 2010
Posts: 28
Default Featured checkbox with several options?

Ok another question, how do I select a specific field inside a checkbox to be displayed?

I used the code:
Code:
<?php 
                if (!empty($fields->features))
                    echo '<b>Features: </b>' . $fields->features . '<br />';
          ?>
But this displays all the checkbox fields that has been ticked. I would like to split them up by adding them one by one so that they can be displayed in a table in two rows.

I tried the following code:
Code:
<?php 
                if (!empty($fields->features->bar))
                    echo '<b>Features: </b>' . $fields->features->bar . '<br />';
          ?>
But this code does not work any suggestions?
  #22  
Old 01-10-2011, 09:26 AM
mariaeadarvemuoz mariaeadarvemuoz is offline
Mosets'd
 
Join Date: Dec 2010
Posts: 13
Default

How can you do the same but for pictures?? im trying to get the same thumbnail shown in the search results in the property details view next to the title??
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help w/XMLThumb Gallery on Property Detail Page timothypsoulen Discussions, Troubleshooting and Problems 5 04-14-2009 11:53 PM


All times are GMT +8. The time now is 06:27 PM.

Copyright © 2005-2010 Mosets Consulting

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.