Customer Portal

Get Involved. Join the Conversation.

Topic

    Janusz Jasinski
    Lazy loading workaround
    Topic posted November 6, 2019 by Janusz JasinskiSilver Crown: 22,500+ Points, last edited November 6, 2019 
    19 Views, 1 Comment
    Title:
    Lazy loading workaround
    Content:

    Hi,

    I have the following code which I know won't work but I was hoping someone had a simpler solution - for a contact that is logged in, I want to expose all their custom field values and dump them into an array called $a

    RNCPHP\ConnectAPI::getCurrentContext()->ApplicationContext = "Get contact information";
    $a = Array();
    $contact = json_encode($this->CI->session->getProfile(), true);
    $contact = json_decode($contact, true);
    $uid = $contact['c_id']['value'];
    $contact = RNCPHP\Contact::fetch($uid);
     
    foreach ($contact->CustomFields->c as $k) {
    $a[$k] = $contact->CustomFields->c->$k;
    }
    Any advice would be welcome
     
    I've tried curly brackets but this goes nowhere

    Comment

     

    • Kenton Banyai

      Personally, when retrieving information from the database while using a page on the site, I had 2 separate API calls, one would actually search for what I needed and then one to search that table. For example, I had an api search our contacts by ID, then once it found that contact, i used another api to append to that, so you can search tables a layer down. Not sure if this is best practice, but it is how I got it to work.