DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • February 17, 2019, 05:48:32 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Trying to display random quotes  (Read 4587 times)
0 Members and 1 Guest are viewing this topic.
Lurch
Guest
« on: February 07, 2005, 03:57:35 AM »

Hey all,

Trying to display random quotes on the index page, havent  had any luck yet. If someone could take a look at my code to see where I am going wrong that would be great d:)

http://dragonprime.net/users/Lurch/quotes.txt
« Last Edit: February 07, 2005, 03:58:09 AM by Lurch » Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #1 on: February 07, 2005, 04:09:53 AM »

when using the index hook you'll have to do the following:

First in getmoduleinfo you have to put:

Code:
"allowanonymous" => 1,
(somewhere)

and in the do_hook part:
Code:
define("ALLOWANONYMOUS", true);
at the beginning or from where not logged-in users should be able to run the module...
Logged

Running for more than three years now:
CortalUX
Dwellings Project
Mod God
*****
Offline Offline

Posts: 796


Wogga! Meep!


View Profile WWW
« Reply #2 on: February 07, 2005, 04:10:16 AM »

try this:
Code:
$file = file($filename);
$array = explode('\n', $file);
$str = array_rand($array,1);
output_notl("Quote: %s", $str);
« Last Edit: February 07, 2005, 04:12:08 AM by CortalUX » Logged
CortalUX
Dwellings Project
Mod God
*****
Offline Offline

Posts: 796


Wogga! Meep!


View Profile WWW
« Reply #3 on: February 07, 2005, 04:13:29 AM »

when using the index hook you'll have to do the following:

First in getmoduleinfo you have to put:

Code:
"allowanonymous" => 1,
(somewhere)

and in the do_hook part:
Code:
define("ALLOWANONYMOUS", true);
at the beginning or from where not logged-in users should be able to run the module...

you shouldn't have to use the second define, as it may already have been defined by common.php. I think it might be defined by home.php itself at the start of the script.
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #4 on: February 07, 2005, 04:20:56 AM »

having it there will not cause any trouble... Wink

At least it did not for me Tongue

Aaaaaand for the very unlikely case it should not have been defined yet...  Grin

Logged

Running for more than three years now:
CortalUX
Dwellings Project
Mod God
*****
Offline Offline

Posts: 796


Wogga! Meep!


View Profile WWW
« Reply #5 on: February 07, 2005, 04:31:58 AM »

*nods* Tongue
and that code
Code:
$file = file($filename);
$array = explode('\n', $file);
$str = array_rand($array,1);
output_notl("Quote: %s", $str);
should actually have been
Code:
$file = file($filename);
$array = explode('\n', $file);
$str = array_rand($array,1);
output_notl("Quote: %s", $str[0]);

Edit: At least define() won't throw up an error if it's been done like some stuff does. If it has been defined it just returns false which the script will ignore anyway, as it doesn't link it to a variable, therefore no reason to use defined()
« Last Edit: February 07, 2005, 04:33:58 AM by CortalUX » Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #6 on: February 07, 2005, 04:36:42 AM »

just a question: does Sichae's hitcounter work? (haven't tried yet... Wink )

He doesn't use "allowanonymous" either...
Logged

Running for more than three years now:
CortalUX
Dwellings Project
Mod God
*****
Offline Offline

Posts: 796


Wogga! Meep!


View Profile WWW
« Reply #7 on: February 07, 2005, 04:38:23 AM »

ya, it works.
home.php and about.php all have define allowanonymous before the requires_once for common.php
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #8 on: February 07, 2005, 04:44:21 AM »

Aaaah... so I need the "allowanonymous"-part only, if I call the module via "runmodule.php"
Logged

Running for more than three years now:
CortalUX
Dwellings Project
Mod God
*****
Offline Offline

Posts: 796


Wogga! Meep!


View Profile WWW
« Reply #9 on: February 07, 2005, 05:45:41 AM »

I think so, ya.
Logged
Lurch
Guest
« Reply #10 on: February 07, 2005, 12:49:31 PM »

Sweet let me try these d:)
Logged
Turock
Guest
« Reply #11 on: February 08, 2005, 04:10:15 PM »

Rather than hooking into index you can hook everyfooter and test the $args['__scriptfile__'] for your page name.
Code:
switch($hookname){
    case "everyfooter":
    $args['quote'] = array();
    if($args['__scriptfile__'] == "home") {
        $quote = get_module_setting("quote");
        array_push($args['quote'], $quote);
    }
    break;
return $args;
}
In your templates you can then add {quote} to the html where you want the quote to be displayed.
« Last Edit: February 08, 2005, 04:15:44 PM by Turock » Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #12 on: February 08, 2005, 04:17:05 PM »

just a question: does Sichae's hitcounter work? (haven't tried yet... Wink )

He doesn't use "allowanonymous" either...

Since the hitcounter only exists upon the outside index, it does not need the allow anonymous, since that is really only used for the module, if it has the "run" function filled out, and the run function needs to be accessed from the outside, such as "Recent Players" or "Recent Accounts" or any FAQ hooking module. If it wasn't in place in those, then it would state "Your are not logged in" and redirect you to the index.php in order to login.

Take a look at the statue as well ^_^

Are you accusing me of releasing non-working mods? Tongue
Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Version 1.1.2 is the current supported version and is available for download.

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
28 Guests, 1 User
pharis
Home Forums News Downloads Login Register Advanced Search