News:

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

Main Menu

Mod options page - custom display

Started by kkmic, January 02, 2017, 03:40:16 PM

Previous topic - Next topic

kkmic

Hi,

I'm writing a mod that uses an authentication token. The token is automatically generated when the mod is installed, but it is mandatory that the board admin can generate a new token, should it be needed.

For security reasons, I don't want to allow the admin to type is the new token by hand.

My initial design for the options page is something like this:



Token:                [AAA-BBB-CCC-DDD]
Generate new token:   [x] <- Checkbox
---------------------------------------
                                 [Save]



The token is the only information stored in the $modSettings array.


How can I "convince" SMF to allow me to have such a options page for my mod?
I've... seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched c-beams glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears... in... rain. Time... to die...

kkmic

I've... seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched c-beams glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears... in... rain. Time... to die...

Dzonny

Hello there.

I believe that you can manage to do what you asked, but let me point our Customizers to this topic so you can get the best answer regards this.

Kindred

http://wiki.simplemachines.org/smf/Integration_hooks#Admin_panel

these hooks should help you...

you can look at how some of the other mods with admin interfaces do it
Ultimate profile or bad behavior might be some to look at...   many of the things by Dougiefresh are well coded and can give you a baseline on how to linjk in an admin page via hooks
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

kkmic

Quote from: Dzonny on January 04, 2017, 07:13:30 AM
I believe that you can manage to do what you asked, but let me point our Customizers to this topic so you can get the best answer regards this.

I'm pretty sure it's doable - otherwise it would be a shame. TBH, I HAVE managed to do it, but it was a hack so ugly (both visually and code-wise) that even I have disliked it.

Quote from: Kindred on January 04, 2017, 08:59:45 AM
http://wiki.simplemachines.org/smf/Integration_hooks#Admin_panel

these hooks should help you...

They did, thanks for pointing me in their direction a few days ago.

I have managed to properly add a "standard" options page for my mod by using hooks - this includes the correct menu entries. I like the hooks, this is a lot more cleaner than the classic 1.x way

The issue arises from the fact that I don't have "standard" options - where the user would simply (more or less) edit the values from the $modSettings array. I need a "refresh that value now" ability.

Quote from: Kindred on January 04, 2017, 08:59:45 AM
you can look at how some of the other mods with admin interfaces do it
Ultimate profile or bad behavior might be some to look at...   many of the things by Dougiefresh are well coded and can give you a baseline on how to linjk in an admin page via hooks

I will try to give them a go today, and see if they can help.

In the mean time, I have noticed a function called "createList", which looks like helpful. A function reference would have been nice, as the code is pretty scarcely documented.

Thanks a lot, both of you!
I've... seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched c-beams glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears... in... rain. Time... to die...

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Quote from: Kindred on January 05, 2017, 10:01:32 AM
you mean like this?
http://support.simplemachines.org/function_db/index.php?action=main

(it's amazing what our online wiki./manual contains... :P )

It's sooooooo descriptive. Not for createList, anyway.

There was a post around here somewhere from SlammedDime that documented all the options but I can't seem to find it right now.

kkmic

Quote from: Kindred on January 05, 2017, 10:01:32 AM
you mean like this?
http://support.simplemachines.org/function_db/index.php?action=main

(it's amazing what our online wiki./manual contains... :P )

Yeah, like that. Good to know it's there, even if createList is not actually documented.

Quote from: Arantor on January 05, 2017, 01:18:59 PM
There was a post around here somewhere from SlammedDime that documented all the options but I can't seem to find it right now.

That would be nice to have. Assuming that createList IS the function I'm looking for.
I've... seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched c-beams glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears... in... rain. Time... to die...

live627

Quote from: kkmic on January 05, 2017, 06:58:16 AM
In the mean time, I have noticed a function called "createList", which looks like helpful. A function reference would have been nice, as the code is pretty scarcely documented.
See http://wiki.simplemachines.org/smf/Generic_List which is based on said post.

kkmic

Nice!

I'll give it a through read, as the options list is pretty huge - not that it was unexpected.

Thanks a lot live627!
I've... seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched c-beams glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears... in... rain. Time... to die...

kkmic

I've managed to implement the options page I was looking for (and it works as it should).

I eneded up not using createList(), as I have not managed to figure it out.

However, I am not sure that the aproach I have used is the best one, and I would like to know the opinion of one of the devs regarding my solution.

This is what I have done:


  • I have added an options page for my mod using these instructions as a base, but using integration hooks instead of directly modifying the files.

  • I have created a custom template that I have loaded instead of the standard "settings template" that SMF uses for my options page. The template contains a form with my custom fields, the session var/id hidden field and display formatting.

  • In the handling function I have checked the session and updated the token on save if the "Generate new token" checkbow was checked.
This solution works, and does not feel like an ugly hack (in case someone else needs something like this), but as I have said, I am not 100% convinced that this is the best way to do it.
I've... seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched c-beams glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears... in... rain. Time... to die...

kkmic

So... is my solution a good solution or not?
I've... seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched c-beams glitter in the dark near the Tannhäuser Gate. All those... moments... will be lost in time, like tears... in... rain. Time... to die...

Advertisement: