Hi.
I have a question about how relations work in EE. I have replaced a {exp:channel:entires} tag with my own custom plugin that takes the results from the db, however I’ve found that the {related_entries} tag doesn’t work outside the {exp:channel:entries} tag. Here is the original code:
{exp:channel:entries channel="professional_calendar" limit="10" orderby="start_date" sort="asc" dynamic_parameters="category|entry_date"}
<input type="hidden" name="business" value="{related_entries id="practitioner"}{paypal_details}{/related_entries}">
....Here is my new code (which doesn’t work). I tried making a {exp:channel:entries} tag which selects by practitioner (the relation field that contains the dropdown to the paypal channel) but it appears the relation field doesn’t refer to the entry_id. What does the value in relation fields refer to and what’s the best way to get this working again?
{exp:myplugin:get_data channel_id="22" page_size="5"}
{exp:channel:entries channel="paypal" entry_id="{practitioner}"}
<input type="hidden" name="business" value="{paypal_details}"/>
{/exp:channel:entries}
...Thanks!
This might be of interest too: http://ellislab.com/forums/viewthread/196050/
Thanks for that I’ll consider it in the future. In case it’s useful to anyone here’s my beast of an sql statement. Fields with $ before them are php variables.
SELECT t.title, exp_channel_data.*,
pract.$paypal_details_field as paypal_details
FROM exp_channel_titles as t
LEFT JOIN exp_channel_data ON exp_channel_data.entry_id=t.entry_id
LEFT JOIN exp_category_posts ON exp_category_posts.entry_id=t.entry_id
LEFT JOIN exp_relationships ON exp_relationships.rel_id=exp_channel_data.$practitioner_field
LEFT JOIN exp_channel_data pract ON pract.entry_id=exp_relationships.rel_child_id
WHERE t.channel_id=$channel_id
AND (exp_category_posts.cat_id=$cat_id or $cat_id IS NULL)
AND ($month_min IS NULL OR exp_channel_data.$start_date_field_name>=$month_min)
AND ($month_max IS NULL OR exp_channel_data.$start_date_field_name<=$month_max)
AND t.status='open'
AND t.entry_date<unix_timestamp(CURDATE())
AND (t.expiration_date>unix_timestamp(CURDATE()) OR t.expiration_date=0)
ORDER BY exp_channel_data.$start_date_field_namePacket Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.