News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Modifying Register.template.php, looking for $context['custom_field'] function

Started by Glyph, November 22, 2015, 10:04:11 PM

Previous topic - Next topic

Glyph

I am working on adding checkbox input boxes to my register template and i am trying to add it properly to the core SMF system (2.0)
e.g. http://www.simplemachines.org/community/index.php?topic=541440.0

Where is the $context global variable being included from? I don't see any, POST, GET, or includes in the register.template.php file ANYWHERE.

I just want to add a new drop down option with my code for the dropdown/input box set.
Personal TODO:

Glyph

Did some digging around and found this:

$context = array('pretty' => array(
'action_array' => unserialize($modSettings['pretty_action_array']),
'board_urls' => unserialize($modSettings['pretty_board_urls']),
'db_count' => 0,

the above code is with the prettyurls mod installed.

so now my next question is where is "$modSettings" ?
My next step is to find the file from the prettyurls "mod installer" with a search for "pretty_action_array"


not only is my goal to add more text boxes but also edit the context, or modSettings variable array output.
context['gw2username'], $context['gw2aggregate']['wins']['losses']['desertions']['byes']['forfeits'], $context['gw2apikey'], etc...
currently ill have to create a function in every single source file i see (or just make an include) to grab the api key data, so i'm trying to make global variable function like a normal SMF mod. e.g. prettyurls. ($context['action'])
Personal TODO:

Jade Elizabeth

I am pretty sure you can already do this in admin. Admin > Features and Options > Profile fields > Create field > Check require on rego :).
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Sir Osis of Liver

That's correct.  You have to enable 'Advanced Profile Fields' in Core Features to make it work - it's disabled out-of-box.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Glyph

as of 2.0.11 i don't have the option that i'm referring to.

http://www.simplemachines.org/community/index.php?topic=541440.0
for more information. I do apoligize, my first post is a bit unorganized.
Personal TODO:

Jade Elizabeth

Ahh you want MULTIPLE checkboxes.

Well that seems to be impossible. I have asked for it a bunch of times. I think the best way is to change the field to be separated by commas...maybe look at it from that angle? (it's late afternoon here and I haven't eaten so if I'm not making sense chalk it up to that).
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Glyph

Quote from: Jade Elizabeth on November 23, 2015, 10:43:56 PM
Ahh you want MULTIPLE checkboxes.

Well that seems to be impossible. I have asked for it a bunch of times. I think the best way is to change the field to be separated by commas...maybe look at it from that angle? (it's late afternoon here and I haven't eaten so if I'm not making sense chalk it up to that).
I thought the exact same thing, but these values will be used directly for an SQL "UPDATE". I can't rely on users to correctly type the querys out lol. It will result in alot of frustration for users. I would be happy to work on something like this for the core in 2.1, but my main issue is learning how SMF operates. e.g. figuring out how these scripts are using $context['action'] 's, or $modSetting['action'] 's.

seems $context is declared in SSI.php.
Personal TODO:

Glyph

Okay, so i asked the wrong question here.

What I was looking for is how to include a function from an external PHP file without an "include" the same way that subs.php calls
'menu_pvp' => array(
'title' => 'PvP Rankings',
'href' => $scripturl . '?action=pvp',
'show' => true,


so action=pvp loads the pvp.php and pvp.template.php files, i need to figure out how to pass a function from pvp.php to pvp.template.php, or a function from pvp.php to display.template.php, or register.template.php, or any other file as such.

the answer is in index.php, where
'pvp' => array('pvp.php', 'PvPMain'),
after
'xmlhttp' => array('Xml.php', 'XMLhttpMain'),

but i need to pass pvp.php's function called "getapi" to global name.template.php files, or files that i explicitly add.

im guessing i need to add another "GET" request for each file including the data from my function.

e.g. ?action=Display&?action=pvp
so that the functions from both files are executed. so that i can use the function from pvp.php in the dispay.tempate.php


contents of pvp.php

function getapi()
{
    $texthere="fail";
    return $texthere;
}


im thinking maybe adding something with call_integration_hook
http://wiki.simplemachines.org/smf/Integration_hooks#Using_Integration_Hooks
to grab data from a function in a source file.
Personal TODO:

Jade Elizabeth

No no, you have SMF build the query....like how radio checkboxes store except the checked information would be [c1, c4, c6] based on what's checked. And I dunno about the actual fields themselves.
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Advertisement: