Joining page attributes into a range 5.6.2.1

Permalink
I have a question about displaying custom page attributes together. I will explain below what I have and what I ultimately need to render.

This is a property rental site. A building has multiple attributes for number of bedrooms, rent, etc. So right now if I show what's available I get this:

2 bedrooms - $1,095
2 bedrooms - $1,495

What I would like to show is this:

2 bedrooms $1,095-$1,495

I assume this is possible, I am just drawing a blank here!

Anyone have an idea?

 
WebcentricLtd replied on at Permalink Reply
how is the attribute set up?

Is '2 bedrooms - $1,095' the value of a single text attribute and
'2 bedrooms - $1,495' is just another instance of that attribute type?

Or are you using other combinations of attributes?
aaronmarp replied on at Permalink Reply
It's a combo of attribute like this...

2 bedrooms - $1,095' the value of a single text attribute
<?php echo $unit_one_beds ?> Bedrooms $<?php echo $unit_one_rent ?>
<?php echo $unit_two_beds ?> Bedrooms $<?php echo $unit_two_rent ?>


If unit_one_beds and unit_two_beds values are the same, I want to use their respective rents as the range. does that make sense?
shotrox replied on at Permalink Best Answer Reply
shotrox
There is a lot more to be considered as you might have buildings with 3 or more individual units?
Also, are there ever 1 bedroom units? Then you have to check if you need plural or singular for bedroom(s)
Otherwise this will work:
<?php if ($unit_one_beds==$unit_two_beds) { ?>
<?php echo $unit_one_beds ?> Bedrooms $<?php echo $unit_one_rent ?> - $<?php echo $unit_two_rent ?>
<?php } else { ?>
<?php echo $unit_one_beds ?> Bedrooms $<?php echo $unit_one_rent ?>
<?php echo $unit_two_beds ?> Bedrooms $<?php echo $unit_two_rent ?>
<?php } ?>
aaronmarp replied on at Permalink Reply
Worked like a charm!

There is one bedroom units but I am not too worries about the (s), would be nice but isn't crucial.

Many thanks!
aaronmarp replied on at Permalink Reply
Here's another one for ya! Let's just say the user doesn't enter them from lowest to highest? Is there an easy way to grab the lowest and put it first? And what if there are more than two apartments with the same amount of bedrooms, how to show a range on that?

Sorry for all the questions, I appreciate your help! ;)