CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • custom jQuery to hide options in Quick Search
Pages: [1]

Author Topic: custom jQuery to hide options in Quick Search  (Read 464 times)

allenthehusband

  • I’m new here
  • *
  • Posts: 27
  • Karma: 2
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • PHP version: 5.3
custom jQuery to hide options in Quick Search
July 16, 2014, 04:40:30 pm
Running Civi 4.4.6 on Drupal 7.  I'm trying to remove 3 options we won't be using in the Quick Search.  I have added Navigation.extra.tpl to my custom templates directory\templates\CRM\common.  The file has the following code:
Code: [Select]
{literal}
<script>
cj('.innerbox li:nth-child(2)').hide();
cj('.innerbox li:nth-child(3)').hide();
cj('.innerbox li:last-child').hide();
</script>
{/literal}

The code does not work (the options are still there when I clear the cache and use QuickSearch), yet if I individually put those lines into Firebug's console, the options disappear.  Any ideas on why my jQuery is not working when placed in the tpl file?  Thanks for any help!

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: custom jQuery to hide options in Quick Search
July 16, 2014, 05:14:49 pm
Hi Allen,

That looks like the right template - but to be sure, it might be worth putting in an alert() on console.log() statement into your jQuery?  Also, are you using any other custom templates?  I've been bitten in the ass before by THINKING I had the right custom templates directory, but actually not...

More to the point - is there a reason not to simply override Navigation.tpl altogether and dispense with the jQuery?  In general I'd support your approach for upgrade/maintainability reasons, but Civi 4.5 has completely overhauled the QuickSearch, so I wouldn't sweat the maintainability.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

allenthehusband

  • I’m new here
  • *
  • Posts: 27
  • Karma: 2
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • PHP version: 5.3
Re: custom jQuery to hide options in Quick Search
July 17, 2014, 08:43:24 am
JonGold,
Thanks so much for the reminder that the solution doesn't *have* to be jQuery.  I tried the console.Log approach and as you suggested, something must have been wrong with my naming/folder convention.  Needing to push on and not spend more time on it, I followed the suggestion of point 1 on the template page (http://book.civicrm.org/developer/current/techniques/templates/), and went the CSS route through my Drupal theme.  Thanks again for helping!

UPDATE -- my previously noted selectors were too generic.  Turns out they selected the 2nd, 3rd and last items of each menu in the black toolbar across the top, not just the Quick Search.  Per Jon's suggestion, I overrode the Navigation.tpl and commented out the QuickSearch options we don't need.  Not ideal, by any means, but in the case with limited time, effective.
« Last Edit: July 18, 2014, 11:44:06 am by allenthehusband »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • custom jQuery to hide options in Quick Search

This forum was archived on 2017-11-26.