By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,847 Members | 2,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,847 IT Pros & Developers. It's quick & easy.

Change included code

P: n/a
Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.

Thanks,
Jon
Apr 19 '07 #1
Share this Question
Share on Google+
27 Replies


P: n/a
Jon Slaughter wrote:
Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.

Thanks,
Jon

Ensure your link is an absolute path relative to your website root.
Then where you include index.php doesn't matter.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #2

P: n/a

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast.com. ..
Jon Slaughter wrote:
>Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.

Thanks,
Jon

Ensure your link is an absolute path relative to your website root. Then
where you include index.php doesn't matter.
It would actually be a bit more trouble since any time I want to upload to
the server to test I will have to change the link. Would be easier just to
have php just add "../" to one spot instead manually doing it every time I
upload to the server.
Apr 19 '07 #3

P: n/a
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast.com. ..
>Jon Slaughter wrote:
>>Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.

Thanks,
Jon
Ensure your link is an absolute path relative to your website root. Then
where you include index.php doesn't matter.

It would actually be a bit more trouble since any time I want to upload to
the server to test I will have to change the link. Would be easier just to
have php just add "../" to one spot instead manually doing it every time I
upload to the server.

And why is that? I never have to change links when I upload to my servers.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #4

P: n/a

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast.com. ..
Jon Slaughter wrote:
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast.com ...
>>Jon Slaughter wrote:
Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot.
I need to add "../" to the css file reference in Index.php to make it
work.

Thanks,
Jon
Ensure your link is an absolute path relative to your website root. Then
where you include index.php doesn't matter.

It would actually be a bit more trouble since any time I want to upload
to the server to test I will have to change the link. Would be easier
just to have php just add "../" to one spot instead manually doing it
every time I upload to the server.

And why is that? I never have to change links when I upload to my
servers.

Um, because the directory structure differs on my server than my computer?
My server uses public_html to hold html files while my computer doesn't. I
suppose I could go mess with the apache config file and change it though but
it still doesn't solve my problem complete. I still need to inject html
files into containers in the html/php code.

e.g. when I do

<?php include ('SomeFile.php') ?>

I need to also do something like

<?php include ('File2.php') INTO This.DOM.MainDiv ?>

(just psuedocode)

That is, SomeFile contains a html container that I'd like to fill with
another file(Which needs to be arbitrary).

Maybe I'm going about it wrong but I'm simply trying to make a template that
exists on pages of my web site. Because of the design of the template I
cannotjust do something like

<?php include ('SomeFile.php') ?>

dflasdjflalsdflkaslkdjf
and have that texted show up in the right place. I could split the file
into something like

<?php include ('SomeFile1.php') ?>
dflasdjflalsdflkaslkdjf
<?php include ('SomeFile2.php') ?>

and then it would work but just doesn't seem elegant.
(basically SomeFile1.php ends like

<div class="Container">
and Somefile2.php has the final code

</div>
</body>
</html>
I might end up using that though as it seems pretty simple

Thanks,
Jon

Apr 19 '07 #5

P: n/a
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast.com. ..
>Jon Slaughter wrote:
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast.co m...
Jon Slaughter wrote:
Can I modify code that I have included using
>
<?php
include("../Index.php");
?>
>
The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot.
I need to add "../" to the css file reference in Index.php to make it
work.
>
Thanks,
Jon
Ensure your link is an absolute path relative to your website root. Then
where you include index.php doesn't matter.

It would actually be a bit more trouble since any time I want to upload
to the server to test I will have to change the link. Would be easier
just to have php just add "../" to one spot instead manually doing it
every time I upload to the server.
And why is that? I never have to change links when I upload to my
servers.


Um, because the directory structure differs on my server than my computer?
My server uses public_html to hold html files while my computer doesn't. I
suppose I could go mess with the apache config file and change it though but
it still doesn't solve my problem complete. I still need to inject html
files into containers in the html/php code.
So? Mine differs also - my test system is Windows and most of my hosts
are Unix. And my directory here is much different than the one on the
server. I just set up Apache to handle it. Much easier than trying to
screw around with files like you are.
e.g. when I do

<?php include ('SomeFile.php') ?>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/SomeFile.php'); ?>

Use the features of the language.
I need to also do something like

<?php include ('File2.php') INTO This.DOM.MainDiv ?>
(just psuedocode)

That is, SomeFile contains a html container that I'd like to fill with
another file(Which needs to be arbitrary).
Same thing.

Maybe I'm going about it wrong but I'm simply trying to make a template that
exists on pages of my web site. Because of the design of the template I
cannotjust do something like

<?php include ('SomeFile.php') ?>

dflasdjflalsdflkaslkdjf
and have that texted show up in the right place. I could split the file
into something like

<?php include ('SomeFile1.php') ?>
dflasdjflalsdflkaslkdjf
<?php include ('SomeFile2.php') ?>

and then it would work but just doesn't seem elegant.
(basically SomeFile1.php ends like

<div class="Container">
and Somefile2.php has the final code

</div>
</body>
</html>
I might end up using that though as it seems pretty simple

Thanks,
Jon
Whatever. I just include files where they are needed. Sometimes
they're at the top of the file, sometimes the bottom, and sometimes in
between.

What's more important - something you think looks "elegant", or
something which works and is easy to maintain?


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #6

P: n/a
>>>Index.php is basically an html file uses a linked css file and when its
>>>included in the new file its referencing a css file in the wrong spot.
I need to add "../" to the css file reference in Index.php to make it
work.
If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.

Apr 19 '07 #7

P: n/a

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:yf******************************@comcast.com. ..
Jon Slaughter wrote:
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast.com ...
>>Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast.c om...
Jon Slaughter wrote:
>Can I modify code that I have included using
>>
><?php
>include("../Index.php");
>?>
>>
>The Index.php file contains links that need to be modified to work.
>Index.php is basically an html file uses a linked css file and when
>its included in the new file its referencing a css file in the wrong
>spot. I need to add "../" to the css file reference in Index.php to
>make it work.
>>
>Thanks,
>Jon
Ensure your link is an absolute path relative to your website root.
Then where you include index.php doesn't matter.
>
It would actually be a bit more trouble since any time I want to upload
to the server to test I will have to change the link. Would be easier
just to have php just add "../" to one spot instead manually doing it
every time I upload to the server.
And why is that? I never have to change links when I upload to my
servers.


Um, because the directory structure differs on my server than my
computer? My server uses public_html to hold html files while my computer
doesn't. I suppose I could go mess with the apache config file and change
it though but it still doesn't solve my problem complete. I still need to
inject html files into containers in the html/php code.

So? Mine differs also - my test system is Windows and most of my hosts
are Unix. And my directory here is much different than the one on the
server. I just set up Apache to handle it. Much easier than trying to
screw around with files like you are.
>e.g. when I do

<?php include ('SomeFile.php') ?>

<?php include ($_SERVER['DOCUMENT_ROOT'] . '/SomeFile.php'); ?>

Use the features of the language.
To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

But when I include the main file the styles/main.css is referenced from the
directory of that file... but there is not styles/main.css from in that
directory of that file unless it happens to be the root.

Got any more bright ideas?

Apr 19 '07 #8

P: n/a

<ge*********@gmail.comwrote in message
news:11*********************@b58g2000hsg.googlegro ups.com...
>>>>Index.php is basically an html file uses a linked css file and when
its
included in the new file its referencing a css file in the wrong
spot.
I need to add "../" to the css file reference in Index.php to make
it
work.

If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.
Thanks, I'll try it. The reason I can't use absolute paths is because the
path on the remote server is different from the path that I have setup for
apache and therefore it does no good to hard code it. My only option there
is to setup apache to have the exact same dir structure as the remote
server. Ofcourse that might be the best thing and I guess I'll do it but
still need to know how to modify the file contents for other purposes.

Thanks,
Jon

Apr 19 '07 #9

P: n/a
Jo***********@Hotmail.com says...
To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">
Iv'e joined this thread late, so maybe I'm off track, but wouldn't the
following simple fix work:

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

Just tell all the scripts (regarless of where they are) that the style
sheet is to be sourced relative to the http document root.

GM
Apr 19 '07 #10

P: n/a

"Geoff Muldoon" <ge***********@trap.gmail.comwrote in message
news:MP************************@news.readfreenews. net...
Jo***********@Hotmail.com says...
>To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

Iv'e joined this thread late, so maybe I'm off track, but wouldn't the
following simple fix work:

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

Just tell all the scripts (regarless of where they are) that the style
sheet is to be sourced relative to the http document root.

Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect in
both cases.

Jon
Apr 19 '07 #11

P: n/a

"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:Tb***************@newssvr22.news.prodigy.net. ..
>
"Geoff Muldoon" <ge***********@trap.gmail.comwrote in message
news:MP************************@news.readfreenews. net...
>Jo***********@Hotmail.com says...
>>To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

Iv'e joined this thread late, so maybe I'm off track, but wouldn't the
following simple fix work:

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

Just tell all the scripts (regarless of where they are) that the style
sheet is to be sourced relative to the http document root.


Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect in
both cases.
Nope, doesn't work.

Apr 19 '07 #12

P: n/a

<ge*********@gmail.comwrote in message
news:11*********************@b58g2000hsg.googlegro ups.com...
>>>>Index.php is basically an html file uses a linked css file and when
its
included in the new file its referencing a css file in the wrong
spot.
I need to add "../" to the css file reference in Index.php to make
it
work.

If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.
using

<LINK REL=StyleSheet HREF="/Styles/Main.css" TYPE="text/css">

instead of

<LINK REL=StyleSheet HREF="Styles/Main.css" TYPE="text/css">

doesn't work when I do not include the the html file from a directory that
contains Styles/Main.css.

For some reason the absolute paths are not working. The browser is trying
not looking from the root but always from the current dir.

using code to change link still doesn't work

echo str_replace('"/Styles/Main.css"', '"/../Styles/Main.css"',
file_get_contents('../Main.php'); );

It does change the link properly but no matter what I use it does not find
the css file(I've tryed /.. and ../ but nothing works).
The directories are right but I can't seem to get the style sheet.
Apr 19 '07 #13

P: n/a

"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:2t***************@newssvr22.news.prodigy.net. ..
>
<ge*********@gmail.comwrote in message
news:11*********************@b58g2000hsg.googlegro ups.com...
>>>>>Index.php is basically an html file uses a linked css file and
>when its
>included in the new file its referencing a css file in the wrong
>spot.
>I need to add "../" to the css file reference in Index.php to make
>it
>work.

If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.

using

<LINK REL=StyleSheet HREF="/Styles/Main.css" TYPE="text/css">

instead of

<LINK REL=StyleSheet HREF="Styles/Main.css" TYPE="text/css">

doesn't work when I do not include the the html file from a directory that
contains Styles/Main.css.

For some reason the absolute paths are not working. The browser is trying
not looking from the root but always from the current dir.

using code to change link still doesn't work

echo str_replace('"/Styles/Main.css"', '"/../Styles/Main.css"',
file_get_contents('../Main.php'); );
(the extra ; is a bug... still doesn't work.
Apr 19 '07 #14

P: n/a
Message-ID: <hf***************@newssvr22.news.prodigy.netfro m Jon
Slaughter contained the following:
>Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect in
both cases.

Nope, doesn't work.
Are you working on a live server or a development subdirectory?
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Apr 19 '07 #15

P: n/a

"Geoff Berrow" <bl******@ckdog.co.ukwrote in message
news:7l********************************@4ax.com...
Message-ID: <hf***************@newssvr22.news.prodigy.netfro m Jon
Slaughter contained the following:
>>Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect
in
both cases.

Nope, doesn't work.

Are you working on a live server or a development subdirectory?
Both.

The issue seems this, I suppose the absolute directory is working... but the
links in the css file are not.

That is, the css file contains links to images for the background...

so in the css file there is lines like

background-image:url('images/someimage.gif');
But its not finding these images.

changing it to

background-image:url('/images/someimage.gif');

doesn't help either.

I guess I have to write a simple test case to see what the real problem is.
I can't tell if its not including the css or if it is but not the images
since theres not much in the css to tell the difference.
Its all work fine though as long as I'm accessing the css file from the root
dir but as soon as I try to reference it from a sub dir it gives me
problems.

Yeah, it seems to not be finding the images...

so the

background-image:url('/images/someimage.gif');

isn't working properly.
Ok, when I copy the Images directory to the Mathematics sub dir then
everything works...

so

background-image:url('/images/someimage.gif');

is trying to find the image in the sub directory instead of w.r.t to the
root dir.

Guess I gotta figure out what url actually does ;/
Thanks,
Jon
Apr 19 '07 #16

P: n/a

"Geoff Berrow" <bl******@ckdog.co.ukwrote in message
news:7l********************************@4ax.com...
Message-ID: <hf***************@newssvr22.news.prodigy.netfro m Jon
Slaughter contained the following:
>>Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect
in
both cases.

Nope, doesn't work.

Are you working on a live server or a development subdirectory?

Ok, I believe its now working. I needed to use the ../ on the images. I
actually had this before but I guess I screwed up somewhere and then started
changing things but now everything seems to be working. Not sure why it
didn't work the first time.

Thanks,
Jon
Apr 19 '07 #17

P: n/a
Jon Slaughter wrote:
My only option there is to setup apache to have the exact same dir
structure as the remote server
Not the same directory structure, but the same URL structure. These are
different (and often entirely unrelated) things.

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Apr 19 '07 #18

P: n/a

"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:Jz******************@newssvr29.news.prodigy.n et...
Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.

Thanks,
Jon
Ok, forget it. I guess its my incompetence. Not sure why it didn't work in
the first place but I probably should have coded the original html and css
file better. Had a few things mixed up and I suppose it wasn't the php part
that was wrong but I forgot I had some inline css that had relative links in
it and it wasn't find the the images.
Thanks,
Jon
Apr 19 '07 #19

P: n/a
ge*********@gmail.com wrote:
>>>>>>Index.php is basically an html file uses a linked css file and when its
>>included in the new file its referencing a css file in the wrong spot.
>>I need to add "../" to the css file reference in Index.php to make it
>>work.

If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.
Which includes another query to the webserver - and is very inefficient.
There's no reason to do this when the file is on the local filesystem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #20

P: n/a
Jon Slaughter wrote:
<ge*********@gmail.comwrote in message
news:11*********************@b58g2000hsg.googlegro ups.com...
>>>>>>>Index.php is basically an html file uses a linked css file and when
>>>its
>>>included in the new file its referencing a css file in the wrong
>>>spot.
>>>I need to add "../" to the css file reference in Index.php to make
>>>it
>>>work.
If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.

Thanks, I'll try it. The reason I can't use absolute paths is because the
path on the remote server is different from the path that I have setup for
apache and therefore it does no good to hard code it. My only option there
is to setup apache to have the exact same dir structure as the remote
server. Ofcourse that might be the best thing and I guess I'll do it but
still need to know how to modify the file contents for other purposes.

Thanks,
Jon
Jon,

Did you even read my message earlier? The relative path does not need
to be dependent on the absolute path to your document root. They are
two entirely different things.

All of my sites use absolute paths for their include and require
statements. And all of them work both on test and production machines,
despite very different directory structures.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #21

P: n/a
Jon Slaughter wrote:
<ge*********@gmail.comwrote in message
news:11*********************@b58g2000hsg.googlegro ups.com...
>>>>>>>Index.php is basically an html file uses a linked css file and when
>>>its
>>>included in the new file its referencing a css file in the wrong
>>>spot.
>>>I need to add "../" to the css file reference in Index.php to make
>>>it
>>>work.
If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.

using

<LINK REL=StyleSheet HREF="/Styles/Main.css" TYPE="text/css">

instead of

<LINK REL=StyleSheet HREF="Styles/Main.css" TYPE="text/css">

doesn't work when I do not include the the html file from a directory that
contains Styles/Main.css.

For some reason the absolute paths are not working. The browser is trying
not looking from the root but always from the current dir.

using code to change link still doesn't work

echo str_replace('"/Styles/Main.css"', '"/../Styles/Main.css"',
file_get_contents('../Main.php'); );

It does change the link properly but no matter what I use it does not find
the css file(I've tryed /.. and ../ but nothing works).
The directories are right but I can't seem to get the style sheet.

Of course. "../Main.php" is a request to the webserver to fetch a file
one level below the root directory - which is not accessible to outside
requests.

And this is the crappiest way to go - see my note above about it
requiring a lot of additional and unnecessary work on the webserver.

Your problem is not the code. It's your screwed up test environment.
Straighten that out and it will work.

You're using a hammer to drive in a screw. And when that doesn't work,
you're trying a bigger hammer.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #22

P: n/a
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:yf******************************@comcast.com. ..
>Jon Slaughter wrote:
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast.co m...
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast. com...
>Jon Slaughter wrote:
>>Can I modify code that I have included using
>>>
>><?php
>>include("../Index.php");
>>?>
>>>
>>The Index.php file contains links that need to be modified to work.
>>Index.php is basically an html file uses a linked css file and when
>>its included in the new file its referencing a css file in the wrong
>>spot. I need to add "../" to the css file reference in Index.php to
>>make it work.
>>>
>>Thanks,
>>Jon
>Ensure your link is an absolute path relative to your website root.
>Then where you include index.php doesn't matter.
>>
It would actually be a bit more trouble since any time I want to upload
to the server to test I will have to change the link. Would be easier
just to have php just add "../" to one spot instead manually doing it
every time I upload to the server.
And why is that? I never have to change links when I upload to my
servers.
Um, because the directory structure differs on my server than my
computer? My server uses public_html to hold html files while my computer
doesn't. I suppose I could go mess with the apache config file and change
it though but it still doesn't solve my problem complete. I still need to
inject html files into containers in the html/php code.
So? Mine differs also - my test system is Windows and most of my hosts
are Unix. And my directory here is much different than the one on the
server. I just set up Apache to handle it. Much easier than trying to
screw around with files like you are.
>>e.g. when I do

<?php include ('SomeFile.php') ?>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/SomeFile.php'); ?>

Use the features of the language.

To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

But when I include the main file the styles/main.css is referenced from the
directory of that file... but there is not styles/main.css from in that
directory of that file unless it happens to be the root.

Got any more bright ideas?
Like I said - use

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

And get your test environment straightened out.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #23

P: n/a
Jon Slaughter wrote:
"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:Tb***************@newssvr22.news.prodigy.net. ..
>"Geoff Muldoon" <ge***********@trap.gmail.comwrote in message
news:MP************************@news.readfreenews .net...
>>Jo***********@Hotmail.com says...

To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">
Iv'e joined this thread late, so maybe I'm off track, but wouldn't the
following simple fix work:

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

Just tell all the scripts (regarless of where they are) that the style
sheet is to be sourced relative to the http document root.

Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect in
both cases.

Nope, doesn't work.
It works if /styles is in the root directory of your website.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #24

P: n/a

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Pq******************************@comcast.com. ..
Jon Slaughter wrote:
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:yf******************************@comcast.com ...
>>Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast.c om...
Jon Slaughter wrote:
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
>news:D5******************************@comcast .com...
>>Jon Slaughter wrote:
>>>Can I modify code that I have included using
>>>>
>>><?php
>>>include("../Index.php");
>>>?>
>>>>
>>>The Index.php file contains links that need to be modified to work.
>>>Index.php is basically an html file uses a linked css file and when
>>>its included in the new file its referencing a css file in the
>>>wrong spot. I need to add "../" to the css file reference in
>>>Index.php to make it work.
>>>>
>>>Thanks,
>>>Jon
>>Ensure your link is an absolute path relative to your website root.
>>Then where you include index.php doesn't matter.
>>>
>It would actually be a bit more trouble since any time I want to
>upload to the server to test I will have to change the link. Would
>be easier just to have php just add "../" to one spot instead
>manually doing it every time I upload to the server.
And why is that? I never have to change links when I upload to my
servers.
>

Um, because the directory structure differs on my server than my
computer? My server uses public_html to hold html files while my
computer doesn't. I suppose I could go mess with the apache config file
and change it though but it still doesn't solve my problem complete. I
still need to inject html files into containers in the html/php code.

So? Mine differs also - my test system is Windows and most of my hosts
are Unix. And my directory here is much different than the one on the
server. I just set up Apache to handle it. Much easier than trying to
screw around with files like you are.

e.g. when I do

<?php include ('SomeFile.php') ?>

<?php include ($_SERVER['DOCUMENT_ROOT'] . '/SomeFile.php'); ?>

Use the features of the language.

To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

But when I include the main file the styles/main.css is referenced from
the directory of that file... but there is not styles/main.css from in
that directory of that file unless it happens to be the root.

Got any more bright ideas?

Like I said - use

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

And get your test environment straightened out.

Yes. You were right from the beginning. What I first thought you ment by
absolute paths was including the domain name which would just have been a
mess. When I realized that you can use / to refer a path from the root dir
and tired it did not work. It didn't work not because of that but because I
didn't change all the links to be absolute but only some... but I didn't
realize it. So I thought it must have been something else.

The good thing is, is now its working and now I know so next time I
shouldn't have this problem ;)

Thanks,
Jon
Apr 19 '07 #25

P: n/a
On Apr 19, 6:18 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
Jon Slaughter wrote:
Can I modify code that I have included using
<?php
include("../Index.php");
?>
The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.
Thanks,
Jon

Ensure your link is an absolute path relative to your website root.
Then where you include index.php doesn't matter.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Or, if you really want to do what you've asked to do, then you could,
instead of include-ing it into the script, and if it isn't ALL just
html and has some PHP needed to be parsed, you could fopen it, read
the contents, strreplace strings with whatever you want, then eval the
entire string. Not a good idea, pretty ugly, but there you have it :)

Apr 19 '07 #26

P: n/a
One last thing:
<?php

/* Remove link that brought us to this site to prevent recursion and
highlight that link */
$Link = "Mathematics";
$Dir = '/'.$Link.'/'.$Link.'.php';
$MainFile = str_replace('<a href="'.$Dir.'">'.$Link.'</a>', '<span
style="color:#FFFF00; text-decoration:underline;
font-weight:bold;">'.$Link.'</span>', file_get_contents('../Main.php'));
echo $MainFile;
?>

I'm searching for the link that user clicked on(going to try and take the
link from the url to generalize the code above later) so the user cannot
click on it again and there is some visual feedback to where the user is at
besides the address bar.

You can see what I mean at

http://www.JonSlaughter.com/Index.php

Clicking on mathematics removes the link at mathematics and changes the
style of it.

Is there any reason why I should't do this and just include main.php using
include '../Main.php';?

Hopefully I'll be able to generalize the code enough so that I will not have
to change it for each link but can just call it and it will figure out the
details. I guess ultimately I'll need to use regular expressions which
might slow things down? (Main.php is not a large file though and I never
expect it to grow, say, above 10k)
Thanks,
Jon


Apr 19 '07 #27

P: n/a
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Pq******************************@comcast.com. ..
>Jon Slaughter wrote:
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:yf******************************@comcast.co m...
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast. com...
>Jon Slaughter wrote:
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
>>news:D5******************************@comcas t.com...
>>>Jon Slaughter wrote:
>>>>Can I modify code that I have included using
>>>>>
>>>><?php
>>>>include("../Index.php");
>>>>?>
>>>>>
>>>>The Index.php file contains links that need to be modified to work.
>>>>Index.php is basically an html file uses a linked css file and when
>>>>its included in the new file its referencing a css file in the
>>>>wrong spot. I need to add "../" to the css file reference in
>>>>Index.php to make it work.
>>>>>
>>>>Thanks,
>>>>Jon
>>>Ensure your link is an absolute path relative to your website root.
>>>Then where you include index.php doesn't matter.
>>>>
>>It would actually be a bit more trouble since any time I want to
>>upload to the server to test I will have to change the link. Would
>>be easier just to have php just add "../" to one spot instead
>>manually doing it every time I upload to the server.
>And why is that? I never have to change links when I upload to my
>servers.
>>
Um, because the directory structure differs on my server than my
computer? My server uses public_html to hold html files while my
computer doesn't. I suppose I could go mess with the apache config file
and change it though but it still doesn't solve my problem complete. I
still need to inject html files into containers in the html/php code.
>
So? Mine differs also - my test system is Windows and most of my hosts
are Unix. And my directory here is much different than the one on the
server. I just set up Apache to handle it. Much easier than trying to
screw around with files like you are.

e.g. when I do
>
<?php include ('SomeFile.php') ?>
>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/SomeFile.php'); ?>

Use the features of the language.

To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

But when I include the main file the styles/main.css is referenced from
the directory of that file... but there is not styles/main.css from in
that directory of that file unless it happens to be the root.

Got any more bright ideas?
Like I said - use

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

And get your test environment straightened out.


Yes. You were right from the beginning. What I first thought you ment by
absolute paths was including the domain name which would just have been a
mess. When I realized that you can use / to refer a path from the root dir
and tired it did not work. It didn't work not because of that but because I
didn't change all the links to be absolute but only some... but I didn't
realize it. So I thought it must have been something else.

The good thing is, is now its working and now I know so next time I
shouldn't have this problem ;)

Thanks,
Jon

Great - the only thing better than fixing a problem is learning from it! :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #28

This discussion thread is closed

Replies have been disabled for this discussion.