Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted December 17, 20177 yr Hi, How can I populate a select box in my plugin settings page with i.e. all the forums? I now have a field where one would put the forum ID in, but it would be nicer for the user to be able to select the forum from a dropdown box and then saves the ID as setting. Chris
December 20, 20177 yr Author Ok got that one sorted with the following code: $form->add( new \IPS\Helpers\Form\Node( 'setting_name', \IPS\Settings::i()-> setting_name ? \IPS\Settings::i()->setting_name : 0, FALSE, array( 'class' => 'IPS\forums\Forum', 'zeroVal' => 'use_cat_forum' ), NULL, NULL, NULL, 'setting_name' ) ); Now I need to find out how to display all profile fields (and a seperate one for the profile field groups)
December 20, 20177 yr 6 minutes ago, ChrisVanMeer said: Now I need to find out how to display all profile fields (and a seperate one for the profile field groups) The same way but use IPS\core\ProfileFields\Group as class param
December 20, 20177 yr Author Awesome, got that one sorted as well. I now see the full node and I want to populate three \IPS\Settings values > With the profile field group id With the profile field id With the profile field name I can't seem to find documentation on how to use one Node / Select box in the settings.php to store to multiple settings values. Plus, how can I echo the contents of a \IPS\Settings value, so I can see what values are being stored in it?
December 20, 20177 yr Not sure what you mean. To select multiple values add 'multiple' => true, to options $form->add( new \IPS\Helpers\Form\Node( 'setting_name', \IPS\Settings::i()-> setting_name ? \IPS\Settings::i()->setting_name : 0, FALSE, array( 'multiple' => true, 'class' => 'IPS\forums\Forum', 'zeroVal' => 'use_cat_forum' ), NULL, NULL, NULL, 'setting_name' ) );
December 20, 20177 yr Author Ok I will try to clarify. I have this form below. Let's say that I click on About Me I then want the following to happen when I save the settings Save the ID of the Personal Information group to \IPS\Settings::i()->cvm_profile_group_id Save the ID of the About Me field to \IPS\Settings::i()->cvm_profile_field_id Save the name About Me to \IPS\Settings::i()->cvm_profile_field_name
December 20, 20177 yr 10 minutes ago, ChrisVanMeer said: I then want the following to happen when I save the settings Why? 10 minutes ago, ChrisVanMeer said: Save the name About Me to \IPS\Settings::i()->cvm_profile_field_name It's multilang value Store only field ID. Then get the field by ID. No need create separate setting for each field param
December 20, 20177 yr Author 14 minutes ago, newbie LAC said: Why? Because I have the following class: public function get_required_profile_field() { try { $setting = \IPS\Member::loggedIn()->profileFields(); $groupID = \IPS\Settings::i()->cvm_profile_field_group_id; $groupID = "core_pfieldgroups_$groupID"; $fieldID = \IPS\Settings::i()->cvm_profile_field_field_id; $fieldID = "core_pfield_$fieldID"; $field = $setting[$groupID][$fieldID]; if ($field != "") { return true; } else { return false; } } catch ( \RuntimeException $e ) { throw $e; } } I need to fill at least the core_pfieldgroups_<id> and core_pfield_<id>
December 20, 20177 yr 1 hour ago, ChrisVanMeer said: I need to fill at least the core_pfieldgroups_<id> and core_pfield_<id> 1 hour ago, newbie LAC said: Then get the field by ID. try { $fieldObj = \IPS\core\ProfileFields\Field::load(\IPS\Settings::i()->cvm_profile_field_field_id); $fieldID = "core_pfield_{$fieldObj->_id}"; $groupID = "core_pfieldgroups_{$fieldObj->group_id}"; } catch (\Exception $e) { }
December 20, 20177 yr Author Almost got it, but can't find the equivalent of array( 'class' => 'IPS\core\ProfileFields\Group' ) for the single profile field ID. When I now select About Me, it saves the ID of the group, not the field.
December 21, 20177 yr 16 hours ago, ChrisVanMeer said: Almost got it, but can't find the equivalent of array( 'class' => 'IPS\core\ProfileFields\Group' ) for the single profile field ID. From my previous post Quote \IPS\core\ProfileFields\Field 16 hours ago, ChrisVanMeer said: When I now select About Me, it saves the ID of the group, not the field. I reported about that sometime ago The stored value is 1 but should be 1.s
December 21, 20177 yr Author 4 hours ago, newbie LAC said: \IPS\core\ProfileFields\Field $form->add( new \IPS\Helpers\Form\Node( 'cvm_profile_field_field_id', \IPS\Settings::i()->cvm_profile_field_field_id ? \IPS\Settings::i()->cvm_profile_field_field_id : 0, FALSE, array( 'class' => 'IPS\core\ProfileFields\Field' ), NULL, NULL, NULL, 'cvm_profile_field_field_id' ) );
December 21, 20177 yr Congratulations! You found a bug. Quote Access to undeclared static property: IPS\core\ProfileFields\Field::$nodeTitle If the form field type doesn't matter for you use IPS\Helpers\Form\Select $form->add( new \IPS\Helpers\Form\Select( 'cvm_profile_field_field_id', \IPS\Settings::i()->cvm_profile_field_field_id ? \IPS\Settings::i()->cvm_profile_field_field_id : 0, FALSE, array( 'options' => \IPS\core\ProfileFields\Field::rootsAsArray() ), NULL, NULL, NULL, 'cvm_profile_field_field_id' ) );
December 21, 20177 yr Author 14 minutes ago, newbie LAC said: Congratulations! You found a bug. Ok, I will report it. One final question: how do I retrieve the name of the profile field by it's id? $fieldObj = \IPS\core\ProfileFields\Field::load(\IPS\Settings::i()->cvm_profile_field_field_id); $fieldName = $fieldObj-> ; I can't seem to find where you can retrieve a list of all these properties.
December 21, 20177 yr 14 minutes ago, ChrisVanMeer said: One final question: how do I retrieve the name of the profile field by it's id? $fieldName = $fieldObj->_title;
December 21, 20177 yr Author That's it! Where do you find all that relevant data? I can't find where to look for it.
December 21, 20177 yr 30 minutes ago, ChrisVanMeer said: Where do you find all that relevant data? I can't find where to look for it. Do you know what's OOP? If I give you \IPS\core\ProfileFields\Field you should see \applications\core\sources\ProfileFields\Field.php More about IPS autoloading classes
December 21, 20177 yr Author 30 minutes ago, newbie LAC said: More about IPS autoloading classes That's what I needed. Yes I am a bit aquatinted with OOP, I just didn't know where to look on disk. Thank you very much for all your help! I learned a lot from creating these plugins...and feel like experimenting more and more
December 22, 20177 yr Author 23 hours ago, newbie LAC said: Congratulations! You found a bug. Bug reported and just got back the following: Quote Thank you for your report, I have added the node title property for the node model. This change will be included in a future release.
Archived
This topic is now archived and is closed to further replies.