1. 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

Discussion in 'XenForo Development Discussions' started by Wuebit, Apr 17, 2011.

  1. Wuebit

    Wuebit Well-Known Member

    PHP:
                                <xen:if is="{$identities}">
                                    <
    xen:foreach loop="$identitiesvalue="$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
     
  2. ragtek

    ragtek Guest

    PHP:
    $userModel $this->getModelFromCache('XenForo_Model_User');
    $identities $userModel->getIdentities(XenForo_Visitor::getUserId());
    and then you can access it via $identities['...']
     
    Vodkaholic likes this.
  3. Wuebit

    Wuebit Well-Known Member

    ragtek am not as good as you :D
    So $identities['...'] will pull the users twitter name ?
    Still trying to learn sorry :C
     
  4. James

    James Well-Known Member

    Between the brackets you'll have to use the service ID probably. $identities['twitter'].
     
  5. Wuebit

    Wuebit Well-Known Member

    Yup but how do I find the Service ID. Any ideas?
     
  6. James

    James Well-Known Member

    admin.php?identity-services/twitter/edit

    Service ID: twitter
     
  7. Wuebit

    Wuebit Well-Known Member

    Thanks James. Last question do I have to use the php ragtek posted ?
    Am not quite sure where I would add that.. atm I only have one php file listener
     
  8. James

    James Well-Known Member

    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.
     
  9. Wuebit

    Wuebit Well-Known Member

    I did try $identities['twitter'] and $identities['7'] yesterday.. didn't work tho hmm
     
  10. James

    James Well-Known Member

    Which template? I'll see if I can get it working.
     
  11. Wuebit

    Wuebit Well-Known Member

    Custom
     
  12. James

    James Well-Known Member

    I think there's a tutorial here that explains how to make variables available in custom templates. I'll have a search.
     
  13. Nasr

    Nasr Well-Known Member

    You're better off creating a mod/add-on. Take a look at Kiers tutorial in the tutorial section.
     
  14. Bob

    Bob Well-Known Member


    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}
     
  15. Wuebit

    Wuebit Well-Known Member

    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


    This is what am trying to do :( right now (make an addon)
     
  16. Wuebit

    Wuebit Well-Known Member

    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
     
  17. James

    James Well-Known Member

    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.
     
  18. Wuebit

    Wuebit Well-Known Member

    Both returned as NULL
     
  19. James

    James Well-Known Member

    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...
     
  20. Wuebit

    Wuebit Well-Known Member

    Aye I have that's why am here because am stuck :( oh well thanks away James
     

Share This Page