solved Display Signup form field on Profile

Elise
Elise
@elise
8 years ago
249 posts
I'm using the default Signup field. With the Form Designer, I added a field user_about. I would like to display this field on the user's profile.

I'm in skin/profile_sidebar.tpl (my location of choice)
What's the syntax to display that new field (user_about from the signup form field).

Thanks!
updated by @elise: 12/17/16 07:37:35PM
Elise
Elise
@elise
8 years ago
249 posts
Ah this seems to be the winner:
{$_user['user_about']}
michael
@michael
8 years ago
7,714 posts
The issue here is you're adding Form Fields to collect additional USER information, then wanting to display that as PROFILE information.

It will be available everywhere the user is looking on the {$_user.user_about} variable, but the $_user variable is the 'user looking at the screen' so probably not what you're wanting.

Will get a coffee and have a think about how it could be done. back soon.
Elise
Elise
@elise
8 years ago
249 posts
LOL good point. Paul did it for strumelia so it's doable!
michael
@michael
8 years ago
7,714 posts
Paul has done this in the profile_sidebar.tpl file:
{$_ut = jrCore_db_get_item('jrUser', $_user_id)}

He's taken the {$_user_id} which is the user id that is associated with the profile being viewed, then retrieved it from the datastore.

If you want to know what is available in that $_ut, then you can put debug after it and it will appear in the debug console:
 {$_ut = jrCore_db_get_item('jrUser', $_user_id)}
{debug}

Your desired info will be there PROVIDED $_user_id is an actual number value in the location you're trying to use it. Not all variables are the same in all templates. $_user_id should be there anywhere in the profile section though and refer to the user id of the profile owner.

You can then access stuff in that array in the usual way:
{$_ut.user_location}
or
{$_ut['user_location']}
are exactly the same, just different notation.
Elise
Elise
@elise
8 years ago
249 posts
I'm in the Ningja profile_sidebar.tpl and I don't see the magic of finding the "profile being viewed" to user id translation.

If I just use
{$_ut = jrCore_db_get_item('jrUser', $_user_id)}
I'll get *my* location on every profile?
paul
@paul
8 years ago
4,326 posts
Elise:
I'm in the Ningja profile_sidebar.tpl and I don't see the magic of finding the "profile being viewed" to user id translation.
If I just use
{$_ut = jrCore_db_get_item('jrUser', $_user_id)}
I'll get *my* location on every profile?

No the $_user_id variable is the ID of the user that belongs to the profile being viewed, so using the above smarty code in the template will assign all the data for that user to array variable $_ut, including the custom field 'user_about' so in the template, after that assignation, just use {$_ut.user_about} where you want to show that info.
Note that in almost every Jamroom template the array variable $_user is already available and that is the data of the logged in user (you) viewing the site.
hth


--
Paul Asher - JR Developer and System Import Specialist
michael
@michael
8 years ago
7,714 posts
In most locations on the profile you will find a {$_profile} section in the profiles, the {$_user} variable is the user looking at the screen, but in that template the {$_profile} array has been expanded out into individually callable variables for readability.

So where normally you might need to type {$_profile._user_id} to get the user_id of the profile that is being looked at, in this template all of the sub variables of the $_profile array have been exploded to their own stand alone variables, so {$_user_id} is the variable of the profile being looked at.

You can test this by putting:
THE PROFILE NAME IS {$profile_name} and the user_id is {$_user_id}
into that template, then switch between profiles and watch it change. If its you then the sentence wont change. (but it will)

--edit--
If you use {$_user._user_id} you will get your info on every page.
updated by @michael: 09/15/16 04:51:42AM
Elise
Elise
@elise
8 years ago
249 posts
Ooooo I see. Wow that is some serious magic. Thanks!!!
paul
@paul
8 years ago
4,326 posts
I assume you know about using {debug} in templates? Its an essential tool when developing templates - https://www.jamroom.net/the-jamroom-network/documentation/jamroom-developers-guide/1477/debug


--
Paul Asher - JR Developer and System Import Specialist
Elise
Elise
@elise
8 years ago
249 posts
I wish I could print out a {brain_debug} so you can see everything I know and find what's missing ;)

Yes, I found the debug along my meandering. That is a great help. I have and Admin only menu in Site Builder that leads to a test page when I print this stuff out for my viewing pleasure.

Thanks!
paul
@paul
8 years ago
4,326 posts
fdebug can be useful as well. It dumps specific variables to the debug log that you can view in your ACP Dashboard. Its mainly used when coding/debugging php but it works in templates as well - {fdebug($_user, $_profile_id)} (insert whatever variables you want dumping).


--
Paul Asher - JR Developer and System Import Specialist

Tags