core icon indicating copy to clipboard operation
core copied to clipboard

Site Variable does not render in a headless application / redering page using API

Open craigWagner99 opened this issue 4 years ago • 6 comments
trafficstars

As reported in: https://dotcms.zendesk.com/agent/tickets/105638 v5.3.8.5LTS Tested in v5.3.8.5LTS

In a headless application, when i calling the api/v1/page/render/{mypage} service, the host_variable does not render.

There is a workaround: adding the code to your VTL: #parse("LIVE/${host.identifier}.site")

To Reproduce Steps to reproduce the behavior:

  1. Create a page
  2. Add a reference to the site variable (e.g. <p>$host_variable.{var}</p> )
  3. Render the page using the API
  4. The code does not render - it just displays the code

Screenshots image

craigWagner99 avatar Nov 05 '21 18:11 craigWagner99

In order to test you can create a container and a couple site vars, such as this

$title

on container: $host_variable.onevar <br/>
$host_variable.secondvar

You should see the vars translated to the real values on the site vars

jdotcms avatar May 27 '22 22:05 jdotcms

Fixed, tested on release22.07 // Docker // FF image

bryanboza avatar Jul 26 '22 20:07 bryanboza

We need some work here, we need to create a curl test for this specific case.

bryanboza avatar Jul 26 '22 21:07 bryanboza

@jdotcms Here.

fmontes avatar Jul 28 '22 15:07 fmontes

PR for postman tests left for master/next-release: https://github.com/dotCMS/core/pull/22653

dsilvam avatar Aug 09 '22 18:08 dsilvam

Since the tests was done in master, moving this to next release so @bryanboza can check it and pass is there.

fmontes avatar Aug 09 '22 18:08 fmontes

Now we have the curl test implemented and running, but in this implementation we are using the host word instead a site wich is not good because we are using both to the same thing.

After a discussion with @wezell we need to change the names of the new endpoints to and replace host by site at the endpoints level

Here the list:

  • saveHostVariable
  • getHostVariables

bryanboza avatar Aug 25 '22 21:08 bryanboza

Done: PR

jdotcms avatar Aug 29 '22 21:08 jdotcms

https://github.com/dotCMS/core/pull/22878

Merged.

fmontes avatar Sep 08 '22 21:09 fmontes

Fixed, feedback applied. Tested on release-22.09 // Docker // FF

bryanboza avatar Sep 09 '22 15:09 bryanboza

Excluding from LTS releases as there is a viable workaround and the issue has been low impact

swicken-dotcms avatar Nov 16 '22 22:11 swicken-dotcms