1

I have been trying to do this for quite a long time. I don't know whether it is possible or not. Searched the internet a lot but no demos or samples were available.

Is it possible to add css dynamically from the admin panel using codeigniter. I have seen this feature in wordpress. I am trying to a shorter version of that. So when the admin changes the values using a form, that values should be stored into db & from there it is fetched & shown in style.css page. Possible?

2 Answers 2

2

yes you can do that but the css which will be fetched from db can be set by inner style sheet or in header etc, like you have fetched propertise from db and now you are into view so your code will be like this Controller:

function index(){
    $data['css_style'] = $this->css_model->get_styles();
    $this->load->view("myview",$data);
}

View:

<?php
    $toShow = "<style>";
    foreach($css_style as $one_property)
    {
        $toShow .= $one_property['name'].":".$one_property['value'].";";
    }
    $toShow .= "</style>";
    echo $toShow;
?>
Sign up to request clarification or add additional context in comments.

Comments

1

This tutorials will help you, how to add php variables (In your case database values) to css file

http://css-tricks.com/css-variables-with-php/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.