Post

1 follower Follow
0
Avatar

Example on best practise with items->getValue() or getfieldvalue()

Hello everybody,

I am not a professional programmer - so please forgive me for asking basics :)

I am working with the API (php client) and I am trying to find the best way how to get the current values from an item. I am having real difficulties working with the returned array from the getValue()  or getfieldvalue() function. Right now I am basically doing everything manually just to get to the values of an item.

So you better understand my dilemma - here is my approach right now:

$pvalues = array();

$pvalues['vorname'] = $podioapi->item->getfieldvalue(item_id,field_id); _

_$pvalues['nachname'] = $podioapi->item->getfieldvalue(item_id,field_id);


_ $pvalues['anrede'] = $podioapi->item->getfieldvalue(item_id,field_id);_

_ $pvalues['title'] = $podioapi->item->getfieldvalue(item_id,field_id);_

_ $pvalues['email'] = $podioapi->item->getfieldvalue(item_id,field_id); _

$pvalues['status'] = $podioapi->item->getfieldvalue(item_id,field_id);

_ $pvalues['sprache'] = $podioapi->item->getfieldvalue(item_id,field_id); _

$pvalues['anmeldung'] = $podioapi->item->getfieldvalue(item_id,field_id);

_ $pvalues['letztes-update'] = $podioapi->item->getfieldvalue(item_id,field_id);_

Checking the output - accessing the actual field values:

echo $pvalues['vorname'][0]['value']."<br/>"; _

_echo $pvalues['nachname'][0]['value']."<br/>"; _

_echo $pvalues['anrede'][0]['value']."<br/>"; _

_echo $pvalues['title'][0]['value']."<br/>"; _

_echo $pvalues['email'][0]['value']."<br/>";


_ echo $pvalues['status'][0]['value']['id']."<br/>"; _

echo $pvalues['sprache'][0]['start']."<br/>";

There has to be a faster and easier way right?

Maybe you can give me a hint on how to approach this in an php environment!!

Thank you so much for the help!

Michael

Michael Winterheller Answered

Please sign in to leave a comment.

4 comments

0
Avatar

Hi Michael,

I must urge you to seek out some general PHP tutorials if you do not have much experience with programming. Otherwise you will have trouble every step of the way. At the very least you need to be comfortable working with arrays.

For this question: It's not convenient to fetch each value individually. You should get the entire item using:

$item = $api->item->get($item_id);

Then you can loop over all the fields in $item['fields']

Andreas Haugstrup Pedersen 0 votes
0
Avatar

Hej Andreas,

I saw that answer coming :) You are def. right - but with your hint I managed to loop through the fields and everything is working as expected. The next steps I will hand over to the pros.

Thank you for the fast response

Michael

Michael Winterheller 0 votes
0
Avatar

Hi Michael,

Happy to hear you got it working. :)

You should always feel free to ask Podio specific questions here. For example which methods are best to use to reach a specific goal. We just don't have the manpower to teach you PHP :)

All the best,

Andreas

Andreas Haugstrup Pedersen 0 votes
0
Avatar

Andreas,

no doubt - so far I have had a superb experience with both the product and the team at podio. 

Thanks again

Michael

Michael Winterheller 0 votes