We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Runway

Need ideas for efficient use of Categories/Relationships in Runway

I'm building a Runway site for a home building company. I have two collections, Homes and Neighborhoods, both of which have list/detail pages. On my homes list page, homes can be filtered by categories such as number of bedrooms, bathrooms, etc. I also need to be able to filter homes based on which neighborhoods they are in. Similarly, on my neighborhood detail pages, I need to list the associated homes as well as the unique home price for that neighborhood.

I need to:

  • Associate each home with one or more neighborhoods
  • Assign a home price for each associated neighborhood
  • Filter by associated neighborhoods on the homes list page
  • Show associated homes and prices on the neighborhood detail page

If it weren't for the unique prices attached to each home/neighborhood combination, I could simply create a Neighborhoods category and use that to filter. How can I also associate a price with the related homes/neighborhoods?

Thanks for the ideas!

  • Shane
Shane Lenzen

Shane Lenzen 18 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

This is the part I don't understand:

Assign a home price for each associated neighbourhood

Does that mean a home can be in more than one neighbourhood somehow?

Yes, these are home plans. The same home can exist in several neighborhoods, but is priced differently in each one.

Drew McLellan

Drew McLellan 2638 points
Perch Support

So does the price exist on the relationship?

That's what I'm not sure about. I know I can use Relationships to satisfy most of these requirements, but I'm not sure how to add the price into the mix. I can relate a home to several neighborhoods, but how can I also associate a price with that home/neighborhood relationship?

I can think of other use cases for this, especially with Shop. Say I have a collection of products and a "colors" category. In the product item I select the available colors so that the products can be filtered by color. But say the price of the item is dependent on the color...how can that price be added to the product/color combination?

Drew McLellan

Drew McLellan 2638 points
Perch Support

In Shop those are product variants. You'd create an option for colour, and then option values for each colour. When colour is set as an option for the product, each combination is created as a variant with its own SKU, and its own properties such as price.

That sounds great. Do you think it would make sense to use Shop in this situation, without the ecommerce features?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, I don't think this sounds like a good use for Shop at all. That wasn't my suggestion - I was just answering your question about Shop.

Any idea how I might achieve similar functionality without Shop?

Drew McLellan

Drew McLellan 2638 points
Perch Support

At the moment you can't add any content onto the relationship itself. I'll have a think about it, but I'm not sure what the right solution might be.

Understood, thanks.

Still working towards a solution for this, but I've hit a wall and could use some help.

I've created Neighborhoods category. In my Neighborhood template, I select the category like this:

<perch:categories id="neighborhood" label="Category" set="Neighborhoods" display-as="checkboxes" divider-before="Neighborhood Category" suppress="true"></perch:categories>

In my Home template, I also select a Neighborhoods category:

<perch:categories id="home_neighborhood" label="Neighborhood" set="Neighborhoods" display-as="checkboxes" suppress="true" divider-after="Neighborhood Prices"></perch:categories>

On my neighborhoods detail page, I get content like this:

$result = perch_collection('Neighborhoods', [
    'filter'=>'slug',
    'match'=>'eq',
    'value'=>perch_get('s'),
    'skip-template'=>true,
    'return-html'=>true
]); 

...

echo $result['html'];

Now what I can't figure out is how to get the category of the matched Neighborhood detail page item, and then display items from the Homes collection which match the same category. I tried this:

perch_collection('Homes', [
    'filter'=>'home_neighborhood',
    'match'=>'contains',
    'value'=>$result[0]['neighborhood'],
    'template'=>'/homes/home_in_list.html'
]); 

but that doesn't work because $result[0]['neighborhood'] is an array of category IDs. How can I get the category slug of the current item so that I can filter another collection with the same category?

Nevermind, got it working with a combination of categories and repeaters. Thanks.