Topic: Styles on frontpage?

On your front page (www.punbb.org) you use the styles from the forum. For example if i go to my profile and change style to "cobalt" or any one of the styles available, the front page changes style as well.

How do you code this? Im kinda noobie at php and web design over all...

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde

2

Re: Styles on frontpage?

The syles are controlled by the css files.

The punbb.org site is using oxygen.css from the forums and site.css for site specific elements.

3 (edited by Jansson 2004-07-29 17:52)

Re: Styles on frontpage?

No, it uses $cur_user['style'].'.css' and site.css for site specific elements. ;)

To do this, include "include/common.php" and edit your css url to <?php echo $cur_user['style'].'.css'; ?>

Re: Styles on frontpage?

Here's some example code:

<?php

define('PUN_TURN_OFF_MAINT', 1);    // We don't want a maintenance message to appear on the front page
define('PUN_QUIET_VISIT', 1);        // We don't want to update peoples cookies on the front page

$pun_root = '../forums/';    // The path to the forum root directory relative to this script
@include $pun_root.'include/common.php';

// If PUN isn't defined, config.php is missing or corrupt
if (!defined('PUN'))
    exit('config.php doesn\'t exist or is corrupt. Please run install.php to install PunBB first.');

// Now we determine what style we should use
$style = (isset($cur_user)) ? $cur_user['style'] : $pun_config['o_default_style'];

?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://path.to.your.forums/style/<?php echo $style ?>.css">
</head>
<body>
Your website here.
</body>
</html>

If you get the an error message saying "config.php doesn't exist or is corrupt", the path to the forum root directory ($pun_root) is most likely incorrect.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

5 (edited by bobitt 2004-07-29 19:51)

Re: Styles on frontpage?

Thanks a lot guys.. ill try it right away big_smile
Wohoo it worked =P now back t othe drawing table.. im gonna make a frontpage for my forum smile

One more thing would be really nice though.. is it possible to move the login part to the front page (only username and password fields and forgotten password/register)?

I have fixed it kind of clumpsy right now by borrowing some code from the forum files, but that login part does not dissappear when you log in... I would like it to do that.. smile

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde

6 (edited by Jansson 2004-07-30 12:56)

Re: Styles on frontpage?

Use this to check if the user is online:

if($cookie['is_guest'])
{
//Login stuff
}


(Yeah.. I was faster than Rickard ;)

Re: Styles on frontpage?

Yes, it's possible. After including common.php (as we did above), you can check $cookie['is_guest'] and if that is true, you show the login box. If it's false, the user is logged in and you don't show the login box.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Styles on frontpage?

Thx alot guys.. but i have one more.. smile
Is there some easy way to include the navigation links from the forum on my first page? (home | user list | login etc...)

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde

Re: Styles on frontpage?

Rickard wrote:

you can check $cookie['is_guest'] and if that is true, you show the login box.

Btw.. did we not diable the use of cookies in the script above?

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde

Re: Styles on frontpage?

<?php echo gen_navlinks(); ?> will print the navigation =)

11 (edited by bobitt 2004-07-30 09:42)

Re: Styles on frontpage?

Jansson wrote:

<?php echo gen_navlinks(); ?> will print the navigation smile

I tried it, but i got this error: Fatal error: Call to undefined function: gen_navlinks() in \test.php on line 70

Ok nevermind.. i found the solution.. the code should be:
<?php echo generate_navlinks(); ?>
instead of:
<?php echo gen_navlinks(); ?>

...
Thanks a lot for all help.. ill show you my page when its done big_smile

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde

12 (edited by bobitt 2004-07-30 10:11)

Re: Styles on frontpage?

Hi again guys.. here comes another one... i also want the little message that appears under the menu saying:

Logged in as [username]
Last visit: [date]

alternatively (if you are not logged in):

You are not logged in


How do i get that?

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde

13 (edited by Jansson 2004-07-30 11:26)

Re: Styles on frontpage?

if(isset($cookie['is_guest']))
    echo 'Not logged in';
else
    echo 'Logged in as: '.$cur_user['username'].'<br>Last visit: '.format_time($cur_user['last_visit']);

14

Re: Styles on frontpage?

Still some problems... when i go to my main page it says "not logged in". Then I log in to the forum and go back to the main page... it still says "not logged in"... i go back to the forum and it says "logged in as bobitt..."

Because of this i removed the line in the top of the page saying:
"define('PUN_QUIET_VISIT', 1);        // We don't want to update peoples cookies on the front page"

Now i can se that i am logged in on the front page, because i have links like "log out" and "admin options" in the menu... But it still says "not logged in" under... smile

Thx again for the quick response

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde

Re: Styles on frontpage?

Oops.. The isset() function should not be there

if($cookie['is_guest'])
    echo 'Not logged in';
