Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-18511

Add support for passing a query string when calling getSkinFile

    XMLWordPrintable

Details

    • New Feature
    • Resolution: Unresolved
    • Major
    • None
    • 12.10.5
    • Old Core
    • None
    • Unknown

    Description

      Today, if you want to include a CSS or a JavaScript skin resource in the current page you can do it with:

      $xwiki.ssfx.use('js/xwiki/widgets/modalPopup.css', {
        'forceSkinAction': true,
        'colorTheme': $themeDoc
      })
      ...
      $xwiki.jsfx.use('uicomponents/suggest/suggest.js', {
        'forceSkinAction': true,
        'language': $xcontext.locale
      })
      

      Note how the skin extension plugin allows you to specify query string parameters to use on the resource URL. This is very useful because:

      • it "invalidates" the cached CSS when the color theme changes (assuming the CSS uses the color theme)
      • it "invalidates" the cached JavaScript when the current locale changes (assuming the JavaScript code uses Velocity and the localization script service)

      Now, if you want to load these resources yourself, lazy, after the page loads (e.g. using RequireJS), you need to use $xwiki.getSkinFile() instead to get the resource URL.

      require.config({
        'paths': {
          'xwiki-suggest': "$xwiki.getSkinFile(''uicomponents/suggest/suggest.js'', true)",
          ...
        }
      });
      

      But this doesn't support a query string parameter so you're forced to "extend" the query string of the returned URL. Simply appending your query string doesn't work because the returned URL can already have a query string (the cache-version parameter for instance).

      Attachments

        Activity

          People

            Unassigned Unassigned
            mflorea Marius Dumitru Florea
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: