Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
The Old Man Posted July 7, 2020 Posted July 7, 2020 Hi, In a Plugin Settings form, I can add text, with HTML formatting etc by using: $form->addMessage('mymessage'); 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!
Solution opentype Posted July 7, 2020 Solution Posted July 7, 2020 Did you nest the quotes properly? 'mymessage' => "<a href='#'>link</a>" or 'mymessage' => '<a href="#">link</a>' sobrenome and The Old Man 1 1
The Old Man Posted July 7, 2020 Author Posted July 7, 2020 Thanks, I think so, but I'll try again. I assumed it just didn't like the link tags per se.
bfarber Posted July 8, 2020 Posted July 8, 2020 18 hours ago, The Old Man said: 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! $form->addButton(...) The Old Man 1
The Old Man Posted July 14, 2020 Author Posted July 14, 2020 On 7/8/2020 at 3:26 PM, bfarber said: $form->addButton(...) 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? $form->addButton Many thanks!
Ryan Ashbrook Posted July 14, 2020 Posted July 14, 2020 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; The Old Man 1
The Old Man Posted July 14, 2020 Author Posted July 14, 2020 (edited) 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 July 14, 2020 by The Old Man sobrenome 1
Recommended Posts