else
    echo 'Logged in as: '.$cur_user['username'].'<br>Last visit: '.format_time($cur_user['last_visit']);

16 (edited by bobitt 2004-07-30 15:07)

Re: Styles on frontpage?

it works better now.. but if you log out fron the forum it still looks like you are logged in when you go to the front page.. you have to update (F5) to make it change...

Is there a way to make the status on the front page update when you log out from the forum so that you dont have to reload the front page for it to update?

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde

Re: Styles on frontpage?

Then it's a caching problem. Have look at header.php and copy/paste the lines at the top that start with header(blablabla). Put those lines at the beginning of your site script.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

18

Re: Styles on frontpage?

Thx it works just fine now

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde

19

Re: Styles on frontpage?

Here comes the first version of the result of my work with the frontpage: http://rbkforum.no-ip.com

How do you like it?

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde

Re: Styles on frontpage?

I like it =)

21 (edited by NT 2004-10-09 18:35)

Re: Styles on frontpage?

i got the same problem but i dont know how to fix i just recently switched to punbb can you help me do whe he did .
  How do i get the user system of the forum intergrated with my site.
   
What you see here is my index page before i went to punbb since i just got it recently.
               

<?php
include("login.class.php");
include("mydb.class.php");
include("files/css.css");
echo ("<body topmargin=\"20\" leftmargin=\"20\" bottommargin=\"20\" rightmargin=\"20\" text=\"798A9B\">");
$border = "0";
$fontsize = "2";
if ($login->logged()){
  $id = $_SESSION["uid"];
  $fp = file("forum/db/users.dat");
  $userinfo = explode("<~>", $fp[$id]);
};
?>

<?php

