dynamic css using php problem

14 replies
Hi
I'm trying to help a friend that has a problem with a wordpress based website.
The site is on a shared hostgator linux server and he has just bought a wordpress theme/framework that has a built in "point and click" content/layout/stylesheet builder.
The problem is the theme has the main stylesheet with a php extension and the hostgator server is not parsing it.
Going back and forth between the theme developer and hostgator has sent me round in circles. Theme developer first said "The problem is because of your hosting. Please contact with your hosting provider because as far as we see your hosting can`t work with css files.

It shouldn`t work like that. It looks like your server can`t parse php files as css and that`s why you should contact with your hosting. All normal hostings should work with that because it`s standard nowdays."
So developer says that hostgator need to allow "CSS files to work as .php extension" and they don't know what settings need changing as they are not hosts.

Hostgator say they can make changes if developer tells them what to change!

The developer set the theme up like this to have dynamic css in the wordpress admin. Searching "dynamic css in php" on search engines brings up many site with the suggestion of adding the following to the htaccess file:
<Files style.php>
AddType text/css .php
</Files>
This did output the css but also output the php code as text also so didn't work.

Several other suggestions included adding apache handlers to the htaccess file such as:
AddType application/x-httpd-php .css
AddHandler application/x-httpd-php .css
But neither of these worked either.

Please, can anyone assist in making some sense of what the problem could be?

Thanks
Tony
#css #css apache #dynamic #dynamic css #php #problem
  • Profile picture of the author wayfarer
    Forget about .htaccess, just add the text/css header right from your php:

    <?php header('Content-type: text/css');?>
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[8011629].message }}
    • Profile picture of the author asnorth
      Thanks for the suggestion wayfarer, the themes style.php file already has that code in it though.

      Tony
      Signature

      Connect with me on Google+

      {{ DiscussionBoard.errors[8012349].message }}
  • Profile picture of the author ttkim
    What theme are you using?
    {{ DiscussionBoard.errors[8012369].message }}
  • Profile picture of the author wayfarer
    Is your hosting service using a reverse proxy (ie load balancer)? If so, it could be that they are denying access to requests for text/css file on non- .css extensions via the proxy layer. This is really weird, but if this is what they are doing, you should consider switching hosts or using a service of their's that doesn't do this, since nothing you configure in .htaccess will ever affect the load balancer layer.

    As the developer pointed out, it's time to talk to your host, to see if it can be resolved. If not, dump them, because as pointed out, using a dynamically generated CSS sheet like this is totally standard stuff these days.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[8012409].message }}
  • Profile picture of the author mojojuju
    Originally Posted by asnorth View Post

    Hi

    The problem is the theme has the main stylesheet with a php extension and the hostgator server is not parsing it.
    If the stylesheet ends with .php and your server is correctly processing other files that end with .php, then I'm sure that your server is correctly processing the stylesheet as a php file. This is assuming that your browser is actually making a request to the stylesheet ending with .php.

    Have you checked to see that the stylesheet ending with .php is referenced correctly by its parent page? Can you try accessing the stylesheet ending with the .php extension directly by pasting the path to it in your browser?

    If there's no problem using files that end with .php for other pages, there should be no reason for a problem with accessing and processing stylesheets with a .php extension.
    Signature

    :)

    {{ DiscussionBoard.errors[8012532].message }}
  • Profile picture of the author asnorth
    Thanks for the response so far.
    Wayfarer, The host is hostgator using one of their shared servers accounts. I will have to ask their support about load balancing as I do not know about that.
    I've spoken to their support about this and they say they can make changes on the server if the developer tells them what they need changing and the theme developers say they are not hosts and don't know what would need changing on the server!

    ttkim, the theme is bretheon found here WordPress - Bretheon Premium WordPress Theme | ThemeForest it has over 1200 sales with 5 star rating.

    mojojujo, all other php files process fine but the style sheet doesn't http://www.marketme.co.uk/wp-content...heon/style.php
    compared to the theme developers version http://themes.muffingroup.com/brethe...heon/style.php

    tony
    Signature

    Connect with me on Google+

    {{ DiscussionBoard.errors[8012597].message }}
    • Profile picture of the author mojojuju
      Originally Posted by asnorth View Post


      mojojujo, all other php files process fine but the style sheet doesn't http://www.marketme.co.uk/wp-content...heon/style.php
      Why don't you click on that link and take a look at the error message. It looks like it's being processed as a php file by the server just fine. It's just that you need to resolve that error.

      Remove the declaration of the mentioned function in that file, or put in a condition so that it's not declared if it already exists.

      PHP is processing this file exactly as it's supposed to.
      Signature

      :)

      {{ DiscussionBoard.errors[8012677].message }}
      • Profile picture of the author asnorth
        Originally Posted by mojojuju View Post

        Why don't you click on that link and take a look at the error message. It looks like it's being processed as a php file by the server just fine. It's just that you need to resolve that error.

        Remove the declaration of the mentioned function in that file, or put in a condition so that it's not declared if it already exists.

        PHP is processing this file exactly as it's supposed to.
        Thanks, I'm not a php programmer just have a bit more knowledge than my friend whos site I'm helping with. I'll speak to the developer and see if they can help out with that.

        Originally Posted by David V View Post

        Are you quite positive there have been no changes/additions to the theme core files?
        I've seen dozens of clients that use hostgator with dynamic css without issue.
        I'm pretty sure a fair number of the customers who bought that theme are using hostgator, it's a very popular shared hosting service.
        I'd have to agree with Mojojuju.
        The redeclare error is odd considering you think it might be the hosting.
        If this is a new site, I would do a clean reinstall and make sure no plugins are active.
        Definitely no changes to any of the theme files. What I did was upload the same theme files to a different website on the same hostgator server with the same outcome. I also tried with no plugins etc active. I then uploaded the theme to a wordpress site on a different host and the css was all fine on that site.
        I totally agree that with over 1200 sales it is more than likely that there are other users of the theme on hostgator with no problem. Thats why the theme developer suggested that it was a problem with the specific server that the site is on but hostgator didn't have a clue what the problem could be.

        This site that has the problem has their email setup to route through a third party company and the cost to move to another server and setup the email again will be over £200 so not really an option just to use a $50 theme.
        Signature

        Connect with me on Google+

        {{ DiscussionBoard.errors[8014941].message }}
  • Profile picture of the author David V
    Are you quite positive there have been no changes/additions to the theme core files?
    I've seen dozens of clients that use hostgator with dynamic css without issue.
    I'm pretty sure a fair number of the customers who bought that theme are using hostgator, it's a very popular shared hosting service.
    I'd have to agree with Mojojuju.
    The redeclare error is odd considering you think it might be the hosting.
    If this is a new site, I would do a clean reinstall and make sure no plugins are active.
    {{ DiscussionBoard.errors[8012719].message }}
  • Profile picture of the author wayfarer
    I can see now that the problem is definitely not the server, but a programming error. Maybe you got a bad release of the plugin, because a function should definitely only be defined once in PHP.

    You should show the developer this link: http://www.marketme.co.uk/wp-content...heon/style.php

    If you want to try to fix it yourself, just search in that file for something starting...

    function mfn_sortable(
    then remove that function, which would be the function name and everything between the curly brackets
    function mfn_sortable( ... ) {
    ...
    }
    Anything with ... is unknown by me.

    Now, it could be that something is getting included twice, so if you don't find a function definition in that file, it could be more complicated, and you'll need a developers help.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[8016278].message }}
    • Profile picture of the author asnorth
      Originally Posted by wayfarer View Post

      I can see now that the problem is definitely not the server, but a programming error. Maybe you got a bad release of the plugin, because a function should definitely only be defined once in PHP.

      You should show the developer this link: http://www.marketme.co.uk/wp-content...heon/style.php

      If you want to try to fix it yourself, just search in that file for something starting...


      then remove that function, which would be the function name and everything between the curly brackets

      Anything with ... is unknown by me.

      Now, it could be that something is getting included twice, so if you don't find a function definition in that file, it could be more complicated, and you'll need a developers help.
      Thanks, I tried that on the test site i'm using on the hostgator server and it cleared the error message but still didn't display the css as the theme developers test file does, also the css still didn't work on the actual site.
      It's frustrating as the exact same files work fine on a different host but two installations on hostgator both fail
      Signature

      Connect with me on Google+

      {{ DiscussionBoard.errors[8016641].message }}
  • Profile picture of the author wayfarer
    Maybe there's some sort of plugin conflict. I would try disabling plugins one at a time to see if it starts working. I know this seems like a generic solution, but not sure what else to do with the information I have.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[8016724].message }}
    • Profile picture of the author asnorth
      Originally Posted by wayfarer View Post

      Maybe there's some sort of plugin conflict. I would try disabling plugins one at a time to see if it starts working. I know this seems like a generic solution, but not sure what else to do with the information I have.
      I don't believe it! I thought I had previously deactivated all plugins, however one that I didn't deactivate because I thought it had come with the theme and couldn't be the problem was causing a conflict.
      Thanks everyone so much for the help.
      Signature

      Connect with me on Google+

      {{ DiscussionBoard.errors[8018112].message }}
  • Profile picture of the author wayfarer
    Awesome, glad we could help figure it out
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[8019395].message }}

Trending Topics