Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted July 7, 20204 yr 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!
July 7, 20204 yr Solution Did you nest the quotes properly? 'mymessage' => "<a href='#'>link</a>" or 'mymessage' => '<a href="#">link</a>'
July 7, 20204 yr Author Thanks, I think so, but I'll try again. I assumed it just didn't like the link tags per se.
July 8, 20204 yr 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(...)
July 14, 20204 yr Author 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!
July 14, 20204 yr 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;
July 14, 20204 yr Author 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, 20204 yr by The Old Man