Customer Portal

Get Involved. Join the Conversation.

Topic

    domn
    Passing Contact Variables Through a URLAnswered
    Topic posted February 11, 2009 by domn Bronze Medal: 1,250+ Points, last edited October 29, 2011 
    1421 Views, 8 Comments
    Title:
    Passing Contact Variables Through a URL
    Content:

    In 7.5 we're using the following code in the myovr_ext file to pass contact ID, first, last name and a custom feild.

     

    <?} //retrieve value of the custom field from profile. $custom_field_val = sql_get_str(sprintf('SELECT c$promo FROM contacts WHERE c_id = %d', $profile->c_id), 1); //need to convert retrieved 1 or 0 to yes or no if ($custom_field_val == "1") {c$promo = "yes"; } else {$promo = "no"; } //modify the desc string to have all the correct text and multiple links. //$scrambled = base64_encode ($profile->customer_id); $scrambled = "customer_id=". base64_encode ($profile->c_id); $scrambled = $scrambled . "&email_address=". base64_encode ($profile->email); $scrambled = $scrambled . "&first_name=". base64_encode ($profile->first_name); $scrambled = $scrambled . "&last_name=". base64_encode ($profile->last_name) ; $scrambled = $scrambled . "&market=". $promo; $desc = "Click on the product name to REGISTER your product or MODIFY your previous product registration: ". "<a href=\"http://www.canon.ca/english/index-product_registration.asp?".$scrambled."&f=1\" target=\"_top\">EOS Digital SLR</a>

     

     

    This code doesn't seem to work in Nov 08. The proper page loads but without the contact info. I don't think any of the contact variables have changed? Any siggestions on what needs to be changed?

    Best Comment

    Ernie Turner

    I would strongly suggest putting this code into a custom widget. With the amount of PHP that you're doing, I think that would be much cleaner. In Customer Portal the way in which you access contact information is much different. I've posted a similar post here about how to access the information. Within CP, the $profile variable doesn't exist and you need to use

     

     

    $this->session->getProfileData(index) [If within page]


    or

    $this->CI->session->getProfileData(index); [If within widget]

     

     

    Where 'index' is the information you want to retrieve. So, for your needs, contact ID, first/last name and email, you would use

     

    [If within page]
    $this->session->getProfileData('c_id');
    $this->session->getProfileData('first_name');
    $this->session->getProfileData('last_name');
    $this->session->getProfileData('email');

    [If within widget]
    $this->CI->session->getProfileData('c_id');
    $this->CI->session->getProfileData('first_name');
    $this->CI->session->getProfileData('last_name');
    $this->CI->session->getProfileData('email');

     

    Comment

     

    • Ernie Turner

      So are you trying to use the 7.5 code you have below in Customer Portal? Are you putting this code within a view page or within a custom widget?. I'm pretty sure we can do this within CP, but I wanted to make sure I knew exactly what you were trying to accomplish first.

       

      Also, as a suggestion, there is a 'Code Insert' button in the post toolbar (two icons to the left of the smiley face) which will help code readability and stop it from producing smiley faces.

    • domn

      Yes, trying to use the code we have in 7.5. I'm putting this code into a page. overview.php to be exact.

       

      Thanks for the suggestion. Fixed the first post.

    • Ernie Turner

      I would strongly suggest putting this code into a custom widget. With the amount of PHP that you're doing, I think that would be much cleaner. In Customer Portal the way in which you access contact information is much different. I've posted a similar post here about how to access the information. Within CP, the $profile variable doesn't exist and you need to use

       

       

      $this->session->getProfileData(index) [If within page]


      or

      $this->CI->session->getProfileData(index); [If within widget]

       

       

      Where 'index' is the information you want to retrieve. So, for your needs, contact ID, first/last name and email, you would use

       

      [If within page]
      $this->session->getProfileData('c_id');
      $this->session->getProfileData('first_name');
      $this->session->getProfileData('last_name');
      $this->session->getProfileData('email');

      [If within widget]
      $this->CI->session->getProfileData('c_id');
      $this->CI->session->getProfileData('first_name');
      $this->CI->session->getProfileData('last_name');
      $this->CI->session->getProfileData('email');

       

    • domn
      Thank you very much eturner, that worked fine within the page. I'll work on using a custom widget instead.
    • MikeP

      Ernie,

        Is there a list of all the ProfileData indexes.  I am currently looking for org_id and session_id.

       

      Thanks

    • MikeP

      I think I answered my own question. 

       

       

      CP May 09 - API Documentation\doc\class_profile.html

       

       

    • Ernie Turner

      Yes, go to the Business Object page in the tag gallery for your site. In there you will see a grid of all the available profile fields.

       

      The session ID is not part of the Profile object, it is part of the Session object. To retrieve that value do

       

      [If within page]
      $this->session->getSessionData('sessionID');

      [If within widget]
      $this->CI->session->getSessionData('sessionID');

       [Edit] - Oops, didn't see your reply. Yes, that information is also available in the Documentation.

    • MikeP

      I have never been able to find the SessionID retrieval method documented.  I gave up and created a model to retrieve it. I still don't find it in Business Models.  So your post was delightful.

       

       

      Thanks

      Mike