- This topic is empty.
-
AuthorPosts
-
July 5, 2014 at 6:09 am #174709KKHANParticipant
Yes i am saying it is correct from the output, but it is not applying. I have tried clicking page source.
C:/xampp/htdocs/mysite/includes/css/style.css">
i can’t clicked it but it says the address was not understood. I am now thinking it may have something to do with the way the xampp server is setup? As i currently access my files like this.http://localhost:63342/mysite/index.php
July 5, 2014 at 6:12 am #174710KKHANParticipantYes i am saying it is correct from the output, but it is not applying. I have tried clicking page source.
C:/xampp/htdocs/mysite/includes/css/style.css">
i can’t clicked it but the address was not understood. i currently access my files like this.http://localhost/mysite/includes/css/style.css.
July 5, 2014 at 6:36 am #174715chrisburtonParticipantIs this for a client? Certainly not the most efficient way to go about it.
I have to head out but I will say that I think you should start by combining overallHeader and head. What is the purpose of separating those?
The problem seems to be using the global doc_root.
The way you have your setup, it’s probably best to go with
/mysite/includes/
and use../
depending on the level of your directories.July 5, 2014 at 6:46 am #174716KKHANParticipantNope this is not for a client. Its a fake site i have setup with the goal to learn PHP. I have used ../ in the past, however it works for dashboard.php file because it is nested in a folder, but when it comes to index.php which is not in a folder but in the root directory it fails.
July 5, 2014 at 6:53 am #174717chrisburtonParticipantbut when it comes to index.php which is not in a folder but in the root directory it fails – @KKHAN
I understand that. That’s the point I’m trying to make. You have to change
../
to reflect your level of directories. So for example with your index.php file, you would not use a slash nor../
.See this: http://hastebin.com/egaforofuy.vhdl
July 5, 2014 at 7:29 am #174728KKHANParticipantSo do you recommend me removing document_root? I assumed it was always good to use this.
So my index.php will look like this..
<?php include (“includes/overall/overallHeader.php”);?>
where as dashboard.php will look like this…
<?php include (“../includes/overall/overallHeader.php”);?>
regarding your hashbin, do you think its necessary for me to include the style sheet directly as your suggesting in every .php page, even tho im including it in the head.php which get included in the overallHeader.php.
The purpose of me declaring it in the head, was that overallHeader will get used by every .php page so it would save duplication and should work everywhere regardless of nested .php files in folders.
July 5, 2014 at 11:48 am #174749KKHANParticipantAlso i have in an image in my header.php
When im in index.php, the src will be includes/images/myimage.css
where as when im in profile/dashboard.php the src will be ../includes/images/myimage.cssThere must be a way ii can universally include images and style sheet no matter how deep i am in the folder structure if im including the overallHeader in every php file. As i can’t declare ../ and without at the same time.
July 5, 2014 at 4:04 pm #174760chrisburtonParticipantThe purpose of me declaring it in the head, was that overallHeader will get used by every .php page so it would save duplication and should work everywhere regardless of nested .php files in folders. @KKHAN
Yes, sorry. I was completely exhausted – my fault. What you need to do is this:
include('includes/css/style.css');
If this does not work, zip MYSITE folder and upload it somewhere so I can download and take a closer look.
July 6, 2014 at 12:44 am #174778KKHANParticipantThat’s alright.
Where am i adding this piece of code?
Bare in my mind i have the link rel in head.php
Also i don’t wish to make this site public for everyone, is there some way we can do this more private?
July 6, 2014 at 12:49 am #174779chrisburtonParticipantWhere am i adding this piece of code?
head.php
is there some way we can do this more private?
chrisburton.me. You can find my email under my name. Make sure to zip the folder before attaching it to an email.
July 6, 2014 at 1:02 am #174780KKHANParticipantOk i will try this and get back to you. Much appreciation for the help.
Edit
It just outputs the content of the style.css to the header, nothing gets applied though. Rightly so i think.July 6, 2014 at 1:55 am #174782KKHANParticipantSolved.
So there was actually a very simple solution.
Just like with my includes. I added “$_SERVER[‘DOCUMENT_ROOT’]” to get the absolute path. I needed to do something similar with the href. Though for some reason it didint like $_SERVER[‘DOCUMENT_ROOT’] because it was pointing all the way back to the C: drive. I still needed to use an absolute path.
In the end this worked, entering in a direct absolute path starting from the root with a leading /
<link rel="stylesheet" type="text/css" href="/mysite/includes/css/style.css">
Now, all my .php files which are held in subfolders properly render with the styling in place. This needs to be applied to all scripts/images also.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.