- Posts: 20
COMMUNITY FORUM
Add dropdown field to k2 user profile
- Tibbe van Asten
-
Topic Author
- Offline
- Junior Member
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
-
- Offline
- Platinum Member
- Posts: 15920
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
-
Topic Author
- Offline
- Junior Member
- Posts: 20
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
-
Topic Author
- Offline
- Junior Member
- Posts: 20
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
-
- Offline
- Platinum Member
- Posts: 15920
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
-
Topic Author
- Offline
- Junior Member
- Posts: 20
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
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Tibbe van Asten
-
Topic Author
- Offline
- Junior Member
- Posts: 20
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
-
- Offline
- Platinum Member
- Posts: 15920
<pre><?php echo var_dump($user); ?></pre>
Please Log in or Create an account to join the conversation.
- Tibbe van Asten
-
Topic Author
- Offline
- Junior Member
- Posts: 20
["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
-
Topic Author
- Offline
- Junior Member
- Posts: 20
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
- Posts: 8743
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
-
Topic Author
- Offline
- Junior Member
- Posts: 20
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
-
Topic Author
- Offline
- Junior Member
- Posts: 20
Can you give me an example?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
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
-
Topic Author
- Offline
- Junior Member
- Posts: 20
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.
- Kelsey Brookes
-
- Offline
- Elite Member
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
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.