Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Younes Nachar
    How to expose ContactType ctype_Id in contacts?
    Topic posted September 21, 2011 by Younes NacharRed Ribbon: 250+ Points, last edited October 29, 2011 
    1623 Views, 24 Comments
    Title:
    How to expose ContactType ctype_Id in contacts?
    Content:

    I need to expose ctype_id contact type for the customer portal pages. Any idea? 

    Comment

    • Younes Nachar

      Ryan,

      The hook is working as I am getting the value saved and retrieved from the session within the model function. 

      I cannot get the value to the page from the session!!!

    • Younes Nachar

       Ryan,

      Somehow the esession get wipe off somewhere. I used the cookie and I can get it to the page now.

      Now, I need to be able to pass in teh c_id (contact id) as a parameter of that function. How can I do that?

      On you previous post you said that you can pass it by reference but how? Will just &$c_id in the method header be enough?

      Thanks,

    • Ryan Seltzer

      No, pass in &arr and then dump out $arr in the code to see everything in there you have access to.  That is what you can utilize in your code in the hook.

    • Younes Nachar

       Ryan,

      The question is where to pass in &arr?

      so far I have three pieces:

      1. The page that displays the data.

      2. The hooks.php

      3. The model (contact_model_custom)

      Where in those I should pass the &arr and how?

      Thanks,

    • Ryan Seltzer

      You pass in the &arr to the function in your custom model which is called by the 'function' attribute in your $RnHooks declaration from hooks.php.

       

      So the file to modify is your custom model.  Pass the function (set_ctype in my case) the &arr

       

      From my earlier post

       

      function set_ctype(&$arr)
      {
         $arr['data'] = ......

         //do stuff here and check out what all is in $arr by dumping it out.

      }

    • Younes Nachar

       Ryan,

      Here is what I added:

      function set_ctype(&$arr)
      {
          print_r($arr); // I am getting 'Array()'

          $ctype_id = sql_get_int('SELECT c_id from contacts where c_id = ' . intval($contactID));

      }

      I am trying to get a c_id (contactId of the current logged in user into this method) passed to the method above.

       

    • Ryan Seltzer

      Thats because you are still probably trying this with the pre_page_render hook which has an empty array passed to it.  This is what I was trying to point out to you earlier to help with overall understanding of what is going on with hooks.  You can determine what data is passed into the hook (into $arr) by looking at the code from where the hook is called.  For example, you can see here how the pre_page_render hook is called by the standard page controller (notice the empty array).

      $preHookData = array();
      RightNowHooks::callHook('pre_page_render', $preHookData);

       

      The post_login hook however is different and actually passes data to the hook.  In the standard contact model for example if looks like this

       

      $postHookData = array('returnValue'=>$newProfile, 'data'=>array('source'=>'LOCAL'));
      RightNowHooks::callHook('post_login', $postHookData);

       

      So you can see that it is passing data to that hook.

    • Younes Nachar

       Ryan,

      When I use the 'post_login' hook I cannot login! Do you know why?

    • Younes Nachar

      Ryan,

      When I use the 'post_login' hook I cannot login! Do you know why?

      I cannot get it to work with 'post_login' as it hangs in the login screen!!!