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 »
  • Using Profiles (Moderator: Dave Greenberg) »
  • current employer autocomplete
Pages: [1]

Author Topic: current employer autocomplete  (Read 1451 times)

Yoda_Oz

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 3.3.3
  • CMS version: Joomla 1.5.22
current employer autocomplete
June 26, 2010, 02:45:25 am
im trying to learn the API and i'm not really sure where to put the code said in the manual regarding a current employer autocomplete. basically which file do i edit???

in the manual:
Code: [Select]
Autocomplete and search contacts
If you create a profile for individual contacts that contains the current employer, you might want to add an autocomplete on that field, such as you have on the normal contact edit form. When a user starts to type the name of the current employer, the system will attempt to autocomplete the name from your database of organisation contacts.
For security reasons, the Ajax interface is restricted to users who have access to CiviCRM - otherwise, it would be fairly easy for anyone to download all the contacts you have in your database. So that's the first thing we check for here:
{if $session->get('userID') > 0}

<script type="text/javascript" src="{$config->resourceBase}js/rest.js"></script>{literal}
<script>
jQuery(document).ready(function($){
  $('#current_employer').crmAutocomplete({params:{contact_type:'Organization'}});
});
</script>
{/literal}

{/if}
You might want to add additional filters. For instance in a profile "new volunteer from a member", you want to populate the list only with the organisations that belong to the group "members" (group id 42).

$('#current_employer').crmAutocomplete({params:{contact_type:'Organization',group:42}});

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: current employer autocomplete
June 28, 2010, 12:36:24 am
In the custom template that override the template for the profile (either specific for this profile or all profiles).

You might want to read the relevant chapter on templates that is aimed at answering these questions:

http://en.flossmanuals.net/CiviCRM/DevelopTemplates

Please tell me if something wasn't clear.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: current employer autocomplete
June 28, 2010, 12:37:58 am
btw, crmAutocomplete has only been introduced on 3.2 if my memory serves me right. You have example in the blog of a slightly longer version that works on 3.1.x

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Yoda_Oz

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 3.3.3
  • CMS version: Joomla 1.5.22
Re: current employer autocomplete
June 28, 2010, 12:52:54 am
that's strange!
* i put the code in custom_templates/CRM/Contribute/Form/Contribution/Main.tpl
* i created a field in a profile called Current Employer (using the default current employer field).
* i opened the profile...
...and it didn't work.

is there anything else i need to do do make the code work?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: current employer autocomplete
June 28, 2010, 06:21:32 am
Err, not sure

1) verify that civi is taking into account your custom directory. Override an easy to spot one, eg put a "Here be dragons" in your custom
CRM/Contact/Page/DashBoard.tpl

and see if you see that instead of your normal dashboard

2) Check the wiki, but the file to modify the templates aren't the one you tried to modify, they should be around templates/CRM/Profile/Form/
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Yoda_Oz

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 3.3.3
  • CMS version: Joomla 1.5.22
Re: current employer autocomplete
June 28, 2010, 07:20:52 am
yeah, custom php directory definitely working...

also, this is taken from a view source when at the same page the form is on:
Code: [Select]
<!-- .tpl file invoked: CRM/Contribute/Form/Contribution/Main.tpl. Call via form.tpl if we have a form in the page. -->
so im assuming that it is the correct tpl file to be editing, yes?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: current employer autocomplete
June 28, 2010, 07:38:52 am
1) That's not the custom php directory, that's the custom template, right ?

2) templates might includes other templates, and the templates for profiles are often included elsewhere.

3) this being said, the javascript source to include the autocomplete should be executed anyway. Are you sure you have it in the source of the page ?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Yoda_Oz

  • I post occasionally
  • **
  • Posts: 107
  • Karma: 2
  • CiviCRM version: 3.3.3
  • CMS version: Joomla 1.5.22
Re: current employer autocomplete
June 29, 2010, 03:06:22 am
yeah.
i already have both custom php and custom template directories set up and they are both working correctly as i have other customisations and they work perfectly thanks to some help from the folks at webaccess.

here are some screenshots:
1. current employer enabled in the backend in profile.
http://img819.imageshack.us/img819/2605/screenshot20100629at802.png
2. safari's web inspector showing the script in the source.
http://img693.imageshack.us/img693/1329/screenshot20100629at803.png

anyway, i appreciate the assistance and patience you are giving :)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • current employer autocomplete

This forum was archived on 2017-11-26.