Dynamic css file Server Error (Wordpress) - css

my theme uses a dynamic css file 'custom-style.php' which is included through wp_enqueue_style();
This file includes some styles depending on the theme options (colors,fonts,...)
On some installation there is no access to this file. Trying to access the file via the source code gets a "500 Internal Server Error". Changing file permissions to 777 does not solve it.
How can I solve this? Is there any other possibility to create dynamic css files?
Alternatively I could write a function to include this css in the head of the html but this is not the way I want go. There are some lines of css and I don't like css in html output.

This problem is from the server and is related to the server configuration. You can put your css code in variable and use the file_put_contents function to put your css code into the style.css file.
Like the code below
<?php
$customColor = #fff;
$css_code = "body{ background:{$customColor}; }";
file_put_contents('style.css',''); //First we empty the file
file_put_contents('style.css',$css_code);//Transfer Css code to file
I used this method and it was a good solution

Related

Access public folder of Laravel in CSS file

Newbie question as stated above. How do I access the public folder of laravel in .css file? I have a custom css and I want to get the url of the image.
You can not use the asset() or public_path() functions there, they will not get called from a css file but you can use the traditional way to access file like this
../css/want_to_import.css
This is the only way you can access a file in a css file, unless you're writting your css dynamically then possibilities are different.
If your domain points to your public folder, you can reference it using /
Let's imagine you want to display a JPG file as a background image.
public/image/background.jpg
In your CSS, you can use background-image:url('/images/background.jpg')

External Css is not working with my HTML code, what is my error?

This is my HTML code which is not working in working with the css file located in other folder name css
this is my css code.
kindly help me and suggest me the correct changes.
Thank you
How are your folders structured?
In the header of you HTML file you state that the css file is called 'home.css' and is located in a folder called 'css'. And this folder should be in the same directory as your html file.
See if you can view your CSS file in your browser at the address you are specifying in your HTML. In other words, go to www.yourwebsite.com/css/home.css. If your CSS file does not show up, it is not at that address and you will need to determine where the file is actually located.
If you can view your CSS file at the address you have specified, but its style directives are not reflected on your pages, check to be sure they are not being overridden somewhere later in your CSS file.
As others have noted, your question is poorly formatted. Providing more information (i.e. URL, fiddle, directory structure, etc.) will likely get you more useful answers faster.

EJS Tags in external css

I'm trying to refactor a nodeJs project and my css is in my .ejs file. I need to put some dynamic data in my css file. I need to have dynamic data in my css, when my css is in my EJS file it's good.
But when I put my css into an external file, nothing happens!
So, how can I inject ejs tag in my external stylesheet file?
This is one of the questions to which one has to ask you - why do you want to do that? You are asking about a solution to a problem that you didn't describe.
By suspicion is that you are trying to use a templating system for something that could be done with a CSS preprocessor like Sass or Less. Particularly Less can be easily used on both the client side and server side. See http://lesscss.org/#client-side-usage
Now, if you really want to use a templating system created for HTML to generate CSS then you will have to take few things into account: You need to store your CSS templates somewhere where your HTML templates are stored, not where you store your static assets like images. Then, your server will have to serve your generated CSS with a correct MIME type. Then, your HTML will have to reference the styles using a URL to your generated CSS that will be generated on every request instead of being served directly from disk.

CSS stripped off when Liferay automatically appends themeId to URL

Liferay automatically appends the themeId (along with other information such as browser) to the URL when including my portlet's css files. When this happens, I find that not all my css styles are loaded. I try to access the css file directly, using /test-portlet/css/main.css?themeId=classic, and only some of the styles are loaded. When I use /test-portlet/css/main.css without the themeId appended, all the styles are loaded fine.
I have been unsuccessful in finding out why. Can anyone help me with this? I am using Liferay 6.1.1 (6.1 GA2).
Angeline can you tell me where you are including your /test-portlet/css/main.css ?
This main.css file has your custom css specific to your portlet. So to load your css when the portlet is accessed on Page. You need to either include in jsp or the recommended way that is to include below line in your test-portlet liferay-portlet.xml
<header-portlet-css>/css/main.css</header-portlet-css>
This will load your css changes.
Hope this helps !
I had the same issue. Try to rename your css (do not use main.css) and it should work.

using import url will it protect my css code

I've been target for someone used to copy my website style sheet so this time i would like to protect my css file using the following :-
i will create fake.css and inside it will put the following code based on #import url
#import url("css/real.css");
Now if he view source will only see the above line and will try to call
www.my_site.com/css/real.css
but i will indeed using my hosting panel will not allow direct access to files .css
Now my question, Is it save enough or still he can get the code by using firebug or whatever !? ~ thanks
There is no way to hide CSS from your users.

Resources