FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » including CSS & JS on only pages that need that CSS & JS
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: including CSS & JS on only pages that need that CSS & JS [message #175586 is a reply to message #175585] Mon, 10 October 2011 12:27 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 10/10/2011 5:22 AM, paris2venice wrote:
> On Oct 9, 5:34 am, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 10/9/2011 2:51 AM, paris2venice wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> I'm still a newbie at PHP. What would be the right way to include CSS
>>> and Javascript such that I could add CSS and JS just for those pages
>>> that need it?
>>
>>> Would it be something like this? Is this how you do it?
>>
>>> <?
>>> php require_once './css.php'; /* css.php contains
>>> doctype, meta& css needed universally */
>>> ?>
>>
>>> <!-- link href= calls to CSS needed on local page only -->
>>
>>> <?
>>> php require_once './js.php'; /* js.php contains
>>> javascript calls needed universally */
>>> ?>
>>
>>> <!-- script type="text/javascript" calls to Javascript needed on
>>> local page only -->
>>> </head>
>>
>>> Thanks a bunch for your help.
>>
>> I'm not sure what you're trying to do here, but these aren't PHP
>> questions. You're only using PHP to include the files.
>>
>> You're asking basic layout file layout questions, which vary widely.
>> The includes can be done in many ways.
>>
>> The first thing you need to do is learn about various ways to structure
>> your files. For instance, don't mix your DOCTYPE and other header
>> information with CSS.
>>
>> I would suggest you start with a book on basic programming for the web,
>> including html, css, etc.
>
> Thanks for your reply.
>
> I don't understand how you believe that I'm mixing my DOCTYPE and
> other header info with CSS. What the server sends to the client
> should be all that matters and that all arrives perfectly and has
> never been a problem -- validator.w3.org doesn't have an issue with
> it. I don't mind that you tell me there's some problem but how can I
> know why there is a problem if it's not spelled out? That doesn't
> mean I don't appreciate your help. I do.
>

You said:

---
<?
php require_once './css.php'; /* css.php contains
doctype, meta & css needed universally */
?>
---

You are mixing your DOCTYPE and other header information with CSS. Not
a good idea.

As for validating - you could have your entire PHP file be include()
calls, each one including a different file containing one line of PHP or
HTML code. The final product will validate. But that doesn't mean it's
a good idea.

> My problem is just not being able to have something unique to a page
> as I do it now. Thus, my post. If I posted this on an HTML or CSS or
> JS newsgroup, they would go bananas, I guarantee it. I've read a huge
> amount on php.net/manual -- it doesn't really answer questions like
> this as best I can tell. And I'm not really a beginner -- just
> nothing compared to what you guys know about PHP.
>
>

This has nothing to do with PHP. Your problem is a lack of
understanding on how to correctly structure your pages. You could have
exactly the same problems if you were using Perl, Python, Ruby on Rails
or even SSI.

That's why I'm suggesting you start with HTML, CSS and Javascript
newsgroups. You need to learn how to properly structure your pages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: .htaccess vs PHP header(location:)
Next Topic: How to redirect user based on user country?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 14:16:14 GMT 2024

Total time taken to generate the page: 0.04222 seconds