You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 56 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Inserting code in header [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
Antra
Sergeant
Sergeant


Joined: Mar 15, 2003
Posts: 143


PostPosted: Mon Apr 21, 2003 3:05 pm Reply with quoteBack to top

I've played around with inserting some random quotes just underneath my header. Having some problems in that no matter where I put the code, it always shows up at the very top of the page. Here's the function I defined in mainfile.php:
Code:
function randomquote() {

$RANDOM_QUOTE_FILE = "quotes.txt";

srand((double)microtime()*1000000);

if (file_exists($RANDOM_QUOTE_FILE)) {
        $array_txt = preg_split("/--NEXT--/", join('', file($RANDOM_QUOTE_FILE)));
        echo "<center><i>".$array_txt[rand(0, sizeof($array_txt) -1)]."</i></center>";
} else {
        echo "Error: can't open $RANDOM_QUOTE_FILE file";
}
}

No matter how I try, I can't get a php function to call under header.html and if I try to call it in theme.php it displays at the top of the page. It displays it centered and italicized just as I wanted it to, so at least that bit looks good Wink. Any thoughts?
Find all posts by AntraView user's profileSend private messageVisit poster's website
bryan
Nuke Cadet
Nuke Cadet


Joined: Apr 28, 2003
Posts: 1


PostPosted: Mon Apr 28, 2003 6:48 pm Reply with quoteBack to top

I am VERY new to nuke programming and have almost no php experience but I have managed to write a script that generates a random quote like you are doing. I am using sql insted of a text file but the end result is the same. I was hoping someone would post a reply to this and spare me the pain of learning but oh well...

Instead of putting your php code in the header.html file put it in theme.php. Have it set a variable with your quote. You can then user $quote in the header.html file. You can see how this work with the $username in most header files. I hope this makes sense. You can see my poor example at www.my-thoughts.us.

With every page change or refresh the quote changes. It is the quote in the top/center of the page.
Find all posts by bryanView user's profileSend private messageVisit poster's website
Ricon
Nuke Cadet
Nuke Cadet


Joined: Jun 28, 2003
Posts: 2


PostPosted: Sat Jun 28, 2003 7:09 pm Reply with quoteBack to top

I am not sure if this gonna work but i am creating a themeeditor i have functions all throughout it. I include the functions.php or whatever the file is called that holds the functions you create.
Inside that file i would insert:

Code:

function randomquote() {

$RANDOM_QUOTE_FILE = "quotes.txt";

srand((double)microtime()*1000000);

if (file_exists($RANDOM_QUOTE_FILE)) {
        $array_txt = preg_split("/--NEXT--/", join('', file($RANDOM_QUOTE_FILE)));
        $yourvariable ="<center><i>".$array_txt[rand(0, sizeof($array_txt) -1)]."</i></center>";
} else {
        $yourvariable = "Error: can't open $RANDOM_QUOTE_FILE file";
}
 return($yourvariable); }


You must replace echo's with a $yourvariable if more then one echo is called continue with:
Code:

$yourvariable .="text";


Then put in your global variables for themeheader() or wherever you are putting it the $yourvariable. Then insert into the header.html or html page you are using the $yourvariable whereever you want it to show up.

Sometimes you have to add at the end of the functions.php file that you function is located.
Code:

$yourvariable = yourfunction();


Sorry if i might be mistaken but it works on mine.
[/code]

_________________
Making Themes Easier For Nukers
Find all posts by RiconView user's profileSend private messageSend e-mailVisit poster's websiteAIM AddressYahoo MessengerMSN Messenger
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next 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



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.247 Seconds - 254 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::