function title($name, $side){
echo ("<table border=\"0\" cellspacing=\"1\" bgcolor=\"000000\" cellpadding=\"0\" width=\"100%\" align=\"center\">
<tr>
   <td width=\"100%\" bgcolor=\"303438\" align=\"$side\"><font size=\"2\">$name</font></td>
</tr>
</table>");
}; //end function title

function cont($name){
echo ("<table border=\"0\" cellspacing=\"1\" bgcolor=\"000000\" cellpadding=\"0\" width=\"100%\" align=\"center\">
<tr>
   <td width=\"100%\" bgcolor=\"383E45\"><font size=\"2\">$name</font></td>
</tr>
</table><br>");
}; //end function title
?>

<!-- BANNER CODE -->
  <center><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
 WIDTH="830" HEIGHT="84" id="flashsenic" ALIGN="">
    <PARAM NAME=movie VALUE="http://flashsenic.com/flashsenic.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#000000> <EMBED src="http://flashsenic.com/flashsenic.swf" quality=high bgcolor=#000000  WIDTH="830" HEIGHT="84" ALIGN=""
 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT></center>
<!-- /BANNER CODE -->

<table border="<?=$border?>" cellspacing="0" cellpadding="0" width="830" align="center">
<tr>
   <td width="100%" height="28" background="files/flashsenicheadertwo830x27.png" align="center"><font size="<?=$fontsize?>">


<?php include('/home/flash/public_html/flash.php');?>

 </font></td>
</tr>
</table>


<!-- BREAK BANNER FROM TABLES -->
<center><img src="files/flashsenicmainbody.png"></center>
<!-- /BREAK BANNER FROM TABLES -->

<table border="<?=$border?>" cellspacing="0" cellpadding="0" width="830" align="center">
<tr>
   <td width="100%" background="files/flashsenicmainbody.png">

<!-- IINITIALIZING CODE FOR INSIDE THE TABLE -->

<table border="0" cellspacing="0" cellpadding="4" width="95%" align="center">
<tr>
   <td width="200" valign="top">
   <!-- LEFT BLOCK TABLE -->

    <!-- CREATING LOGIN FORM -->
   <?php
   if (!$login->logged()){
   title(">> Quick Login", "left");
   echo ("<table border=\"0\" cellspacing=\"1\" bgcolor=\"000000\" cellpadding=\"0\" width=\"100%\" align=\"center\">
<tr>
   <td width=\"100%\" bgcolor=\"383E45\"><font size=\"2\">Username: ");$login->username();echo ("<br>Password: "); $login->password(); echo ("<br>"); $login->submit(); $login->verify(); echo("<center>[
   <a href=\"index.php?action=reg\">Register?</a> ]</center></font></td>
</tr>
</table><br>");
   };
  ?>
   <!-- /CREATING LOGIN FORM -->


       <!-- CREATING USER PANEL -->
   <?php
   if ($login->logged()){
   title(">> Welcome $_SESSION[user]", "left");
   echo ("<table border=\"0\" cellspacing=\"1\" bgcolor=\"000000\" cellpadding=\"0\" width=\"100%\" align=\"center\">
<tr>
   <td width=\"100%\" bgcolor=\"383E45\"><font size=\"2\">  <a href=\"forum/index.php\">View</a> |<a href=\"forum/index.php\">Edit Porfile</a> <br> <a href=\"portal/submit.php\">Submit Flash </a><br> <a href=\"portal/movie.php\">View Submission(s) </a><br> 
 <a href=\"portal/respond.php\">Respond</a> <br> <a href=\"forum/index.php\">BBS</a> <br><hr> Average Portal Score : <b> Commin soon</b> <br>Rank:<b>Commin Soon</b> <br> BBS Post(s): <b> </b></font></td>
</tr>
</table><br>");
   };
  ?>
   <!-- /CREATING USER PANEL -->

   <?=title(">> Hot Portal Pics", "left");
   echo ("<table border=\"0\" cellspacing=\"1\" bgcolor=\"000000\" cellpadding=\"0\" width=\"100%\" align=\"center\">
<tr>
   <td width=\"100%\" bgcolor=\"383E45\"><font size=\"2\">Hot Portal Picks</font></td>
</tr>
</table><br>");
   
?>

  <?=title(">> Top Affiliates", "left");
   echo ("<table border=\"0\" cellspacing=\"1\" bgcolor=\"000000\" cellpadding=\"0\" width=\"100%\" align=\"center\">
<tr>
   <td width=\"100%\" bgcolor=\"383E45\"><font size=\"2\">Top Afiliates</font></td>
</tr>
</table><br>");
   
   ?>


   <?=title(">> Rate Us", "left");
   $_TABLECOLOR = "303438";
        echo ("<table border=\"0\" cellspacing=\"1\" bgcolor=\"000000\" cellpadding=\"0\" width=\"100%\" align=\"center\">
<tr>
   <td width=\"100%\" bgcolor=\"383E45\"><font size=\"2\">"); include"poll.mod"; echo("</font></td>
</tr>
</table><br>");
   ?>


   <!-- /LEFT BLOCK TABLE -->
   </td>

   <td width="430" valign="top">
    <!-- MIDDLE BLOCK TABLE -->
   <?
    if (isset($_GET["action"])){
     if ($_GET["action"] == "reg"){
     echo ("<form method=\"post\" action=\"\">");
     }; //end if action = reg
   }; //end isset action
   ?>

   <?=title(">> Flash Senic News <<", "center");

   if (isset($_GET["action"])){
     if ($_GET["action"] == "reg"){

    cont("
    <input type=\"text\" name=\"q\"> : Username<br>
    <input type=\"password\" name=\"w\"> : Password<br>
    <input type=\"text\" name=\"e\"> : E-mail Addy<br>
    <input type=\"text\" name=\"r\"> : Name<br>
    <input type=\"text\" name=\"t\"> : Country<br>
    <input type=\"text\" name=\"y\"> : Website<br>
    <input type=\"text\" name=\"u\"> : Avatar<br>
    <input type=\"text\" name=\"i\"> : Signature<br>
    <input type=\"submit\" name=\"a\" value=\"Register!\"></form>");
    
    if (isset($_POST["a"])){
    $mydb->mydb("forum/db", "users.dat");
    
    $fp = file("forum/db/users.dat");
    for ($i = 0; $i < count($fp); $i++){
    $key = explode("<~>", $fp[$i]);
    $taken = "0";
    if ($_POST["q"] == "$key[0]"){
      $taken = "1";
    };

    if ($taken != "1"){
      $test = $mydb->addRecord(array($_POST["q"], $_POST["w"], $_POST["e"], "3", $_POST["r"], $_POST["t"], $_POST["y"], $_POST["u"], "0", $_POST["i"]));
      header ("Location: http://www.flashsenic.com/index.php?msg=1");
      exit();
    };
    
    }; //end $i
    };

     }; //end if action = reg
   }; //end isset action
   

    if (isset($_GET["action"])){
     if ($_GET["action"] == "members"){
     $mydb->showTables("forum/db", "users.dat", array("0", "4", "5", "8"), "303438", "383E45");
     }; //end if action = reg
   }; //end isset action

if (isset($_GET['msg'])) {
    echo '<div align="center"><font size="2">Thankyou for registering for FS. Please login using your username and password.</font></div>';
}
     echo ("<table border=\"0\" cellspacing=\"1\" bgcolor=\"000000\" cellpadding=\"0\" width=\"100%\" align=\"center\">
<tr>
   <td width=\"100%\" bgcolor=\"383E45\"><font size=\"2\">
<?php include('/home/flash/public_html/news/news.php');?><font></td>
</tr>
</table><br>");
   ?>




   <!-- /MIDDLE BLOCK TABLE -->
   </td>
   <td width="200" valign="top">
      <!-- RIGHT BLOCK TABLE -->

   <?=title("Top 100 Point Leaders <<", "right");
      echo ("<table border=\"0\" cellspacing=\"1\" bgcolor=\"000000\" cellpadding=\"0\" width=\"100%\" align=\"center\">
<tr>
   <td width=\"100%\" bgcolor=\"383E45\"><font size=\"2\">100 Point Leaders</font></td>
</tr>
</table><br>");
   
?>


<?=title("Latest Submissions <<", "right");
     echo ("<table border=\"0\" cellspacing=\"1\" bgcolor=\"000000\" cellpadding=\"0\" width=\"100%\" align=\"center\">
<tr>
   <td width=\"100%\" bgcolor=\"383E45\"><font size=\"2\">Latest Submissions</font></td>
</tr>
</table><br>");
   
?>


<?=title("Latest Forum Posts <<", "right");
   echo ("<table border=\"0\" cellspacing=\"1\" bgcolor=\"000000\" cellpadding=\"0\" width=\"100%\" align=\"center\">
<tr>
   <td width=\"100%\" bgcolor=\"383E45\"><font size=\"2\">Latest Forum Post</font></td>
</tr>
</table><br>");
   
?>




<!-- /RIGHT BLOCK TABLE -->
   </td>
</tr>
</table>

<!-- /IINITIALIZING CODE FOR INSIDE THE TABLE -->

   </td>
</tr>
</table>
<!-- INITIALIZING TOOTER -->
<center><img src="files/flashsenicbottom830x46.png"></center><center><a href='http://flashsenic.com'>Flashsenic.com</a> © 2004 - All Rights Reserved | <a href='http://flashsenic.com/contactus.php'>Contact Us</a></body></center>

<!-- /INITIALIZING TOOTER -->

Re: Styles on frontpage?

I have a question here, how can i put this option http://fadered.hollosite.com/style.jpg on the frontpage. The same concept like this code by

Jansson wrote:

if($cookie['is_guest'])
    echo 'Not logged in';
else
    echo 'Logged in as: '.$cur_user['username'].'<br>Last visit: '.format_time($cur_user['last_visit']);

if mONey is lOSt nOThINg is lOSt,
if cHArACtER is lOSt sOMeTHiNG is lOSt,
bUT,
if rELiGIon and eDUcATiON aRE lOSt eVErYThINg is lOSt.

23

Re: Styles on frontpage?

check profile.php for the proper <form>-code that creates that option-box. Then put the code under the "else"-statement

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde

Re: Styles on frontpage?

I've done that before but it's doesn't work out

if mONey is lOSt nOThINg is lOSt,
if cHArACtER is lOSt sOMeTHiNG is lOSt,
bUT,
if rELiGIon and eDUcATiON aRE lOSt eVErYThINg is lOSt.

25 (edited by bobitt 2004-10-28 18:35)

Re: Styles on frontpage?

I coded around a bit and made a little mod smile
make a file called "style.php" put the code below in it and put it on your forum root.

<?php
If (isset($_POST['style_sent']) && $_POST['style_sent'] == 1)
    {
    $pun_root = './';
    include($pun_root.'include/common.php');
    $style = (isset($cur_user)) ? $cur_user['style'] : $pun_config['o_default_style'];
    echo '<link rel="stylesheet" type="text/css" href="'.$pun_root.'style/'.$style.'.css">';

    $id = $cur_user['id'];
    $db->query('UPDATE '.$db->prefix.'users SET    style=\''.addslashes($_POST['style']).'\' WHERE id='.$id) or error('Unable to update style', __FILE__, __LINE__, $db->error());
    redirect($pun_root.'hem.php', 'Sida redigerad, vänta...');
    }
?>

<tr>
    <td><br><b>Style</b>
        <form method="post" action="<?php echo $pun_root; ?>style.php"> 
            <input type="hidden" name="style_sent" value="1">
            <select name="style">
            <?php
            $d = dir($pun_root.'style');
            while (($entry = $d->read()) !== false)
                {
                if (substr($entry, strlen($entry)-4) == '.css')
                    $styles[] = substr($entry, 0, strlen($entry)-4);
                }
                $d->close();

            while (list(, $temp) = @each($styles))
                {
                if ($user['style'] == $temp)
                    echo "\t\t\t\t\t".'<option value="'.$temp.'" selected>'.str_replace('_', ' ', $temp).'</option>'."\n";
                else
                    echo "\t\t\t\t\t".'<option value="'.$temp.'">'.str_replace('_', ' ', $temp).'</option>'."\n";
                }    
            ?>
            </select>&nbsp&nbsp<input type="submit" value="Change">
        </form>
    </td>
</tr>

Then include it wherever you like on your forum using:

<?php include($pun_root.'style.php'); ?>

Most of the code is "borrowed" from profile.php...

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde