Details

    • Branch Version/s:
      6.0.x
    • Backported to Branch:
      Committed
    • Liferay Contributor's Agreement:
      Accept
    • Similar Issues:
      Show 4 results 

      Description

      FTL_liferay.ftl file has an incorrect if-clause for the main css file. Also when the code is manually fixed it seems that css_main_file and js_main_file are undefined. What this means is that all popups have same background than your website and nothing else. No textboxes, buttons, nothing. This is because processing the portal_pop_up.ftl stops when these errors occur. Here's the part where these macros are called in portal_pop_up.ftl:

      <head>
      <title>$

      {the_title}

      </title>

      $

      {theme.include(top_head_include)}

      <@liferay.css file_name=css_main_file/>
      <@liferay.js file_name=js_main_file/>
      </head>

      Here's the broken code snippet from FTL_liferay.ftl:

      <#macro css file_name>
      <#assign file_id = "">

      <#if file_name = css_main_file>
      <#assign file_id = "mainLiferayThemeCSS" />
      </#if>

      <link class="lfr-css-file" href="$

      {file_name}" id="${file_id}" rel="stylesheet" type="text/css" />
      </#macro>

      <#macro js file_name>
      <#assign file_id = "" />

      <#if file_name == js_main_file>
      <#assign file_id = "mainLiferayThemeJavaScript" />
      </#if>

      <script id="${file_id}" src="${file_name}

      " type="text/javascript"></script>
      </#macro>

      As you can see the <#if file_name = css_main_file> is missing a =-mark. Even after fixing the missing =-mark, both variables still caused errors saying they were undefined. I managed to fix the undefined error by copy-pasting both functions to my init_custom.ftl, renaming them and using them from there:

      <#macro css file_name>
      <#assign file_id = "">

      <#if file_name == css_main_file>
      <#assign file_id = "mainLiferayThemeCSS" />
      </#if>

      <link class="lfr-css-file" href="$

      {file_name}" id="${file_id}" rel="stylesheet" type="text/css" />
      </#macro>

      <#macro js file_name>
      <#assign file_id = "" />

      <#if file_name == js_main_file>
      <#assign file_id = "mainLiferayThemeJavaScript" />
      </#if>

      <script id="${file_id}" src="${file_name}

      " type="text/javascript"></script>
      </#macro>

      Errors are:
      19:45:07,296 ERROR [runtime:96] Expression css_main_file is undefined on line 6, column 26 in FTL_liferay.ftl.
      20:01:43,588 ERROR [runtime:96] Expression js_main_file is undefined on line 16, column 27 in FTL_liferay.ftl.

      I've attached a stacktrace from both errors. I don't know why those variables are undefined, but maybe you'll find it as I don't know the whole process of Liferay Freemarker processing.

      1. css-stacktrace
        19 kB
        Henri Koskenranta
      2. js-stacktrace
        19 kB
        Henri Koskenranta
      3. LPS-14789-build-76168.diff
        0.9 kB
        Tomáš Polešovský

        Activity

        Hide
        Henri Koskenranta added a comment -

        Stacktraces for the errors

        Show
        Henri Koskenranta added a comment - Stacktraces for the errors
        Hide
        Tomáš Polešovský added a comment -

        This issue is currently being addressed in Sprint 3 of the 100 PaperCuts program. Please see http://liferay.com/community/100-papercuts

        Show
        Tomáš Polešovský added a comment - This issue is currently being addressed in Sprint 3 of the 100 PaperCuts program. Please see http://liferay.com/community/100-papercuts
        Hide
        Tomáš Polešovský added a comment -

        Some facts:

        • css_main_file and js_main_file are initialized using init.vm which is included into portal_pop_up template's namespace
        • FLT_liferay.flt is loaded using auto_import, which means it has different namespace than theme's templates (it is loaded into "liferay" namespace)
        • macros in FLT_liferay.flt doesn't see css_main_file and css_main_file because they are in different namespace

        I see 3 solutions how it can be fixed:
        1, register css_main_file and js_main_file into global namespace in init.vm using
        <#global css_main_file = htmlUtil.escape(portalUtil.getStaticResourceURL(request, "$

        {css_folder}

        /main.css")) />
        <#global js_main_file = htmlUtil.escape(portalUtil.getStaticResourceURL(request, "$

        {javascript_folder}

        /main.js")) />

        2, rewrite FLT_liferay.flt macros and don't use private properties of another template or move these macros into init.vm - this can impact existing themes' templates

        3, change auto_import of FLT_liferay.flt to auto_include, thus macros and all other stuff will be together in the same namespace with theme's templates - this impacts existing themes' templates (portal_pop_up.flt use macros from the liferay namespace and auto_include won't create own namespace)

        I think the final decision is up to Mika Koivisto.

        Show
        Tomáš Polešovský added a comment - Some facts: css_main_file and js_main_file are initialized using init.vm which is included into portal_pop_up template's namespace FLT_liferay.flt is loaded using auto_import, which means it has different namespace than theme's templates (it is loaded into "liferay" namespace) macros in FLT_liferay.flt doesn't see css_main_file and css_main_file because they are in different namespace I see 3 solutions how it can be fixed: 1, register css_main_file and js_main_file into global namespace in init.vm using <#global css_main_file = htmlUtil.escape(portalUtil.getStaticResourceURL(request, "$ {css_folder} /main.css")) /> <#global js_main_file = htmlUtil.escape(portalUtil.getStaticResourceURL(request, "$ {javascript_folder} /main.js")) /> 2, rewrite FLT_liferay.flt macros and don't use private properties of another template or move these macros into init.vm - this can impact existing themes' templates 3, change auto_import of FLT_liferay.flt to auto_include, thus macros and all other stuff will be together in the same namespace with theme's templates - this impacts existing themes' templates (portal_pop_up.flt use macros from the liferay namespace and auto_include won't create own namespace) I think the final decision is up to Mika Koivisto.
        Hide
        Tomáš Polešovský added a comment -

        Quite funny - I've fetched most recent SVN and Nate fixed it by accident yesterday evening in LPS-16047

        He removed all calls of the macros from portal_pop_up.ftl.

        Workaroud for existing code is to remove <@liferay.css css_main_file /> and <@liferay.js js_main_file /> macro from portal_pop_up.ftl.

        Now the bug can be closed with one fix - remove macros from FTL_liferay.ftl - it's dead code now.

        Show
        Tomáš Polešovský added a comment - Quite funny - I've fetched most recent SVN and Nate fixed it by accident yesterday evening in LPS-16047 He removed all calls of the macros from portal_pop_up.ftl. Workaroud for existing code is to remove <@liferay.css css_main_file /> and <@liferay.js js_main_file /> macro from portal_pop_up.ftl. Now the bug can be closed with one fix - remove macros from FTL_liferay.ftl - it's dead code now.
        Hide
        Tomáš Polešovský added a comment -

        Removing dead code from FTL_liferay.ftl

        Show
        Tomáš Polešovský added a comment - Removing dead code from FTL_liferay.ftl
        Hide
        Mika Koivisto added a comment -

        Thanks Tomas for your analysis. I fixed the macro library by defining the needed variables there. I didn't want to remove the macros because we show in training how to add more css and js files using that macro. Although training uses Velocity templates I want to keep Freemarker functionality as identical as possible.

        Show
        Mika Koivisto added a comment - Thanks Tomas for your analysis. I fixed the macro library by defining the needed variables there. I didn't want to remove the macros because we show in training how to add more css and js files using that macro. Although training uses Velocity templates I want to keep Freemarker functionality as identical as possible.
        Hide
        Edward Gonzales added a comment -

        Hello everyone! We are in the process of moving component "Theme" to "Theme > Dev" in LPS. Please make the necessary adjustments to your filters. Thanks!

        Show
        Edward Gonzales added a comment - Hello everyone! We are in the process of moving component "Theme" to "Theme > Dev" in LPS. Please make the necessary adjustments to your filters. Thanks!

          People

          • Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 49 weeks, 3 days ago

              Development

                Structure Helper Panel