Re: [PHP] Re: PHP Includes and Echoes (From the top...)

2004-01-16 Thread Freedomware
Thanks for all the tips. It's getting generally getting clearer, but I'm 
a little confused somewhere.

Can I give you a better explanation of what I'm trying to do, along with 
my latest code?

The pages on this site focus on various nations and states, with lots of 
links like this:

[LOCAL] ../world/na/us/wy/index.php (World/North America/United 
States/Wyoming)

[REMOTE] www.politix.org/world/na/us/wy/

Each page will feature several prominent instances of the name of a 
country or state, which I can facilitate by using 'MyName', such as the 
title (MyName = Canada, or Wyoming), along with several instances of its 
abbreviation, which is used in several URLs and in the top banner; for 
example, this is the top banner for Alaska: img 
src=../images/banners/ak.gif width=200 height=150 alt= /

Below is the entire head section from the main page. Notice that it's 
mostly a series of variable statements ('MyName', 'MyCountry', etc.), 
followed by an included page (head), which is essentially the REAL head 
section.

I inserted one of the functions you suggested - $includea1 = TRUE; - 
after the include, but I'm sure I did it wrong.

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
?php
$myname = 'MyName';
$mynickname = 'MyNickname';
$mycontinent = 'North America';
$mycountry = 'United States';
$mystate = 'MyState';
$postcode = 'wy';
$linkcontinent = '/na';
$linkcountry = '/us';
$linkstate = '/wy';
$periods = '../../../../';
$linkwebring = '/world/na/us/wy/';
include (../../../../includes/head.php);
$includea1 = TRUE;
?
/head

* * * * * * * * * *

And here's the included page:

?php
$todayDate = date(m-d-Y);
echo 'titleFreedomware gt; ' . $statename . '/title';
echo 'meta name=description content=' . $statename . ' versus 
Microsoft /';
echo 'meta name=keywords content=' . $statename . ' versus 
Microsoft /';
echo 'meta name=mssmarttagspreventparsing content=true /';
echo 'meta http-equiv=content-Type content=text/html; 
charset=iso-8859-1 /';
echo 'meta name=author content=David Blomstrom /';
echo 'script src=' . $periods . 'js/swapclass.js 
type=text/javascript/script';
echo 'script src=' . $periods . 'js/ss.js 
type=text/javascript/script';
echo 'script language=JavaScript type=text/JavaScript
!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//--
/script';
echo 'link href=' . $periods . 'css/a1.css rel=stylesheet 
type=text/css /';
if ($includea1) echo 'link href=' . $periods . 'css' . $linkcontinent 
. '/a1.css rel=stylesheet type=text/css /';
echo 'link href=' . $periods . 'css/na/north.css rel=stylesheet 
type=text/css /';
echo 'link href=' . $periods . 'css/themes/peace.css rel=alternate 
stylesheet type=text/css title=Peace /';
echo 'link href=' . $periods . 'css/themes/war.css rel=alternate 
stylesheet type=text/css title=War /';
echo 'link rel=SHORTCUT ICON href=../../../../us/aaa/favicon.ico /'
?

Note that two of my style sheets are named css/a1.css and css/na/a1.css 
(na is short for North America). Maybe I should rename the second a1 to 
avoid confusion, though I'd prefer to tackle it head on and learn how to 
deal with this situation. (Does $includea1 = TRUE; refer to css/a1.css 
or css/na/a1.css?)

So here's what I have at present:

* * * * * * * * * *

The first line denotes style sheet css/a1.css, preceded by . $periods 
., which can be replaced by ../../ or ../../../, depending on the 
folder level:

echo 'link href=' . $periods . 'css/a1.css rel=stylesheet 
type=text/css /';

* * * * * * * * * *

The second line denotes style sheet css/na/a1.css, preceded by if 
($includea1), which I'm probably using incorrectly:

if ($includea1) echo 'link href=' . $periods . 'css' . $linkcontinent 
. '/a1.css rel=stylesheet type=text/css /';

Note, also, that I inserted . $linkcontinent ., which will be replaced 
by na/ (North America) on this particular main page.

In summary, it looks like I need to fix two things:

MAIN PAGE

$linkwebring = '/world/na/us/wy/';
include (../../../../includes/head.php);
$includea1 = TRUE;
?
/head
INCLUDED PAGE

echo 'link href=' . $periods . 'css/a1.css rel=stylesheet 
type=text/css /';
if ($includea1) echo 'link href=' . $periods . 'css' . $linkcontinent 
. '/a1.css rel=stylesheet type=text/css /';
echo 'link href=' . $periods . 'css/na/north.css rel=stylesheet 
type=text/css /';

* * * * * * * * * *

I hope that isn't too confusing. It's actually becoming a lot clearer 
for me; I'm just temporarily confused.

Thanks!

* * * * * * * * * *

I wrote,

 ? Holy cow, this gets simpler all the time.

 ? But suppose there's a certain page where I don't want the
 style sheet in
 ? the middle - the one I named MIDDLE. Is there a way to mark
 it in the
 ? include page, then instruct the main page to either not import it or
 ? replace it with nothing ()?
On 15 January 2004 22:39, Luke wrote:

RE: [PHP] Re: PHP Includes and Echoes (From the top...)

2004-01-16 Thread Ford, Mike [LSS]
On 16 January 2004 13:54, Freedomware wrote:

 Thanks for all the tips. It's getting generally getting
 clearer, but I'm
 a little confused somewhere.

[SNIP] 

 I inserted one of the functions you suggested - $includea1 = TRUE; -
 after the include, but I'm sure I did it wrong.

Just like before -- put it *before* the include, otherwise the included file
won't see it.

[SNIP]

 //--
 /script';
 echo 'link href=' . $periods . 'css/a1.css rel=stylesheet
 type=text/css /'; if ($includea1) echo 'link href=' . $periods .
 'css' . $linkcontinent . '/a1.css rel=stylesheet type=text/css
 /'; 
 echo 'link href=' . $periods . 'css/na/north.css rel=stylesheet
 type=text/css /'; echo 'link href=' . $periods .
 'css/themes/peace.css rel=alternate stylesheet type=text/css
 title=Peace /'; 
 echo 'link href=' . $periods . 'css/themes/war.css rel=alternate
 stylesheet type=text/css title=War /';
 echo 'link rel=SHORTCUT ICON
 href=../../../../us/aaa/favicon.ico /'
  
 
 Note that two of my style sheets are named css/a1.css and
 css/na/a1.css (na is short for North America). Maybe I should rename
 the 
 second a1 to
 avoid confusion, though I'd prefer to tackle it head on and
 learn how to
 deal with this situation. (Does $includea1 = TRUE; refer to css/a1.css
 or css/na/a1.css?)

Well, which one is controlled by the if ($includea1) test?

 
 So here's what I have at present:
 

Apart from the above points, looks ok for what you're trying to do.  Keep
plugging away and you'll get there -- a couple of years ago I was a complete
PHP beginner (although an experienced programmer), and now I have several
thousand lines of code in production use!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php