1

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.

2 Answers 2

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; } ?>

1
  • 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. Nov 21, 2022 at 12:18
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

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.