Jump to content

Best practice for adding buttons & links in Plugin Settings

Go to solution Solved by opentype,

Recommended Posts


In a Plugin Settings form, I can add text, with HTML formatting etc by using:


and a language string:

'mymessage' => "<p>Thinking bout burgers.</p>
		<p>I wish I had one, right now. I'd eat it all up. With onion rings of course.</p>"

This works, but if I try to insert tags for a hyperlink to open in a new tab/window such as for example:

 <a href="https://www.w3schools.com" target="_blank" title="Visit W3Schools (in a new tab/window).">Visit W3Schools</a> 

... it refuses to display the form. I recall HTML is filtered automatically, so entering raw is okay.

What is the best practice to insert a URL into my text?

Secondly, I can't seem to find a helper for a button (to add a few buttons to my plug-in settings page), should I create my own in a language string? I've not started with templates yet, only code hooks and plugin settings.

Many thanks!

Link to comment
Share on other sites

On 7/8/2020 at 3:26 PM, bfarber said:


Hi @bfarber

Where can I find info on the correct formatting for this? Is it considered a form helper, as I can't seem to find it?

I tried searching here with this query below and it brought up 0 results, even though it's mentioned in your post above?


Many thanks!

Link to comment
Share on other sites

It's a method in \IPS\Helpers\Form.

	 * Add Button
	 * @param	string	$lang	Language key
	 * @param	string	$type	'link', 'button' or 'submit'
	 * @param	string	$href	If type is 'link', the target
	 * @param	string	$class 	CSS class(es) to applys
	 * @param 	array 	$attributes Attributes to apply
	 * @return	void
	public function addButton( $lang, $type, $href=NULL, $class='', $attributes=array() )

So, structurally, you would do:

$form = new \IPS\Helpers\Form;
// ... Add your other form elements here
$form->addButton( 'lang_string', 'button', ... );
\IPS\Output::i()->output = (string) $form;


Link to comment
Share on other sites

Aha, thanks Ryan! Just found it. Can't see the wood for the trees!

I had used a language string to make a button and it looked great but I was concerned about doing it right.

'learn' => "<span class='ipsResponsive_hidePhone'><a href='https://example.com' class='ipsButton ipsButton_overlaid ipsButton_small' target='_blank' rel='noreferrer noopener' title='Learn more at example.com (in a new tab/window).'><i class='fa fa-external-link'> </i>   Example.com</a></span>"


Edited by The Old Man
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...