Nested Placid Requests


We are currently implementing hubspot on one of our sites. We have a form thank you page which redirects to a page hosted on the Statamic part of the site. On the thank you page we have the phrase: Thank You {{ firstname }}.

In order to get the firstname we firstly retrieve the users profile using the value of the hubspot tracking cookie. The cookie is then used in a Placid request to populate the value of a query parameter.

The result of the Placid request is then used in another Placid request which gets the full user details based on the ID returned by the first request. We use the result of the second Placid Request to output firstname.

This is probably more clearly shown in the code block below

{{ placid:request handle="hubspot" path="/contacts/v1/contact/utk/{ cookie:hubspotutk }/profile?hapikey=key" }}
        {{ response }}
            {{ placid:request handle="hubspot" path="/contacts/v1/contact/vid/{{ response.vid }}/profile?hapikey=key" }}
                {{ response }}
                    <h1>Thank You {{ response.firstname.value }}</h1>
                {{ /response }}
            {{ /placid:request }}
        {{ /response }}
    {{ /placid:request }}

In a twig template I'd just use a temporary variable to hold the response.vid then use it in the second call but this doesn't seem possible in Statamic. I've also tried using { response.vid } but this doesn't work either.

Any ideas?


Answered by Erin Dalzell!
>>>>>>> Answered <<<<<<<
5 Replies