Skip to main content

How to use data from Section Templates in Format templates?

Comments

3 comments

  • Zendesk API User
    Author: bIT_sosswald - 7/18/2019 17:21

    Hi Patryk,

    if i understand your requirements correct you want to want to use content from a section of a page in its header. Therefore in you template hierarchy the source of your data (the section) is in a lover level as the target (the format template of the head).

    Take a look at the documentation regarding variables and especially contexts and its sub pages. I think they could contain the way to solve your problem.

    FirstSpirit Online Documentation - Variables in FirstSpirit

    FirstSpirit Online Documentation - Contexts

    Greetings

    Sandro

    0
  • Zendesk API User
    Author: kosin_patryk - 7/22/2019 10:35

    Please forgive my indolence. Despite the references to the documentation, I can not deal with one issue. In the simplest terms, I need to create a variable (CMS_SET) in Page Template and pass it to Format Template and display it there (CMS_VALUE). Is there a way to do it?

    I solved the previous problem of transferring the value of a variable from Section Template to Page Template as follows:

    Section template:

    $CMS_SET(#global.context("root")[VARIABLE_NAME_1], VALUE)$

    Page template:

    $CMS_VALUE(VARIABLE_NAME_1)$

    $-- shows the value of the variable correctly --$

    So my problem is now to:

    Page template:

    $CMS_SET(VARIABLE_NAME_2, VARIABLE_NAME_1)$

    Format template (how to?):

    $CMS_VALUE(VARIABLE_NAME_2)$

    ...?

    0
  • Zendesk API User
    Author: kschork - 7/22/2019 15:43

    Hi Patryk,

    Page template:

    $CMS_SET(VARIABLE_NAME_2, VARIABLE_NAME_1)$

    Format template (how to?):

    $CMS_VALUE(VARIABLE_NAME_2)$

    This should work, as long as you set the variable on the page template before rendering the format template

    $CMS_SET(VARIABLE_NAME_2, VARIABLE_NAME_1)$

    $CMS_RENDER(template:FORMAT_TEMPLATE_NAME)$

    $CMS_VALUE(VARIABLE_NAME_2)$

    This should show the value of the variable correctly...

    Greetings

    Kevin

    0

Please sign in to leave a comment.