1

As you know in drupal 7 css and js files added to the rendered page. at end of href or src values you see a token.

for example

<link type="text/css" rel="stylesheet" href="/sites/all/themes/uikit/css/icomoon.css?s6y431" media="all" />

<link type="text/css" rel="stylesheet" href="/sites/all/themes/uikit/css/styles.css?s6y431" media="all" />

I want to know is there any way that I can access the variable that take "s6y431" value?

2
  • 1
    AFAIK this is not a real token, this is just a randomly generated cache buster. You could also append the current timestamp to prevent caching. (Side note: Image style variants have a "real" token to prevent DoS attacks, but for CSS and JS files this just means "hey browser, do not load an old one".)
    – Hudri
    Jan 8 at 14:32
  • Dear @Hudri I know what it is and what it does. But for a reason, I want to load this value. So you mean there is not any solution?
    – Mehrdad201
    Jan 8 at 14:53

1 Answer 1

2

That value is stored in a persistent variable (css_js_query_string) which is used by either drupal_pre_render_styles() or drupal_pre_render_scripts().

// A dummy query-string is added to filenames, to gain control over
// browser-caching. The string changes on every update or full cache
// flush, forcing browsers to load a new copy of the files, as the
// URL changed. Files that should not be cached (see drupal_add_js())
// get REQUEST_TIME as query-string instead, to enforce reload on every
// page request.
$default_query_string = variable_get('css_js_query_string', '0');
// A dummy query-string is added to filenames, to gain control over
// browser-caching. The string changes on every update or full cache
// flush, forcing browsers to load a new copy of the files, as the
// URL changed.
$query_string = variable_get('css_js_query_string', '0');

Its value is initialized by _drupal_flush_css_js(), but code needing it should use '0' as default value for css_js_query_string.

1
  • Thanks a lot @apaderno . It works.
    – Mehrdad201
    Jan 8 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.