Hello all, long time nuke user but first time module writer. I'm porting over one of my web based ftp clients i wrote a while back and im in now playing with the module structure and such. One question i have...and ill use the module Your_Account as an example...is that when i look at the code, i see that it uses $op (registered global) in a switch statement to determine what function to go to and what parameters to pass that function.
My real question is, is that when you first go into Your_Account by clicking on the link under modules...theres no op variable in the query string to tell it where to go...and since there is no op at all the switch statement is not evaluated at all so no default case is ran.
Need to know the methodology behind this so i write my module correctly to fit inside the framework. Thanks for the answers!
ethana Sergeant
Joined: Dec 26, 2005
Posts: 81
Posted:
Mon Dec 26, 2005 4:45 pm
Here is what i have for code so far...any advice is appreciated!
Code:
<?php
if (!eregi("modules.php", $PHP_SELF)) {
die ("You can't access this file directly...");
}
$index = 1;
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
function view ($username, $prev_directory, $curr_directory) {
OpenTable();
echo "<br>IN VIEW<br>";
if (! $curr_directory) {
$curr_directory = "\/";
}
hmm, do i have this in the wrong section? I see 37 views but no responses...i posted this yesterday though it says today (in my time zone)...just curious thinking maybe it needed to be in another section. Thanks.
Hello all, long time nuke user but first time module writer. I'm porting over one of my web based ftp clients i wrote a while back and im in now playing with the module structure and such. One question i have...and ill use the module Your_Account as an example...is that when i look at the code, i see that it uses $op (registered global) in a switch statement to determine what function to go to and what parameters to pass that function.
My real question is, is that when you first go into Your_Account by clicking on the link under modules...theres no op variable in the query string to tell it where to go...and since there is no op at all the switch statement is not evaluated at all so no default case is ran.
Need to know the methodology behind this so i write my module correctly to fit inside the framework. Thanks for the answers!
My apologies, i was not clear. On the $op variable that i was talking about that determines what function to execute (Your_Account was my example) is not set or even used when you initially go into the Your_Account module when you click on it from under the modules navigation. How is this working then? How does the module know what to execute? Is there a methodology behind this? How do i take my module and make it run a default function even if there is not $op and no switch is evaluated like in Your_Account? I'm assuming theres a standard way of doing this b/c quite a few modules do it. Thanks all and i hope this was clearer!
Evaders99 Site Admin
Joined: Aug 17, 2003
Posts: 12397
Posted:
Tue Dec 27, 2005 10:27 pm
Ah I see the problem now. Your code is not correct.
You don't want to call include("footer.php") before your switch statement. That will kill your script before it ever executes the switch
You are better to place the header.php and footer includes in the body of your functions.
i.e.
Code:
<?php
if (!eregi("modules.php", $PHP_SELF)) {
...
function view( ...
include("header.php");
...
include("footer.php");
}
ok, thats understandable...but still though, what is the standard way for when you first enter a module through the Modules navigation when the link is only modules.php?name=Your_Account and no $op is set in the query string? The switch statement wont evaluate to even run the default b/c of this, or am i wrong? Thanks for your response
Evaders99 Site Admin
Joined: Aug 17, 2003
Posts: 12397
Posted:
Wed Dec 28, 2005 11:27 pm
The switch will always go to the default: case then
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum