SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2006
    Location
    Sydney, Australia
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question HTML dynamic stylesheet link - is this possible?

    Am having a major head explosion with this one.

    Current line

    Code:
    <link href="<?php echo($globalvar['default_style']) ?>.css/main.css" rel="stylesheet" type="text/css">
    the href should be showing something like "./themes/standard/css/main.css" which it appears to do when I interrogate the php variable, however the css is not being applied ... not sure what I am missing and quite possibly need a debug tool of some kind.

    Can you have dynamic links to style sheets in the head section of an html page?
    www.scaryminds.com ScaryMinds - horror's last colonial outpost.

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2005
    Posts
    1,833
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Salient View Post
    Am having a major head explosion with this one.
    Let me grab my umbrella.

    Quote Originally Posted by Salient View Post
    Code:
    <link href="<?php echo($globalvar['default_style']) ?>.css/main.css" rel="stylesheet" type="text/css">
    Can you have dynamic links to style sheets in the head section of an html page?
    Yes. I don't know why you have parenthesis around your variable you are echoing out as echo is not a function, but a language construct. And PHP statements should end with a semi-colon and you have another syntax error.

    PHP Code:
    <link href="<?php echo $globalvar['default_style'] . 'css/main.css';?>" rel="stylesheet" type="text/css">
    Or

    PHP Code:
    <link href="<?php echo $globalvar['default_style'];?>css/main.css" rel="stylesheet" type="text/css">
    Give that a try or something similar. I did not test. Look at the output. Ensure you have a proper slash before css/main.css. All you have is a simple syntax error. Should be easy for you to solve.

  3. #3
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,835
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Try a fixed path instead of a relative path, the latter has always caused me problems.


    Code:
    <?php 
     $globalvar['default_style'] = 'http://yoursite.com/themes/standard/css/main.css';
    ?> 
    <link href="<?php echo $style;?>.css/main.css" rel="stylesheet" type="text/css">
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Patche on earning Member of the Month for July 2014

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2006
    Location
    Sydney, Australia
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    D'uh, thanks for pointing out the error ... am currently banging my head against my desk!
    www.scaryminds.com ScaryMinds - horror's last colonial outpost.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •