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

Add-on Global Variable

Discussion in 'Custom Service/Development Requests' started by Itworx4me, Nov 29, 2013.

  1. Itworx4me

    Itworx4me Well-Known Member

    I am in need of an add-on that will make this variable global $user.customFields.x. Willing to pay if not too extreme...lol

    Thanks,
    Itworx4me
     
    Last edited: Nov 29, 2013
  2. xf_phantom

    xf_phantom Well-Known Member

  3. Itworx4me

    Itworx4me Well-Known Member

    @xf_phantom I tired your suggestion and it didn't work.

    I have a custom user field that my users fill out. I am trying to call that custom field in many templates. Currently it doesn't work in thread_list_item. The only place I have been able to get the variable to work is message_user_info ({$user.cusomField.X}) Reason that I need the variable to be global for it to work in any template.

    Thanks,
    Itworx4me
     
  4. Itworx4me

    Itworx4me Well-Known Member

    I have been fighting this variable all day. I added the {xen:helper dump, $visitor} to the thread_list_item template. It tells me that the custom_fields variable is there to use. But when I try and use {$visitor.customFields.nick_name} it returns nothing. Can someone help me out on this one?

    Thanks,
    Itworx4me
     
  5. xf_phantom

    xf_phantom Well-Known Member

    And what happens if you use

    Code:
    {xen:helper userFieldValue, 'nick_name', $visitor, {$visitor.customFields.nick_name}}
     
  6. Itworx4me

    Itworx4me Well-Known Member

    @xf_phantom Here is my code:
    Code:
    <xen:if is="{$visitor.user_id}">
        <xen:username user="$thread" title="{xen:phrase thread_starter}" /><span class="startDate">,
    <xen:else />
        <a href="/login/login" class="username" itemprop="name">{xen:helper userFieldValue, 'nick_name', $visitor, {$visitor.customFields.nick_name}}</a>
    </xen:if>
    The new code you had me try does nothing.....

    Thanks,
    Itworx4me
     
  7. xf_phantom

    xf_phantom Well-Known Member

    it won't work because guests don't have custom fields;)

    Code:
    <xen:if is="{$visitor.user_id}">
    <xen:username user="$thread" title="{xen:phrase thread_starter}" /><span class="startDate">,
    <xen:else />
    <a href="/login/login" class="username" itemprop="name">{xen:helper userFieldValue, 'nick_name', $visitor, {$visitor.customFields.nick_name}}</a>
    </xen:if>
    the red code will ONLY be shown to guests and because they DON'T have userFields, it won't work;)
     
  8. Itworx4me

    Itworx4me Well-Known Member

    @xf_phantom You had me use $visitor.customFields when I was using $user.customFields
     
  9. Itworx4me

    Itworx4me Well-Known Member

    @xf_phantom I would be happy to pay you (with in reason) to make an add-on that will make $user.customFields.X global. Then I can use it in any template....

    Thanks,
    Itworx4me
     
  10. xf_phantom

    xf_phantom Well-Known Member

    I don't understand, what you want to accomplish

    You want to show the value of a userfield to guests?! (at least that's what your code from post 6 is trying to do)

    But guests don't have userfields?!
     
  11. Itworx4me

    Itworx4me Well-Known Member

    @xf_phantom
    http://xenforo.com/community/threads/hide-username.63831/#post-675271 This is where I got $user.customField.X from. I am using this code in message_user_info template.

    Hope this helps,
    Itworx4me
     
  12. xf_phantom

    xf_phantom Well-Known Member

    this http://xenforo.com/community/threads/hide-username.63831/#post-675024 ?

    then it should probably be
    Code:
    <xen:if is="{$visitor.user_id}">
    <xen:username user="$thread" title="{xen:phrase thread_starter}" /><span class="startDate">,
    <xen:else />
    <a href="/login/login" class="username" itemprop="name">{xen:helper userFieldValue, 'nick_name', $user, {$user.customFields.nick_name}}</a>
    </xen:if>
     
  13. Itworx4me

    Itworx4me Well-Known Member

    @xf_phantom
    I get this error:
    Template Errors: forum_view
    1. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    2. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    3. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    4. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    5. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    6. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    7. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    8. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    9. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    10. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    11. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/nitro/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    12. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    13. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    14. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    15. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    16. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/nitro/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    17. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    18. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/nitro/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    19. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    20. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
    Thanks,
    Itworx4me
     
  14. xf_phantom

    xf_phantom Well-Known Member

    about what exactly are we talking?:D

    I thought that you want to replace the message_user_info (2)
    1234.PNG

    You should really try to explain it better:p
     
  15. Itworx4me

    Itworx4me Well-Known Member

    @xf_phantom

    I am wanting to hide all usernames on my site and replace them with a custom field named Nick Name(user-id nick_name). I only want to show the nick name to registered and un-registered members. I have a usergroup Verified Members that I want to see peoples real name. So I am going through all the templates that deal with usernames and trying to replace them with the nick name. I need to be able to access the custom field from any template in xeforo. Hense why I am asking for it to be global...Sorry for not explaining it better.

    Itworx4me
     

Share This Page