Keyword

Add dropdown field to k2 user profile

  • Tibbe van Asten
  • Tibbe van Asten's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 7 months ago #132703 by Tibbe van Asten
Add dropdown field to k2 user profile was created by Tibbe van Asten
Hi there,

I'm an user of Joomla for quite a while now, but I'm new to K2. So far, I love the possibility's, but not evertything is easy adjustable. Can anyone help me with the following two questions:

1. I'm extended the profile page with a lot of fields. I did this through a 'hack' I found. Now I only miss one last field. I would like to create a dropdown list with personal titles (professor or something). To make this work, I have tried to add this to the registration.xml from com_users, but I just can't make it show up in my profile.php from com_k2.

2. How do I get to show all added field easy in the K2 user page?

I hope there is a simple solution to this.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #132704 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Add dropdown field to k2 user profile
How does this hack of yours work?

I would suggest that you used a K2 plugin like User Extended Fields.
While you cannot add new fields, you can use this plugin as a skeleton plugin to build upon.

This way you will not lose any changes when you update K2.

Please Log in or Create an account to join the conversation.

  • Tibbe van Asten
  • Tibbe van Asten's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 7 months ago #132705 by Tibbe van Asten
Replied by Tibbe van Asten on topic Re: Add dropdown field to k2 user profile
Excuse me for the late answer.

I have used a solution like this one: manchumahara.com/2010/03/18/how-to-add-extra-fields-in-joomla-registration/

I have also tried to install User Extended Field, but that leads to error.

Please Log in or Create an account to join the conversation.

  • Tibbe van Asten
  • Tibbe van Asten's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 7 months ago #132706 by Tibbe van Asten
Replied by Tibbe van Asten on topic Re: Add dropdown field to k2 user profile
I just installed User Extended Fields and added my custom field through the XML en PHP files.
But now I can't get the lay-out right.

I would like to the fields in a table very field in one row and some titles between fields.
Anyone know how to do this?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #132707 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Add dropdown field to k2 user profile
It is possible but you have to override K2's register and profile.php.
There is a foreach loop that prints fields from plugins.

More about overriding can be found here: getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

Please Log in or Create an account to join the conversation.

  • Tibbe van Asten
  • Tibbe van Asten's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 7 months ago #132708 by Tibbe van Asten
Replied by Tibbe van Asten on topic Re: Add dropdown field to k2 user profile
Thanks for the quick respons.

I have already made changes to register.php and user.php and the information is now showing up in on the userpage. But in the profile.php, all extra fields are dumped in just one table column. I would like to make one row per field. Is that possible?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 6 months ago #132709 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Add dropdown field to k2 user profile
Yes, you have probably omitted the closing </td> and </tr> tags in the loop that prints these fields.

Please Log in or Create an account to join the conversation.

  • Tibbe van Asten
  • Tibbe van Asten's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 6 months ago #132710 by Tibbe van Asten
Replied by Tibbe van Asten on topic Re: Add dropdown field to k2 user profile
The closing tags are still there. I have now solved it with the use of CSS.

One more question: is it possible to show one of the extra fields in the k2 users module. In this case, I would like to add the jobtitle to someone's name. I can't get the retrieval of just one value from the column right.

Hope you can help!

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 6 months ago #132711 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Add dropdown field to k2 user profile
What does the var_dump of $user in the module produce?
<pre><?php echo var_dump($user);  ?></pre>

Please Log in or Create an account to join the conversation.

  • Tibbe van Asten
  • Tibbe van Asten's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 6 months ago #132712 by Tibbe van Asten
Replied by Tibbe van Asten on topic Re: Add dropdown field to k2 user profile
The part of the user Extended Fields extension:
["plugins"]=>
  string(500) "{"userExtendedFieldsbirthday":"11-11-2011","userExtendedFieldsgender":"Vrouw","userExtendedFieldstitle":"drs.","userExtendedFieldsemployment":"Testbedrijf","userExtendedFieldsdepartment":"Testafdeling","userExtendedFieldsfunction":"Testfunctie","userExtendedFieldsaffiliated":"NARIM","userExtendedFieldsaddress":"","userExtendedFieldszipcode":"","userExtendedFieldscity":"","userExtendedFieldscountry":"","userExtendedFieldslinkedin":"","userExtendedFieldstwitter":"","userExtendedFieldsfacebook":""}"

Please Log in or Create an account to join the conversation.

  • Tibbe van Asten
  • Tibbe van Asten's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 6 months ago #132713 by Tibbe van Asten
Replied by Tibbe van Asten on topic Re: Add dropdown field to k2 user profile
No ideas on how to display the value of just one field from the User Extended Fields extention?

Please Log in or Create an account to join the conversation.

More
10 years 6 months ago #132714 by Lefteris
Replied by Lefteris on topic Re: Add dropdown field to k2 user profile
@Tibbe van Asten

Try this:
<?php
$fields = new JRegistry($user->plugins);
echo $fields->get('userExtendedFieldsbirthday'); 
?>

Please Log in or Create an account to join the conversation.

  • Tibbe van Asten
  • Tibbe van Asten's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 5 months ago #134173 by Tibbe van Asten
Replied by Tibbe van Asten on topic Add dropdown field to k2 user profile
Finally, I got it working in a K2 Users module! Thank you so much!!

In the K2 content module this is not working. Do you have an idea on that?

Please Log in or Create an account to join the conversation.

  • Tibbe van Asten
  • Tibbe van Asten's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 5 months ago #134305 by Tibbe van Asten
Replied by Tibbe van Asten on topic Add dropdown field to k2 user profile
Okay, I could not figure that out.
Can you give me an example?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 5 months ago #134345 by Krikor Boghossian
Replied by Krikor Boghossian on topic Add dropdown field to k2 user profile
Sorry I accidentally mislead you.
This plugin is not rendered in that module.
You can use an extrafield if you want to show additional information in that module.

Please Log in or Create an account to join the conversation.

  • Tibbe van Asten
  • Tibbe van Asten's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 5 months ago #134352 by Tibbe van Asten
Replied by Tibbe van Asten on topic Add dropdown field to k2 user profile
So there is no way to show a user extended field in the k2 content module?
An extrafield is not a solution for me, because it's item-related and not user-related.

Please Log in or Create an account to join the conversation.

More
8 years 11 months ago #154588 by Kelsey Brookes
Replied by Kelsey Brookes on topic Add dropdown field to k2 user profile
Hi Krikor, Lefteris,

Lefteris wrote this earlier:
<?php
$fields = new JRegistry($user->plugins);
echo $fields->get('userExtendedFieldsbirthday'); 
?>

Which works perfectly in mod_k2_users - what do I need to replicate this functionality within com_k2 user.php?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 11 months ago #154633 by Krikor Boghossian
Replied by Krikor Boghossian on topic Add dropdown field to k2 user profile
You meant the profile.php file?

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum