I need to be able to do pass the entry_id of the page being viewed into a json file to build a query.
I currently have a page setup that has a Playa field. I need to have a JSON file that will get the IDs of all of the Playa children so that I can pass those values to a map on the same page.
In the page, I have the following;
{exp:stash:set_list name="trail" parse_tags="yes" parse_depth="3"}
{exp:channel:entries channel="{channel}" status="open" limit="1" require_entry="yes"}
{stash:trail_title}{title}{/stash:trail_title}
{/exp:channel:entries}
{/exp:stash:set_list}
{exp:stash:get_list name="trail"}
<h2>About the {trail_title}</h2>
{/exp:stash:get_list}
<div class="mapwithborders">
<div class="listing_map" data-api-url="trail-json"></div>
</div>
My 'trail-json.js' template has the following (but as you can see there is a hardcoded parent_entry_id;
{exp:query sql="SELECT child_entry_id AS entry_ids FROM exp_playa_relationships WHERE parent_entry_id = 2422"}
[
{exp:playa:children
entry_id="{entry_ids}"
field="trail_spots"
channel="things-to-do"
status="Open"
backspace="1"
}
{
"entry_id": "{entry_id}",
"title": "{title}",
"latitude": "{thingtodo_latitude}",
"longitude": "{thingtodo_longitude}"
},{/exp:playa:children}
]
{/exp:query}
I would be grateful if someone could point me in the right direction to replace the hard-coded parent_entry_id.
Thank you.