Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
hinksta
Worker
Worker



Joined: Dec 23, 2005
Posts: 226
Location: UK

PostPosted: Sat Dec 02, 2006 8:19 pm Reply with quote

I have a module index.php that has two parts. If I put the module in the home I only want the first part to run. So I need to make the second part into a function, this I think I'm ok with, what I don’t know is how to have the function run at other times.

Or is there another way to do this say with a function for the home page only.

Could someone point me in the right direction?
 
View user's profile Send private message Visit poster's website
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Sat Dec 02, 2006 9:43 pm Reply with quote

So you have two routines on the same index file. When the module is set to 'home' you only want the first routine to execute but when its not in 'home' you want both to execute?
Are there any other considerations - for example are you trying to limit the second one to run only if its an admin or.....
 
View user's profile Send private message Send e-mail
hinksta







PostPosted: Sun Dec 03, 2006 6:39 am Reply with quote

Yes that's exactly it.
I may need to add admin features in the future but not at the moment.
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sun Dec 03, 2006 8:34 am Reply with quote

Well, I am still unclear. If your module is NOT "In Home", should it do something different?

If you need to know if your module is "in Home", you could have it check the nuke_main table. This would allow your index.php to call two different functions depending upon whether the module is "in Home" or not.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
hinksta







PostPosted: Sun Dec 03, 2006 8:49 am Reply with quote

Quote:
Well, I am still unclear. If your module is NOT "In Home", should it do something different?

If it is in home it should run only function 1.
If it is not in home it should run both functions.

Quote:
If you need to know if your module is "in Home", you could have it check the nuke_main table. This would allow your index.php to call two different functions depending upon whether the module is "in Home" or not.

So if in nuke_main run function1
else run function1 + function2
 
montego







PostPosted: Sun Dec 03, 2006 9:13 am Reply with quote

Quote:

So if in nuke_main run function1
else run function1 + function2


Yup.
 
hinksta







PostPosted: Sun Dec 03, 2006 9:53 am Reply with quote

Code:
$row = $db->sql_fetchrow($db->sql_query("SELECT main_module FROM ".$prefix."_main WHERE title='MySearch'"));


if ($row["MySearch"]) {

home

} else {

home,nothome

)


Am I heading in the right direction?
 
montego







PostPosted: Sun Dec 03, 2006 10:05 am Reply with quote

something more like this:

Code:


$row = $db->sql_fetchrow($db->sql_query("SELECT main_module FROM ".$prefix."_main LIMIT 1"));

if ($row['main_module'] == "MySearch") {

home

} else {

home,nothome

}
 
hinksta







PostPosted: Sun Dec 03, 2006 10:22 am Reply with quote

I'm getting a blank page so far

is the right way to make a function?

Code:
function home(){

   global $db, $prefix;

function code goes here

}
 
hinksta







PostPosted: Sun Dec 03, 2006 10:50 am Reply with quote

Got it working ok in the home but something is wrong when I add the ELSE

Code:
$row = $db->sql_fetchrow($db->sql_query("SELECT main_module FROM ".$prefix."_main LIMIT 1")); 


if ($row['main_module'] == "MySearch") {

home();
} else {

home(), nothome();
}
 
montego







PostPosted: Sun Dec 03, 2006 11:01 am Reply with quote

wrong syntax. He must be:

home();
nothome();
 
hinksta







PostPosted: Sun Dec 03, 2006 12:03 pm Reply with quote

that's great thank you very much.

for some reason the second function doesn't run so I may have to make some changes. maybe the functions are a bit mixed up.
 
hinksta







PostPosted: Sun Dec 03, 2006 1:06 pm Reply with quote

The first function 'home' runs ok but the second function 'nothome' does not run.
I also tried to run both functions in the home but 'nothome' still failed.

is something missing or should I have a closer look at the function?

Code:
$row = $db->sql_fetchrow($db->sql_query("SELECT main_module FROM ".$prefix."_main LIMIT 1")); 

if ($row['main_module'] == "MySearch")
{
home();
}
else
{
home();
nothome();
}
 
hinksta







PostPosted: Sun Dec 03, 2006 2:19 pm Reply with quote

I think i'm getting a bit closer.

using the if else statment tells it only to run the function 'home' if MySearch is in nuke_main.
if i am browsing on another page it still only run's 'home' because MySearch is still in nuke_main
 
hinksta







PostPosted: Sun Dec 03, 2006 3:05 pm Reply with quote

When reading back on this thread i see that i may have misled you a bit

What I meant by "when not in home" was, when you browse away from the home page to another page of the module itself.
 
hinksta







PostPosted: Sun Dec 03, 2006 4:54 pm Reply with quote

What was I thinking Blonde Moment

I just made a block out of the first function, sorted.
Well thanks for your help Montego, I learnt how to run a function today. Groovy
 
montego







PostPosted: Sun Dec 03, 2006 5:58 pm Reply with quote

Cheers
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©