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 (Moderator: Dave Greenberg) »
  • Custom data using data existing within CiviCRM
Pages: 1 [2]

Author Topic: Custom data using data existing within CiviCRM  (Read 3252 times)

rolevine

  • I’m new here
  • *
  • Posts: 13
  • Karma: 0
Re: Custom data using data existing within CiviCRM
August 16, 2010, 04:49:09 pm
Hopefully this is the last issue.  The autoComplete had no members in it so I check Firebug and each time I typed in the autocomplete I was getting a File 404 response.

So it looks like the ajax line with the URL is not correct:


      "/civicrm/ajax/rest?json=1&fnName=civicrm/contact/search&contact_type=organization&group[2]=1",

But I don't really not sure how to figure out how to make the pathing correct.

One last help?

Kind regards,
Rob


rolevine

  • I’m new here
  • *
  • Posts: 13
  • Karma: 0
Re: Custom data using data existing within CiviCRM
August 16, 2010, 05:54:18 pm
If I just enter http://<domain>/civicrm I get a File 404 so clearly I've missed a setup step somewhere?  I've been searching and searching to find out how one defines or sets up their /civicrm path but to no avail so far.

- Rob

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Custom data using data existing within CiviCRM
August 17, 2010, 11:30:58 pm
Hi,

as I wrote, it depends on your config.

View any contact and go to the tag tag.

Open firebug, go to the net tab, and check any tab, it fires an ajax event, the url is what you need to mimic (that will start differently than /civicrm)

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

rolevine

  • I’m new here
  • *
  • Posts: 13
  • Karma: 0
Re: Custom data using data existing within CiviCRM
August 18, 2010, 06:25:16 am
Hi X,

I know your day would not be complete without a question from me :).

I followed your instructions and I seem to be getting closer but I'm still not there.  The result is that the autocomplete still contains all contacts.  Below is the code I currently have in the CustomData.tpl file.  I've bolded the line with the URL I constructed.  I understand that the URL differs by config but can you at least give me your thoughts on whether you think mine is correct and, in addition, what other things I can check to see why my list is not limited.

NOTE:  If I run the ajax URL on its own (http://<domain>/administrator/index2.php?option=com_civicrm&task=civicrm/ajax/rest?json=1&fnName=civicrm/contact/search&contact_type=organization&group[2]=1) there are no errors and it sends me to my CiviCRM dashboard page.  Maybe that tells us something?

NOTE 2: There are no javascript errors in the CiviCRM page with the autocomplete field.

{literal}
<script type="text/javascript">
  jQuery(document).ready(function($) 
  { 
    var customGroup = "#customData2";//name of the table storing the custom fields
    var groupID = 2;// id of the group containing all the member clubs

    // the id of the custom fields change between calls, that's always in the form
    // custom_{id of the field}_{a number that changes based on the moon's phase or something}.
    //In our case, the custom field id is 9, so the id is going to be custom_9_, custom_9_2, custom_9_5 ...
   
    customid=$(customGroup + " input:first").attr('id');
    t=customid.split("_");
    suffix =  "_"+t[2];

    //first take out the default autocomplete that contains all the contacts,
    // and replaces it with one that contains only a subset,
    $("#custom_9"+suffix).unbind().autocomplete(
      "/administrator/index2.php?option=com_civicrm&task=civicrm/ajax/rest?json=1&fnName=civicrm/contact/search&contact_type=organization&group[2]=1",
    {
     dataType:"json",
     extraParams:{sort_name:function () {return $("#custom_9"+suffix).val();}},
     formatItem: function(data,i,max,value,term){ return value;},
     parse: function(data){
         var acd = new Array();
         for(cid in data){
           acd.push({ data:data[cid], value:data[cid].sort_name, result:data[cid].sort_name });
         }
         return acd;
     },
       width: 500,
       delay:50,
       max:200,
       mustMatch: true,
       autoFill:true,
       selectFirst: true
   })
  });
</script>
{/literal}

<script type="text/javascript">var showTab = Array( );</script>

{foreach from=$groupTree item=cd_edit key=group_id}   
   <div class="crm-accordion-wrapper crm-address-accordion crm-accordion-closed">
      <div class="crm-accordion-header">
         <div id="custom{$group_id}" class="icon crm-accordion-pointer"></div>
         {$cd_edit.title}
         </div><!-- /.crm-accordion-header -->
         
         <div id="customData{$group_id}" class="crm-accordion-body">
            {include file="CRM/Custom/Form/CustomData.tpl" formEdit=true}
         </div>
      <script type="text/javascript">
         {if $cd_edit.collapse_display eq 0 }
            var eleSpan          = "span#custom{$group_id}";
            var eleDiv           = "div#customData{$group_id}";
            showTab[{$group_id}] = {literal}{"spanShow":eleSpan,"divShow":eleDiv}{/literal};
         {else}
            showTab[{$group_id}] = {literal}{"spanShow":""}{/literal};
         {/if}
      </script>
   </div>
{/foreach}

{include file="CRM/common/customData.tpl"}

Regards,
Rob

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Custom data using data existing within CiviCRM
August 18, 2010, 06:47:14 am
This is an url that works:

/administrator/index2.php?option=com_civicrm&task=civicrm/ajax/rest&&entity_table=civicrm_contact&entity_id=103&tag_id=3&fnName=civicrm%2Fcontact%2Fsearch&json=1


And one that doesn't
/administrator/index2.php?option=com_civicrm&task=civicrm/ajax/rest?json=1&fnName=civicrm/contact/search&contact_type=organization&group[2]=1

The difference seems to be that the / are '%2F' (ie, url encoded). Try, experiment, don't know anymore, never used joomla.


(I won't be able to answer for the next coming days, good luck)

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

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Custom data using data existing within CiviCRM

This forum was archived on 2017-11-26.