• Welcome to The Campaign Builder's Guild.
 

News:

We're back!

Main Menu

Site design

Started by Matt Larkin (author), September 30, 2006, 02:50:21 PM

Previous topic - Next topic

Matt Larkin (author)

I cleaned up the code a little, and removed the "@" from the php code so I could see the error:

Quote from: '.:/usr/local/php5/lib/php') in /home/.tallyho/shadowfell/thecbg.org/settings/137/index.php on line 18[/quote<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<?php /* Created on: 12/10/2006 */ ?>
<html>   
<head>
   <title>Kishar</title>     
   <link rel="stylesheet" type="text/css" href="styles.css">
</head>

<body>   



<div class="content">
   <?php require_once ("$page.html"); ?>
</div>

<div class="menu">     
    <a href="index.php?page=home">Home</a>
    <a href="index.php?page=trial">Trial</a>
</div>


</body>
</html>[/spoiler]
Mainly I just changed the DIV id's to DIV classes, and of course the CSS.
Latest Release: Echoes of Angels

NEW site mattlarkin.net - author of the Skyfall Era and Relics of Requiem Books
incandescentphoenix.com - publishing, editing, web design

limetom

Well... from what I can tell we're running a *nix server, and the server cannot find "index.php?page=home" in the directory location "/home/.tallyho/shadowfell/thecbg.org/settings/137/index.php".

The error, I think, says that it cannot find ".html" in the link.  Try adding it on to the end of "page=home" and "page=trial" in the links (thus "page=home.html" and "page=trial.html") and see what happens.  No clue if it will work, but that's what I'd do...

brainface

<?php @ require ("$page.html"); ?>
$page is a variable, and undefined. so it loads
$page + ".html", which is just ".html"

try adding

if (!page) {
$page = 'home';
}

somewhere ABOVE <?php @ require ("$page.html"); ?>

shadowfell is the name of our account. ignore that.

"The perfect is the enemy of the good." - Voltaire

Matt Larkin (author)

Thank you both, unfortunately, I still have not been able to get things working.

The if coding does not seem to work.  Is the intent to make say "if not page (if page is not defined) then set it to 'home'"?

Is this the implementation you used for the Shadowfell site, or am I missing further code?  Do you still have access to the original code before PHP is applied so I could see if I've lost something small?

If I assign the variable non-conditionally, e.g.

$page = 'home';

then I don't get an error message, but the menu does not allow me to switch between content.

I've spent the afternoon filtering through the PHP Manual and Codewalkers trying to figure out what is going wrong, but I have to admit this is over my head, a bit.

Oh, and I switched the order of the content/menu DIVs to more closely resemble the Shadowfell page:

[spoiler=index.php]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<?php /* Created on: 12/10/2006 */ ?>
<html>   
<head>
   <title>Kishar</title>     
   <link rel="stylesheet" type="text/css" href="styles.css">
</head>

<body>
   


<div class="menu">     
    <a href="index.php?page=home">Home</a>
    <a href="index.php?page=trial">Trial</a>
</div>


<div class="content">
<?php if (!page) {
$page = 'home';
}
require_once ("$page.html"); ?>
</div>



</body>
</html>
[/spoiler]

Oh, I did at first try the "if" clause as a seperate <?php ?> statement, but that didn't work, which is when I tried moving it into the same one.  I assume that makes no difference.
Latest Release: Echoes of Angels

NEW site mattlarkin.net - author of the Skyfall Era and Relics of Requiem Books
incandescentphoenix.com - publishing, editing, web design

brainface

QuoteOh, I did at first try the "if" clause as a seperate <?php ?> statement, but that didn't work, which is when I tried moving it into the same one. I assume that makes no difference.
it doesn't.
i'll look at your code in a bit. I can probably pull yours off the server. i'll also try to get you a copy of shadowfell (probably cleaned of brandon's actual content.)
"The perfect is the enemy of the good." - Voltaire

Matt Larkin (author)

Thanks, I very much appreciate it, brainface.
Latest Release: Echoes of Angels

NEW site mattlarkin.net - author of the Skyfall Era and Relics of Requiem Books
incandescentphoenix.com - publishing, editing, web design

brainface

This is pretty barebones, but hey, it's got the php code.

Also, here's your index.php, fixed.

!page should have been !$page (that's possibly my fault.)

Also, you need the code $page = $_GET['page'];, or $page is always null. (this isn't necessary in older php versions, or different servers, etc. it's a security thing.) It's in the fixed index file, you can see it.
File: 1165888326_4_FT16209_shadowclean.zip
File: 1165888326_4_FT16209_index.php.zip
"The perfect is the enemy of the good." - Voltaire

Matt Larkin (author)

Thanks very much, brainface.  I really appreciate all the help.
Latest Release: Echoes of Angels

NEW site mattlarkin.net - author of the Skyfall Era and Relics of Requiem Books
incandescentphoenix.com - publishing, editing, web design

Matt Larkin (author)

Brainface (or anyone that can answer), is it possible to link to a specific location on another page when I'm using php to call the page?

The normal method:

page url#id name

doesn't seem to work (which I guess makes sense, given that its subing the entry).

I see you to specific location links on Shadowfell within the same page, but what I'm looking to do is have a glossary page, which I can link to specific terms in from other content pages.
Latest Release: Echoes of Angels

NEW site mattlarkin.net - author of the Skyfall Era and Relics of Requiem Books
incandescentphoenix.com - publishing, editing, web design

brainface

like this:
http://www.shadowfell.org/jaggerfell/index.php?page=classes#knightErrant
variables first, #location second.
"The perfect is the enemy of the good." - Voltaire

Matt Larkin (author)

Thanks.  I don't know why that didn't work the first time, since that's what I tried.  I must have mistyped something, 'cause it worked this time.
Latest Release: Echoes of Angels

NEW site mattlarkin.net - author of the Skyfall Era and Relics of Requiem Books
incandescentphoenix.com - publishing, editing, web design

brainface

yeah, that happens ;)
"The perfect is the enemy of the good." - Voltaire

Lmns Crn

I've been working through some CSS tutorials, and while I think I understand the basics, I can't seem to find a way to use this with actual content.

What I'd like to be able to do is, for example, have an identical navigation bar on each page, with links to various parts of the site, but not have to code the nav bar seperately on each page. Essentially, I'd like to have a nav bar I could change once if I add a new section to the site, rather than changing it some 75 times.
I move quick: I'm gonna try my trick one last time--
you know it's possible to vaguely define my outline
when dust move in the sunshine

Matt Larkin (author)

You need some kind of server side include to do that.  Most of this thread was about my trying to use php to do so (after brainface explained that was how to do so).  It's what I use for my Kishar site.

Our hosting section supports php, but many web servers don't.  If you plan to host here, it works great.  Otherwise, check first.  Most of what you need, you can find in this thread.  But I'll show you my code for it.

In my main file (index.php)


<div id="menu">  
<a href="index.php?page=home">Home</a>
<a href="index.php?page=FAQ">FAQ</a>
<a href="index.php?page=glossary">Glossary</a>
<a href="index.php?page=map">Map</a>
<a href="index.php?page=cosmology/cosmology">Cosmology</a>
<div class="submenu">
<a href="index.php?page=cosmology/cosmogony">Cosmogony</a>
<a href="index.php?page=cosmology/animas">Animas</a>
<a href="index.php?page=cosmology/outer">Outer Realm</a>
</div>
<a href="index.php?page=overview">The World</a>
<a href="index.php?page=cast">Cast</a>
<a href="index.php?page=fiction">Fiction</a>
</div>

<div id="content-wrapper">
<div id="content">
<?php
$page $_GET['page'];
 if (!$page) {$page 'home'; }
require_once ("$page.html"); ?>

</div>
<div id="copyright">
Copyright 2005-2007 Matt A. Larkin
</div>
</div>


[spoiler=relevant CSS]

#menu
  {  
  margin-top: 1em;
  width: 125px;  
  background-color: #546454;  
  padding-bottom: 5em;
  float: left;
  }

#content a,
#menu a
  {  
  color: #003300;
  }
 
#content a:hover
  {
  color: #007700;
  }
 
#menu a,
#menu .submenu a
  {
  display:block;
  background-color: #D3D3D3;
  font-weight: bold;
  font-size: 0.9em;
  margin: 1px;
  font-variant: small-caps;
  text-decoration: none;
  padding: 1px;
  padding-left: 5px;
  border-right: solid 5px #005000;
  }

#menu a:hover
  {
  background-color:#78A378;
  }

#menu .submenu a
  {  
  background-color: #eeeeee;
  padding-left: 1.5em;
  font-size: .75em;
  border-right: solid 5px #333333;
  }
 
#menu .submenu a:hover
  {
  background-color: #ffffff;
  }

[/spoiler]

The site brainface links to earlier explains the basics, but left out a small bit of code (which brainface fixed for me (see a few posts up).

The "code" tag I used here seems to have inserted bunches of ";" in my index.php code after each "<".  Those obviously shouldn't be there.
Latest Release: Echoes of Angels

NEW site mattlarkin.net - author of the Skyfall Era and Relics of Requiem Books
incandescentphoenix.com - publishing, editing, web design

Lmns Crn

Oh... goodness. I guess I'm learning PHP in addition to CSS, then! I do plan on hosting it here, so that shouldn't be a problem. At any rate, it looks like I have some reading to do. Thanks for the nudge in the right direction!

Edit: So in function, PHP is to content what CSS is to styles? Allowing you to predefine chunks of it that you can later call forth at will?

Edit again: Okay, I am beginning to understand the premise. This is radically cool.
I move quick: I'm gonna try my trick one last time--
you know it's possible to vaguely define my outline
when dust move in the sunshine