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

 
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-23-2009, 01:41 PM
dannyd dannyd is offline
Mosets'd
 
Join Date: Oct 2008
Posts: 25
Default display extra fields

I'd like to display extra fields in my template. How can I call certain fields to show up ? I tried the code below but no luck.

/**
* Get extra fields from DB
*/

$sql = "SELECT * FROM jos_hp_properties2 as p2".
"\n LEFT JOIN jos_hp_prop_ef AS ef ON p2.field = ef.id".
"\n WHERE p2.property = '".$f->id."'";
$database->setQuery($sql);
$extrafields = $database->loadObjectList();

foreach ($extrafields as $ef) {
if ($ef->name == "hp_squaremeters") {
$squaremeters = $ef->value;
} else if ($ef->name == "hp_bedrooms") {
$bedrooms = $ef->value;
}
}
  #2  
Old 03-24-2009, 06:50 PM
dknight dknight is offline
Mosets Team - Lead Developer
 
Join Date: Dec 2004
Posts: 26,468
Default

Which file are you using with those codes?
__________________
Lee
Lead Developer
Mosets.com - Quality Joomla! Solutions
  #3  
Old 04-09-2009, 03:16 AM
timothypsoulen timothypsoulen is offline
Mosets'd
 
Join Date: Mar 2009
Posts: 32
Default

I have a similar need to selectively show extra fields in the property detail page. Can I add something like the above code to the default.php property view or is there somewhere else to define these extra field variables so I can call them in the property view?

Thanks!
  #4  
Old 12-01-2009, 10:52 PM
andrewdferguson andrewdferguson is offline
Mosets'd
 
Join Date: Jul 2009
Posts: 109
Default

Did anyone get a satifactory answer to this???
I need to do a price range, and so added an extra field as the upper price limit and want to grab this and display it after PRICE with the word "to" in between. I can get the "to" easily enough, of course, but trying to get the extra field to display is proving nigh on impossible. I I have tried every permeatation I can think of!! Driving me crazy! What the hell are extra fields called? do they have an HP_ added at the beginning of their names or something?

PLEASE help!

Thanks in advance.
  #5  
Old 12-05-2009, 06:02 AM
Padder Padder is offline
Mosets'd
 
Join Date: Jan 2007
Location: England
Posts: 14
Default

Hi,

There's a few ways to do that, I found using a switch the easiest to follow.

In HP1.0RC the file to change is components/com_hotproperty/views/properties/tmpl/property.php.

Comment out lines 40-51 inclusive, this is what you're removing:

Code:
	<dl class="attributes">
	<?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; ?>
	</dl>
Replace with your own version of this code (this just uses example fieldnames, you'll need to have a 'case' for each of your own fieldnames that you are using from your database table):

Code:
<?php
foreach ($this->extrafields as $extrafield) : 

$extrafield_value = MosetsHTML::_('hotproperty.content.extrafield', $extrafield, $this->row);

if (!empty($extrafield_value)) : 

  switch ($extrafield->name) {

  case "type":
        $itemcategory = $extrafield_value;
  break;

  case "quantity":
        $itemquantity = $extrafield_value;
  break;

  case "intro_text":
        $itemtext = $extrafield_value;
  break;

  case "yourfieldname":
        $yourchosenvariablename = $extrafield_value;
  break;
}

endif;

endforeach;

?>
Make sure there is a 'case' for each of your published fields. This routine just puts the hotproperty fields into standard variables, so you can then do what you want with them using normal php/html code, for example in the above code the description text (intro_text field in the database) is put into variable $itemtext, so I would display it like this:

Code:
<?php echo "<p class='description'>" . $itemtext . "</p>"; ?>
Basically once the hotproperty fields have been put into variables then you should find it easy to layout your page as you wish, using tables, divs, or whatever you're most comfortable with.

Hope that helps!
  #6  
Old 03-18-2010, 08:42 PM
jessevandersteur jessevandersteur is offline
Mosets'd
 
Join Date: Feb 2010
Posts: 33
Default

Padder, thank you for the code above.

I know this is a 9 months old thread but I have a question to the post above. This solution is very awesome and works also with the new Hot Property 1.0.0. Makes configuring the lay-out easy.

Only problem with the code above is that the captions won't show, only the values. Does someone know a quick answer to that?
  #7  
Old 03-18-2010, 09:14 PM
Padder Padder is offline
Mosets'd
 
Join Date: Jan 2007
Location: England
Posts: 14
Default

Hi,

Glad you found it useful. I don't use the captions myself, they are written directly into my template as I'm only using one language.

Without testing this, I'd guess that something along these lines would get you the caption into a variable too (insert into each case you want a caption for):

Code:
  case "yourfieldname":
        $yourchosenvariablename = $extrafield_value;
        $yourchosencaptionname = $extrafield->caption;
  break;
Then you can use the caption in your own style of layout too.

If this doesn't work, then try things around that... the line that HP use to get the caption is:

Code:
<?php echo $this->escape($extrafield->iscore ? JText::_($extrafield->caption) : $extrafield->caption); ?>
so something based around that within the switch should work.
 

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


All times are GMT +8. The time now is 05:08 AM.

Copyright © 2005-2010 Mosets Consulting

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