Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #8480

    Hi dear,

    i was wonder how can i disable the dynamic css style that the theme add in the source code.

    The reason is clear: i want to handle any customization by css and i take care of site performance so any inline css are useless.

    I noticed that it’s possible to do that for the google font, sure i don’t want an option like that for the entire preset styles: for me is enough to delete the theme hook :-)

    Thanks in advance for your response.

    Mr_pa

    #61495

    Hey,

    open up propulsionframeworkphpclass-style-generator.php and comment out/delete following code:

    echo "n<!-- custom styles set at your backend-->n";
    echo "<style type='text/css' id='dynamic-styles'>n";
    echo $this->output;
    echo "</style>n";
    echo "n<!-- end custom styles-->nn";
    echo $this->extra_output;

    #61496

    Works like a charm!

    Thanks so much Dude!

    Mr_pa

    #61497

    Glad that I could help you :)

    #61498

    Is this the same process for the Coalition theme?

    #61499

    Hi!

    Yes :)

    Best regards,

    Peter

    #61500

    Hi,

    Is it possible to write dynamic styles in some cache file, so the possibility of dynamic styles stays and code will be clear?!

    Thanks,

    Aleksandr

    #61501

    Probably it’s possible somehow because you could save the output into a variable and then use functions like: http://php.net/manual/en/function.fwrite.php to write the variable content into a file. However I’ve not tested it and it requires some coding/testing on your end.

    #61502

    Hi Dude,

    Thanks for reply!

    I’ve tried to write something to file using fwrite function, but got and error that file isn’t writable (with 777 permission).

    I’m not php expert, but there should be some thing like this:

    1) write to file

    2) update file when dynamic styles updated from admin

    3) read from file

    Can you give me more clues if possible.

    BR,

    Aleksandr

    #61503

    Hey Aleksandr,

    I’ll Tag Peter on this in case he has any other thoughts.

    Regards,

    Devin

    #61504

    Yes, basically it should be possible. Re 1) – make sure that the directory permission is set to 777. Code would look like:

    $my_file = 'my_template.php';
    $handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
    fwrite($handle, $data);

    - it will generate a file called my_template.php.

    2) Read from file should be simply – eg you could use fread or simply include it with include/require_one.

    #61505

    Thanks, it works, if someone interested in cleaning page source, here is solution:

    1) In class-style-generator.php

    Find this:

    function print_styles()

    {

    echo “n<!– custom styles set at your backend–>n”;

    echo “<style type=’text/css’ id=’dynamic-styles’>n”;

    echo $this->output;

    echo “</style>n”;

    echo “n<!– end custom styles–>nn”;

    echo $this->extra_output;

    }

    Replace with this:

    function print_styles()

    {

    $my_file = AVIA_BASE.’css/dstyles.css';

    $handle = fopen($my_file, ‘w’) or die(‘Cannot open file: ‘.$my_file);

    fwrite($handle, $this->output);

    }

    2) Add to header.php:

    <link rel=”stylesheet” href=”<?php echo get_bloginfo(‘template_url’); ?>/css/dstyles.css” type=”text/css” media=”screen”/>

    #61506

    Hi nuforms,

    Thanks for sharing the solution. :)

    Regards,

    Ismael

    #61507

    The cleaning of the source is amazing! I have also bought CHOICES template, i assumed it would work the same but it seems to break the styling. Can an admin confirm how to clean up the source like above but for the excellent template, CHOICES?

    #61508

    Update on CHOICES, found that if you add it under the custom.css in the header, it works, but custom font is not picked up, for a quick solve i have had to make http request by copying the link href from google web fonts fro that font, not the best way, but a quick fix to clean up all that css in the header

    #61509

    Hi dccs52,

    Thanks for helping out. :)

    Regards,

    Ismael

    #61510

    Ok, I implemented solution from @nuforms and it works well.

    My concerns: Is dstyles.css from solution above generated on every page/post request or only when I add some CSS code to ‘Quick CSS’ and click ‘Save all changes’

    If css style is generated on every page/post request, how to generate it only if changes are made at Quick CSS, or simply disable generating CSS file once you are satisfied with customization?

    Thanks in advance!

    #61511

    You just need to comment out the print_styles() function code. Generate the file by using the codenuforms posted above, then replace:

    function print_styles()
    {
    $my_file = AVIA_BASE.'css/dstyles.css';
    $handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
    fwrite($handle, $this->output);
    }

    with:

    function print_styles()
    {
    /*
    $my_file = AVIA_BASE.'css/dstyles.css';
    $handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
    fwrite($handle, $this->output);
    */
    }

    If you need to generate a new file just undo the code change und use the print_styles function to generate the new file.

Viewing 18 posts - 1 through 18 (of 18 total)

The topic ‘How to disable Dynamic CSS Style on front/back-end’ is closed to new replies.