TheJackal84 Posted April 20, 2017 Posted April 20, 2017 Ok so I am creating a plugin for the user info panel on the topics and its basically a social info block, I have gone for adding the custom fields via the database on installing the plugin as it is the only way I have figured out how to add custom fields without having the user have to go into admin settings and manually add the custom fields to the members profile. Here's part of the install code public function step1() { \IPS\Db::i()->insert( 'core_pfields_groups', array( 'pf_group_id' => 998, 'pf_group_order' => 998, ) ); \IPS\Db::i()->insert( 'core_pfields_data', array( 'pf_id' => 9995, 'pf_content' => '[]', 'pf_type' => 'Url', 'pf_not_null' => 0, 'pf_member_hide' => 0, 'pf_max_input' => 0, 'pf_member_edit' => 1, 'pf_show_on_reg' => 0, 'pf_input_format' => NULL, 'pf_admin_only' => 0, 'pf_format' => '<span class="mem_SocialInfo ipsResponsive_hidePhone"> <a href="{content}" class=" " target="_blank" title="{title}: {content}"><i class="fa fa-globe fa-2x" aria-hidden="true"></i> </a> </span>', 'pf_group_id' => 998, 'pf_search_type' => 'loose', 'pf_filtering' => 0, 'pf_multiple' => 0, ) ); return TRUE; } The problem I am having is when I installed it without any language the profile field names come up as core_pfieldgroups_998 and core_pfield_9995 and it don't show in the users edit profile bit, So I added to the lang.php 'core_pfieldgroups_998' => "Social Info", 'core_pfield_9995' => "Website", 'core_pfield_9995_desc' => "Enter your website URL", And everything shows and the language is there and so is the descriptions in the edit bit the only problem is when a user tries to save it, it will throw a configuration error up saying IPS\Db\Exception: Unknown column 'field_9995' in 'field list' (1054) I take it, it is because of the name of the column because if I go into the member profile settings and then just click copy and delete the older one, I get no error on saving it so I am taking it that it has something to do with me adding the names to the language and the system can't locate the column. Does anyone know how I can fix this?
bfarber Posted April 20, 2017 Posted April 20, 2017 You need to add the fields (field_X) to core_pfields_content. That said, I'd probably not insert directly with hardcoded ids. While you aren't likely to run into conflicts, you WILL be resetting the auto-increment value artificially high. You can create fields by creating a new instance of IPS\core\ProfileFields\Group and IPS\core\ProfileFields\Field and saving the object you create.
TheJackal84 Posted April 20, 2017 Author Posted April 20, 2017 1 hour ago, bfarber said: You need to add the fields (field_X) to core_pfields_content. That said, I'd probably not insert directly with hardcoded ids. While you aren't likely to run into conflicts, you WILL be resetting the auto-increment value artificially high. You can create fields by creating a new instance of IPS\core\ProfileFields\Group and IPS\core\ProfileFields\Field and saving the object you create. Where in the core_fields_content will I add it? I did notice the auto-increment on it so I will look for some other ways, I have looked for some tutorials on creating instances for it but have had no luck the profile fields is a subject that don't seem to come up in the dev area anywhere. Sorry for the bother I am still learning but I am completely hooked on developing plugins lol I was also wondering if there will be a lot of changes to the way the dev works from 4.1 to 4.2 and will a lot of plugins / apps need to be re-wrote or will you be basically using the same divisions and elements the themes you use now with a few updated ones, I have created 2 plugins already and don't know whether to release them now or wait till 4.2 is released in-case they need a lot of changes
bfarber Posted April 20, 2017 Posted April 20, 2017 1 hour ago, TheJackal84 said: Where in the core_fields_content will I add it? I did notice the auto-increment on it so I will look for some other ways, I have looked for some tutorials on creating instances for it but have had no luck the profile fields is a subject that don't seem to come up in the dev area anywhere. I meant you need to add columns to the database table itself. If you create a new instance of \IPS\core\ProfileFields\Field and call save() against it, this is done automatically for you. 1 hour ago, TheJackal84 said: Sorry for the bother I am still learning but I am completely hooked on developing plugins lol I was also wondering if there will be a lot of changes to the way the dev works from 4.1 to 4.2 and will a lot of plugins / apps need to be re-wrote or will you be basically using the same divisions and elements the themes you use now with a few updated ones, I have created 2 plugins already and don't know whether to release them now or wait till 4.2 is released in-case they need a lot of changes Hard to say, but we will release notes for developers in due course.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.