News:

Wondering if this will always be free?  See why free is better.

Main Menu

Help needed on re-coding a mod

Started by Burke ♞ Knight, September 02, 2014, 11:01:42 PM

Previous topic - Next topic

Illori

an example from 2.1


$helptxt['enablePostHTML'] = 'This will allow the posting of some basic HTML tags:
<ul class="normallist">
<li>&lt;b&gt;, &lt;u&gt;, &lt;i&gt;, &lt;s&gt;, &lt;em&gt;, &lt;ins&gt;, &lt;del&gt;</li>
<li>&lt;a href=&quot;&quot;&gt;</li>
<li>&lt;img src=&quot;&quot; alt=&quot;&quot; /&gt;</li>
<li>&lt;br /&gt;, &lt;hr /&gt;</li>
<li>&lt;pre&gt;, &lt;blockquote&gt;</li>
</ul>';

Arantor

Yes but that requires you getting that content into the Help language file.

There are, broadly, 3 options for doing help text on a mod.
1. in the Help language file and tell it to use a (?) icon.
2. under the main item's text, only really suited to short messages.
3. under the main textbox'x text, suited to slightly longer messages, even if it is a bit complicated.

Lemme know which you'd be interested in doing. An example of the third option is attached as taken from LevGal.

Burke ♞ Knight

#2 should do it.

Line would be:

$txt['gkstyle_start'] = 'Opening HTML code to be used before group name:<br />Allowed HTML Tags: <strong></strong><em></em><span></span>';

I think those would be the only tags really needed for this, as can't use <u></u> as it underlines the whole line, and not just the text.

Illori

check the example i gave, it has the tags in it using html entities

Burke ♞ Knight

However, I need them on the settings page, not the help popup, as many people do not even click the ? to see it...LOL

Line would be:

$txt['gkstyle_start'] = 'Opening HTML code to be used before group name:<br />Allowed HTML Tags: &lt;strong&gt ;&lt;/strong&gt; &lt;em&gt; &lt;/em&gt; &lt;span&gt; &lt;/span&gt; ';

Arantor

What you're describing is not option 2, though it would work just fine if you replace the relevant < and > with &lt; and &gt;

By putting that as the main text item attached to the relevant option it should just work even if it will be ugly as sin in the admin panel search.

Burke ♞ Knight

Okay, mod updated on mod site.
Like stated in PM to Cust team, if people use tags that are not listed, then, basically, that is on them, as I have it clearly stated on mod settings page which tags can be used.

Allowed HTML Tags: <strong></strong> <em></em> <span></span>


Arantor

If you're using the strip-tags code, that's all they're able to use anyway ;D

Burke ♞ Knight

Quote from: Arantor on September 04, 2014, 04:44:50 PM
You can't use <style> in line in a page. Not allowed.

As for where you would use it, you would use it during the save routine. $string is more a placeholder for descriptive purposes. In your case, I'd assume use of $_POST['gkstyle_start'] and $_POST['gkstyle_end'] instead before the saveDbSettings() call.

Displaying it on the mod's page is very complicated, lots of permutations, most of which depend on how much text you want to write.

I still have no idea where to put it....LOL

Arantor

And I thought I'd told you already :P

The problem is, if I tell you how to do all of it, it's not really a learning experience for you, is it?

Burke ♞ Knight

ManageSettings.php

Wait, this is a bit of a trick question issue, isn't it?
I'd place it with the code I already have, since that is right above a save call anyway, right?

So would be:

$_POST['gkstyle_start'] = array('text', 'gkstyle_start', '30'),
                $_POST['gkstyle_end'] = array('text', 'gkstyle_end', '30'),


I hope I'm getting this, because I have never done this type of coding in a mod before....LOL

Arantor

No, that's not what I said at all. Nor is it a trick question.

You have the normal $config_vars definitions, which you had just fine.

Now, what I was telling you to do was put in $_POST['gkstyle_start'] = strip_tags($_POST['gkstyle_start'], '<span><strong><em>');

And put that before the call to saveDbSettings()...

Burke ♞ Knight

Like this:

Code (Find) Select
// This line is to help mod authors do a search/add after if you want to add something here. Keyword: FOOT TAPPING SUCKS!
                saveDBSettings($save_vars);


Code (Replace With) Select
// This line is to help mod authors do a search/add after if you want to add something here. Keyword: FOOT TAPPING SUCKS!
                $_POST['gkstyle_start'] = strip_tags($_POST['gkstyle_start'], '<span><strong><em>');
saveDBSettings($save_vars);

Arantor

Yup, to run the stripping of non-valid tags before it gets saved to the database.

Burke ♞ Knight

So now, this mod should be 100% approval ready. :)

Thank you my friend...
Sorry if did not understand you, but this is all new parts for me to coding.
Maybe, it'll help me make some more mods, too. :)

Arantor


Hj Ahmad Rasyid Hj Ismail

A really useful tip. A new knowledge for me today. ;)

Just a little add up that I learn from other mods, BurkeKnight, you can also give description to your mod using the following code:

// Mod authors, feel free to modify this alternative menu but don't remove this statement and basic menu!!
array('desc', 'gkstyle_mod_description'),


Add your language string for it and this will place a description for your mod settings page.

One extra idea that I have, but not tested, is to give some color / styling to this description box. Or may be there is some other way to do it better, yet I don't know :).

Arantor

There are more ways than even that. Consider the attached. This is using the very same template, almost, as the standard template for admin use.

Snippet of code:
// Define the generic master settings.
$config_vars = array(
array('title', 'levgal_quotas'),
array('desc', 'levgal_quotas_desc'),
array('text', 'lgal_max_space'),
array('message', 'lgal_max_space_note'),
);


First up, we have use of 'title' elements. That's how the big section dividers (Images, Audio, Video etc) are done.

Then there's a 'desc' element at the top (the one that says "This page allows you to configure...")

Then the textbox, which is the regular textbox with its setting text.

Then there's one of type 'message', which is a message that will float up on the right-hand side under the message there, whatever that happens to be. See, there's lots of options ;)

As for the magical fieldsets, they're another template, invoked by way of the 'callback' type that lets you call an arbitrary function to display a setting.

Burke ♞ Knight

Well, since this is going into the basic mod settings page, and not a page of it's own, I think it is okay as it is, as these pics will show. :)

Hj Ahmad Rasyid Hj Ismail

Awesome Arantor. Thank you very much for sharing small pieces of the "cake". This really made my day. ;)

Well, BurkeKnight, you can always create your own mod settings page in the future as the samples are already given. :)

Advertisement: