Comments

osopolar created an issue. See original summary.

osopolar’s picture

Status: Active » Needs review
StatusFileSize
new2.28 KB

Patch adds keyword substitution for css_code and js_code.

nwom’s picture

Status: Needs review » Active

Sadly #2 is a patch for the wrong module (and is most likely for a different issue). I'm eager to test out this patch! Setting back to Active for now. Thanks!

osopolar’s picture

Status: Active » Needs review
StatusFileSize
new6.24 KB

You are right, I uploaded the wrong patch. Please check this one.

nwom’s picture

Status: Needs review » Needs work
StatusFileSize
new6.23 KB

Thank you very much for providing the patch! This will be a life saver.

However, when applying the patch, the following errors are shown:

panels_css_js-context-keywords-2567573-2.patch:9: trailing whitespace.
  'all contexts' => TRUE,
panels_css_js-context-keywords-2567573-2.patch:13: trailing whitespace.
    'substitute' => 0,
panels_css_js-context-keywords-2567573-2.patch:24: trailing whitespace.
function panels_css_js_css_code_content_type_render($subtype, $conf, $panel_args, $contexts) {
panels_css_js-context-keywords-2567573-2.patch:25: trailing whitespace.
  if (!empty($conf['panels_css_js_code_css'])) {
panels_css_js-context-keywords-2567573-2.patch:26: trailing whitespace.
    panels_css_js_code_css_render($conf, $contexts);
Checking patch ctools_plugins/content_types/css_code.inc...
Checking patch ctools_plugins/content_types/js_code.inc...
Checking patch panels_css_js.module...
Applied patch ctools_plugins/content_types/css_code.inc cleanly.
Applied patch ctools_plugins/content_types/js_code.inc cleanly.
Applied patch panels_css_js.module cleanly.
warning: squelched 5 whitespace errors
warning: 10 lines add whitespace errors.

I went ahead and fixed the whitespace errors in the attached patch.

With either patch applied, the following error is shown when navigating to the Panels CSS & JS configuration tab:

Notice: Undefined index: substitute in panels_css_js_code_js_edit_form() (line 146 of /var/aegir/platforms/drupal-7.56/sites/SITE/modules/panels_css_js/panels_css_js.module).

Also, only one "Use context keywords" is shown. The checkbox is only shown under CSS code, and not under JS code.

Setting to needs work for now.

nwom’s picture

Status: Needs work » Needs review
StatusFileSize
new6.52 KB

Here is a new patch that fixes the second checkbox from not showing up, and also fixes the watchdog "Undefined Index" notices from showing. Please review.

nwom’s picture

Status: Needs review » Needs work

Found another issue. After enabling one checkbox, both checkboxes instead are automatically checked. Enabling only one isn't possible, and disabling both of them is no longer possible after enabling one.

The whitespace issue is also back oddly enough.

nwom’s picture

Status: Needs work » Needs review
StatusFileSize
new6.52 KB

Here is another patch that fixes the check boxes not working correctly. This should clear up all of the issues I found. Please review.

nwom’s picture

Status: Needs review » Needs work

It appears only contexts are loaded from the entity, but not contexts available through a panels relationship. The same contexts can be otherwise loaded into custom content panes just fine.

Also, I just noticed that backslashes are automatically being removed when the contexts are used as js code. However, if the same contexts are loaded into custom content panes, the back slashes are rendered as expected.

Any ideas @osopolar?

Setting this back to Needs Work for now.

elaman’s picture

Status: Needs work » Needs review
StatusFileSize
new6.69 KB

Fixed by using ctools_context_get_context_from_relationships to load relationships.

As for backslashes. Javascript treats them as a special character. For example \t as tab, \s as space.
If you want to use backslashes in text, please do \\ instead.

nwom’s picture

Status: Needs review » Reviewed & tested by the community

#10 works perfectly. Thanks!

Also thank you for the hint about the backslashes.