Carl W Crawley

Getting all the siblings of a channel entry?

Hey Brandon / Support Type Person!

I've got to a point where I can no longer see the wood for the trees!

I have two channels, areas and properties:

Within Properties is a Playa field which associates 'areas' to it.

Now within the 'areas' page, I need to return all the properties that are related to that property.

so I have a /properties/property-url-title and I'm assuming I should be using the 'siblings' tag?

I am doing it with an embed as follows:


{exp:channel:entries channel="area" limit="1" url_title="{segment_2}" dynamic="no"}
{embed="/_includes/properties" property_ids="{exp:playa:sibling_ids entry_id="{entry_id}" channel="properties"}"}
{/exp:channel:entries}


then within the embed I have:


{exp:channel:entries channel="properties" entry_id="{embed:property_ids}" dynamic="no"}
.......
{/exp:channel:entries}


But this doesn't seem to be working correctly... am I on the right path? What have I missed?

Cheers,

Carl
1 person has
this question
+1
Reply

  • Hi Carl,

    If the Playa field is on the Properties channel, than Properties are the "parents" and Areas are the "children". So if you're looking at an Area, and you want to get the Properties that relate to it, you're going to use {exp:playa:parents}, not :siblings.

    So, replace ":sibling_ids" with ":parent_ids" and your code should work.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • shaunwarren2008
    Tried this just now and it appears with a SQL Error.

    Error Number: 1064

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2

    SELECT DISTINCT(rel.parent_entry_id) AS entry_id FROM exp_playa_relationships rel WHERE rel.child_entry_id = {entry_id tagdata_cache_index=

    Filename: third_party/playa/mod.playa.php

    Line Number: 471


    The code being used is:

    {exp:channel:entries channel="areas" limit="1" url_title="{segment_4}" dynamic="no"}

    {embed="_embeds/area_properties" property_ids='{exp:playa:parent_ids entry_id="{entry_id}" channel="properties" search:property_status="{if segment_3=="sale"}1|2|3{if:else}3|4|5{/if}"}'}

    {/exp:channel:entries}
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Oh, that’s because Playa will begin parsing {exp:playa:parents} before Channel has a chance to swap out {entry_id}. Maybe try this instead:

    {exp:channel:entries channel="areas" limit="1" url_title="{segment_4}" dynamic="no"}
    {embed="_embeds/area_properties"
    entry_id="{entry_id}"
    property_status="{if segment_3=="sale"}1|2|3{if:else}3|4|5{/if}"
    }
    {/exp:channel:entries}


    _embeds/area_properties template:

    {exp:playa:parents
    entry_id="{embed:entry_id}"
    channel="properties"
    search:property_status="{embed:property_status}"
    }
    ...
    {/exp:playa:parents}
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated