Forum Discussion

thesedays's avatar
11 years ago
Solved

FreeMarker template error when passing parameter from custom content to a custom component

Hi, I have created a custom page, and I'm exchanging some variables from the ADMIN (custom content 2) to the STUDIO (a custom component). It is working, because I see the value at the page. But it also generates an error saying: "The following has evaluated to null or missing: env.context.component.getParameter('t1') [in template "preview" at line 1, column 16]"

At the custom content 2:
1. I give a value to the variable t1
<#assign t1="Main title"/>
2.I put the variable to the custom component
<@component id="custom-component" t1=t1 />

At the custom component:
1. I assign the t1 to the value from the custom content 2
<#assign t1=env.context.component.getParameter('t1') />
2. I print the value to the page
<h1>${t1}</h1>

Does anyone have an idea why it is working but also generates this FreeMarker template error?


template_error_20140708.PNG
  • It seems like I'm just stupid.

    I've put the custom content and the custom component at the same page. That's why the second time it printed an error. The component has no link with the content.

    Sorry to bother you guys.

3 Replies

  • NicoB's avatar
    NicoB
    Lithium Alumni (Retired)
    11 years ago

    Hi thesedays 

    where are you getting that error?

     

    It seems like your screenshot attached is referring to the error you normally get in the Studio preview which is fine because when studio tries to render the component it doesn't pass it any parameter.

     

    Thanks,

    Nico

  • thesedays's avatar
    thesedays
    Guide
    11 years ago
    Hi Nico, the error on the rendered site is the same as the studio preview page.
    But on the site, the variable is printed (in this case it's the title: "Main title"), with the error message underneath it.
  • thesedays's avatar
    thesedays
    Guide
    11 years ago
    It seems like I'm just stupid.

    I've put the custom content and the custom component at the same page. That's why the second time it printed an error. The component has no link with the content.

    Sorry to bother you guys.