• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How can I pull the twitter Var from

DarkVodka

Formerly Wuebit
#1
PHP:
                            <xen:if is="{$identities}">
                                <xen:foreach loop="$identities" value="$identity">
                                    <dl><dt>{$identity.title}:</dt> <dd>{xen:string censor, $identity.value}</dd></dl>
                                </xen:foreach>
                            </xen:if>
For example if someone adds there twitter account in "Contact Details"
Than on there profile under the information tab there is

Twitter: Vodkaholic27

I need the var (output) for the user name, I can't seem to find it anywhere other than the code above..

Thanks
 
R

ragtek

Guest
#2
PHP:
$userModel = $this->getModelFromCache('XenForo_Model_User');
$identities = $userModel->getIdentities(XenForo_Visitor::getUserId());
and then you can access it via $identities['...']
 

DarkVodka

Formerly Wuebit
#3
PHP:
$userModel = $this->getModelFromCache('XenForo_Model_User');
$identities = $userModel->getIdentities(XenForo_Visitor::getUserId());
and then you can access it via $identities['...']
ragtek am not as good as you :D
So $identities['...'] will pull the users twitter name ?
Still trying to learn sorry :C
 

James

Well-known member
#8
Ragtek posted the PHP for a listener (I think). If the $identities variable is exposed where you want it, you could probably just use it in templates.
 

James

Well-known member
#12
I think there's a tutorial here that explains how to make variables available in custom templates. I'll have a search.
 

Bob

Well-known member
#14

I did try $identities['twitter'] and $identities['7'] yesterday.. didn't work tho hmm
First question, are you passing $identities into the template? (is this from the listener you were working on last night).... and if so, identities is an array, so you need to access the twitter part of the array like this.. {$identities.twitter} and if you wanted say google talk it would be {$identities.gtalk}
 

DarkVodka

Formerly Wuebit
#15
First question, are you passing $identities into the template? (is this from the listener you were working on last night).... and if so, identities is an array, so you need to access the twitter part of the array like this.. {$identities.twitter} and if you wanted say google talk it would be {$identities.gtalk}
Hey no Ive not added anything in php yet about this. (same listener as last night aye)
I tryed adding {$identities.twitter} in the template but also didn't work

You're better off creating a mod/add-on. Take a look at Kiers tutorial in the tutorial section.
This is what am trying to do :( right now (make an addon)
 

DarkVodka

Formerly Wuebit
#16
Hmm would it be {$user.id}{$identities.twitter} something like that so it knows to pull each members twitter name?

Am just trying everything and anything atm can't seem to work this out... Need more learning :C
 

James

Well-known member
#17
The 2 variables won't do anything.

Put this code into your template:
Code:
{xen:helper dump, $identities}
This will dump the identities array if it exists, or return NULL if it doesn't.

If it returns null, replace the above code with:
Code:
{xen:helper dump, $user}
and see if the identity service is part of the $user array.
 

James

Well-known member
#19
It's a custom template isn't it? I think you need to expose the variables to custom templates. Check the Have You Seen...? section for a tutorial, I'm sure Kier posted one...