Jump to content

Stylesheet Link not working


Alexis
 Share

Recommended Posts

Hi Everybody,

I'm a newbie to PW, but since the few weeks i'm working with it I like it a lot (mainly for it's flexibility).

Ryan and others, you are doing a really impressive job. Congratulations!

For a little CMS i'm working on, I want to use PHP script inside CCS stylesheet.

For that, I put <?php header('Content-type: text/css');?> at the beginning of the mucss.css file which is renamed mycss.php,

and I put the <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>mycss.php" /> in the header of a template file (mycss.php is in the same directory as my templates).

But this code doesn´t work, the mycss.php file is not rendered in the final html page.

After a few testes, I got my objective with this code instead

<link rel="stylesheet" type="text/css" href="/mycss.php" /> and putting the mycss.php file in the root directory of website.

This change of directory is not very suitable for when I want to export my site profile for new installations.

Any idea what is wrong or what can be done for doing the trick maintaining the original structure of PW.

Thanks.

  • Like 1
Link to comment
Share on other sites

Hi Axis, glad you are enjoying PW. You can't access the templates directory by url, since it's protected by the htaccess file. What you can do, is create a css page in the tree with your css.php file as it's template and access that page url instead.

wrote on mobile... can be clumsy

edit: not on mobile anymore, you can see more about my answer here http://processwire.com/talk/topic/2210-help-getting-a-custom-styles-php-file-working/#entry20641

  • Like 1
Link to comment
Share on other sites

01. If you go to templates and then urls, Should page URLs end with a slash? Set the radio button to no.

02. Then go to your page with the CSS template, go to the settings tab and let the name of the page end with .css.

This way you could create pages with names linke: styles.css or default.css

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...