Hiya,
I was just wondering how to do something so thought I would ask on here as I know that there are a lot of excellent developers out there just wanting to lend a hand 😉
I was wondering how I can go about getting an extension settings page which has something like the following :
Weblog One Field One Field Two Weblog Two Field One Field Two
Basically where the Weblog One, Weblog Two text is shown above these would show all your weblogs which would repeat for as many weblogs that there are in the system so if you for instance added a new weblog at any time in the future another instance of the settings would appear. The Field One, Field Two settings would be drop-down menus which would list all the custom fields that are assigned to that weblog. This would then allow you to choose two fields for each weblog that I could then use in the extension code.
Basically my question is two-fold as I really don’t have much of an idea of where to start on this one.
Firstly, how do I get the settings page to show this and dynamically? Second, how do I then utilise (grab) these settings from inside the extension?
Hope that made some sense and someone can help on this.
Any help would be greatly appreciated.
Best wishes,
Mark
Hey Mark, you would use one of the settings field types that fits your need (radio, multi-select, etc.). You can use the Database class to fetch that information to populate the fields in the settings() method. As an example, this would represent a member group multi-select:
$query = $DB->query("SELECT group_id, group_title FROM exp_member_groups WHERE group_id NOT IN ('2', '3', '4')");
$groups = array();
foreach ($query->result as $row)
{
$groups[$row['group_id']] = $row['group_title'];
}
$settings['member_groups'] = array('ms', $groups, '');
Hi Derek,
Okay just getting around to starting to write the extension and already I’m a little confused. I have the extension installing and showing a settings page with the code that you showed above (reflected here again below) :
$query = $DB->query("SELECT group_id, group_title FROM exp_member_groups WHERE group_id NOT IN ('2', '3', '4')");
$groups = array();
foreach ($query->result as $row)
{
$groups[$row['group_id']] = $row['group_title'];
}
$settings['member_groups'] = array('ms', $groups, '');
I have to say that I’m a little perplexed as to where the settings page is getting the Member Groups title from. Next to the multi-select field are shown those words but if I try to add in one of the examples from the documentation such as :
$settings['butter'] = "Quite Tasty";
all I get is the text field but without a title shown on the left of the field explaining what it’s for. How come the Member Groups example that you have provided has this text but the others from the documentation example don’t?
How do I get my own titles to appear?
Thanks.
Best wishes,
Mark
Also just noticed something else a little weird (well it seemed weird to me anyway 😉 ). I tried out this from the documentation too :
$settings['buttery'] = array('r', array('yes' => "yes", 'no' => "no"), 'no');
If I change the yes’s to some other word and also the no’s to some other word then I do get the radio buttons but they don’t have anything written next to them. I think I’m obviously missing something here so any help on this would be greatly appreciated.
Sorry about all of this, I was really hoping to get this on my own but just following the documentation got me a little lost I’m afraid :-(
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.