Inject CSS and JS files into Panels, Mini-Panels, Panels Everywhere

This module allows developers to Inject CSS & JS files into page based on Panels or into block based on Mini Panels. Also this module is useful feature if you building site theme using Panels Everywhere page template

Advantages:

  • you don't need to push all CSS code into "style.css" file and all JS code into "script.js" file.
  • you don't need to add CSS and JS files using theme ".info" file.
  • you don't need to include files using drupal_add_css() and drupal_add_js() in template.php or in your custom module.
  • you can inject CSS and JS files into pages based on Panels
  • you can inject CSS and JS files into blocks based on Mini Panels.
  • you can inject CSS and JS files into Panels Everywhere page template.
  • you can use different types of placeholders to enter path to CSS or JS files instead of full path.

How to Inject Files:

  • using "CSS & JS files" tab in the Page Manager (Structure -> Pages) when you configuring page based on Panels
  • using ctools content type "CSS & JS files" under "Page elements" tab when you add new content to Panels or Mini-Panels

How to Use:

There are two textareas for CSS and JS files accordingly. Enter one file per line.
You can use "[module-{module_name}]" or "[theme-{theme_name}]" placeholders to get path to module/theme. You can use "[theme]" placeholder to get path to current page theeme.

Placeholders examples:

  • [theme]/css/careers.css - path to current page theme
  • [theme-zen]/js/careers.js - path to "Zen" theme
  • [module-views]/views.css - path to "Views" module

Project Page: https://drupal.org/sandbox/webmasterslava/1644300
Git Repository: http://git.drupal.org/sandbox/webmasterslava/1644300.git

Comments

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://ventral.org/pareview/httpgitdrupalorgsandboxwebmasterslava1644300git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

webmasterslava’s picture

Status: Needs work » Needs review

fixed

Darth Raven’s picture

Status: Needs review » Needs work

panel_css_js_fules.module
misspelling

function panels_css_js_files_edit_form(&$form, &$conf) {
  $description = '<b>Enter one file per line.</b><br />' .
    'You can use "[module-{module_name}]" or "[theme-{theme_name}]"' .
    ' placeholders to get path to module/theme. You can use "[theme]"' .
    ' placeholder to get path to current page theeme.<br /><br />';

theeme => theme

webmasterslava’s picture

Status: Needs work » Needs review

fixed

cbudzi’s picture

Status: Needs review » Reviewed & tested by the community

Source Code looks clean to me.

kscheirer’s picture

Status: Reviewed & tested by the community » Needs work

This seems like a great module! Normally Panels makes you edit the template files to add custom css or js.

  1. Can you use the Token API to handle the filtering and replacing of values? I'm assuming that's how the panels module does it. Using the API would save you lots of lines of code.
  2. For your string functions, we have drupal_strlen() and drupal_substr(). mb_strpos() has no drupal_ substitute.
  3. minor: You should use real commit messages, "x" doesn't mean anything.
  4. minor: while (list($key, $value) = each($ops['children'])) { could probably be a foreach()?

Setting to "needs work" for #1 and #2.

----
Top Shelf Modules - Crafted, Curated, Contributed.

webmasterslava’s picture

Status: Needs work » Reviewed & tested by the community

1. I have replaced a lot of code with one small function but without using Tokens API, because module should search for dynamic placeholders like "[module-XXX]", "[theme-XXX]" where XXX is dynamic part that can be for example "views", "zen" etc. Also module should check if found module/theme exists on the site. All of that are impossible with Tokens API, so I implemented all the code with couple preg_match() and str_replace() functions.

2. String functions replaced with "drupal_" functions.

kscheirer’s picture

Status: Reviewed & tested by the community » Needs review

Sorry, you can't RTBC your own issue, "needs review" is the appropriate status after making fixes.

kscheirer’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, that does look better.

----
Top Shelf Modules - Crafted, Curated, Contributed.

kscheirer’s picture

Status: Reviewed & tested by the community » Fixed

It's been a month without any further problems, so...

Thanks for your contribution, webmasterslava!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

----
Top Shelf Modules - Crafted, Curated, Contributed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

description updated