Answers.Body: <p>To answer my own question, I looked a bit harder and found that there is a suitable css class in the html:</p>
  <p>&lt;div class=&quot;crm-contribution-page-id-6 crm-block crm-contribution-main-form-block&quot; data-page-id=&quot;6&quot; data-page-template=&quot;main&quot;&gt;</p>
  <p>this class: crm-contribution-page-id-6</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-21T12:13:16.557Z
Answers.LastActivityDate: 2022-11-21T12:13:16.557Z
Answers.UserDisplayName: Tom Rosenbloom
Answers.Body: <p>It's certainly something you can do, but as you probably realize it's fragile, hard to maintain and hard to test, so not a great idea if you can avoid it. You could do something like:</p>
  <p><code>&lt;?php $url = request_uri(); if (strpos($url, &quot;civicrm/profile/create?gid=NNN&quot;)) { return TRUE; } ?&gt;</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-21T12:18:14.430Z
Answers.Text: Thanks @Lars SG. I agree this is very much to be avoided - I wonder if there is really any valid use case? Note I answered my own question.
Answers.UserDisplayName: Tom Rosenbloom
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-09T16:01:49.957Z
Answers.LastActivityDate: 2022-11-09T16:01:49.957Z
Answers.UserDisplayName: Lars SG
Body: <p>I want to target a Drupal CSS Injector rule at a specific Civi profile, using the query string parameter that identifies the profile.</p>
  <p>There is a section in the CSS Injector dialogue 'Add the CSS on specific pages'. It's v easy to use 'add on only the listed pages' with a path and wildcards as required, but that can't target a specific profile. For that I'm imagining I could use the option 'Add if the following PHP code outputs a nonzero value' to target a specific profile by using the profile id in the query params.</p>
  <p>I assume that could work - ? The problem is this is very difficult to test because any mistake in the php will irretrievably break the entire site.</p>
  <p>Does anyone have an opinion on whether this is a correct or sensible thing to be attempting and/or a working example of using the nonzero php option?</p>
  <p>PS I know I could add targeted css via the Drupal theme, but if I could do it via the UI that would be very much easier in my current setup.</p>
  
Tags: <drupal><drupal-7>
Title: How to target Drupal CSS Injector rule at a CiviCRM profile, using query string paramters
ThreadText: # How to target Drupal CSS Injector rule at a CiviCRM profile, using query string paramters
  
  (Asked by: username_0 on 2022-11-09)
  
  I want to target a Drupal CSS Injector rule at a specific Civi profile, using the query string parameter that identifies the profile.
  
  There is a section in the CSS Injector dialogue 'Add the CSS on specific pages'. It's v easy to use 'add on only the listed pages' with a path and wildcards as required, but that can't target a specific profile. For that I'm imagining I could use the option 'Add if the following PHP code outputs a nonzero value' to target a specific profile by using the profile id in the query params.
  
  I assume that could work - ? The problem is this is very difficult to test because any mistake in the php will irretrievably break the entire site.
  
  Does anyone have an opinion on whether this is a correct or sensible thing to be attempting and/or a working example of using the nonzero php option?
  
  PS I know I could add targeted css via the Drupal theme, but if I could do it via the UI that would be very much easier in my current setup.
  
  **Tags:** drupal, drupal-7
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2022-11-21. Score: 1
  
  To answer my own question, I looked a bit harder and found that there is a suitable css class in the html:
  
  <div class="crm-contribution-page-id-6 crm-block crm-contribution-main-form-block" data-page-id="6" data-page-template="main">
  
  this class: crm-contribution-page-id-6
  
  
  ---
  
  ### Answer by username_1 on 2022-11-09. Score: 1
  
  It's certainly something you can do, but as you probably realize it's fragile, hard to maintain and hard to test, so not a great idea if you can avoid it. You could do something like:
  
  `<?php $url = request_uri(); if (strpos($url, "civicrm/profile/create?gid=NNN")) { return TRUE; } ?>`
  
  > **Comments:**
  > **username_0**: Thanks @username_1. I agree this is very much to be avoided - I wonder if there is really any valid use case? Note I answered my own question.  
  
  ---
  
  