Jump to content

Text output on module config page


Recommended Posts

Hi all,

Just wondering if its possible to just add some basic output to my modules config page.

I was wanting to output a bulleted list of some information which I will be pulling from a third party.

Retrieving the data is fine i'm just not sure how to output it to the config page?

From what I can see in the link below, it only seems like you can append form items to the page.

https://processwire.com/blog/posts/new-module-configuration-options/

Link to comment
Share on other sites

If using the old style, what you need is the method getModuleConfigInputfields(). I think it used to be a static method so no $this, etc, but that could have changed at some point I. Here's how we do it in the Blog module (static method). For that specific case we jump through a couple of hoops but it need not be that complicated in normal use. You can also look at other examples to get the gist of it (e.g. Tracy, [non-static method] and some core modules. Invariably, these will be Process modules, e.g ProcessPageSearch.).  Your module will have to implement the ConfigurableModule interface. The Module interface is a good read.. In the links above, see also the code for retrieving saved values.

Here are some old links on this topic:

Possibly related

 

Edit: see next post if you already know above; my bad; just re-read your post.

Edited by kongondo
links
  • Like 2
Link to comment
Share on other sites

4 hours ago, cosmicsafari said:

it only seems like you can append form items to the page.

You add non-form stuff to forms using MarkupInputfield...for instance...

edit typo: InputfieldMarkup

Edited by kongondo
typo
  • Like 1
Link to comment
Share on other sites

11 minutes ago, kongondo said:

You add non-form stuff to forms using MarkupInputfield...for instance...

That sounds promising however do you have an example, I tried adding it to my module config page but get:

 InputfieldWrapper: Skipped field 'test' because module 'InputfieldMarkupInputfield' does not exist

Scratch that got it to work with :

 

[
    'name' => 'test',
    'type' => 'Markup',
    'value' => 'Huzzah!'
]
Link to comment
Share on other sites

Hey @kongondo - I am OT here and not meaning to single you out :) 

I was going to PM you, but thought I could make this a friendly public service reminder to hit the "Y" key in Github before posting links to a line of code so they will be correct even after changes to the file. Thanks everyone!

  • Like 1
Link to comment
Share on other sites

Markup is what I do:

        $f = $this->wire('modules')->get("InputfieldMarkup");
        $f->attr('name', 'config_intro');
        $f->label = "";
        $f->value = "<p>These settings will override those in the main config settings for this page.</p>";
        $fieldset->append($f);

I think you'll need lowercase "markup" using that approach to field configuration.

  • Like 2
Link to comment
Share on other sites

3 hours ago, cosmicsafari said:

That sounds promising however do you have an example, I tried adding it to my module config page but get:

My bad! That's what happens when you type just before dashing out the door :P. As @adrian shows above, it should be InputfieldMarkup. There's a couple of examples in the Blog module link I posted above. Note that since the method is static in the blog case, we use this instead:

$m = new InputfieldMarkup;
$m->label = __('Blog fully installed');
// blah blah
$form->add($m);

 

2 hours ago, adrian said:

I could make this a friendly public service reminder to hit the "Y" key in Github before posting links to a line of code so they

Guilty as charged sir! Ditto - the rushing out the door :-X. Corrected the links, ta.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...