Giter Club home page Giter Club logo

Comments (6)

exside avatar exside commented on May 23, 2024

lol...just doesn't work: Parse error: syntax error, unexpected T_IF in /home/exodch/public_html/bern-derfilm/assets/site/booster/booster_inc.php on line 1798

how do I make an if statement in a for loop?

Edit: ok, I have it...but it looks ugly =)...could this be done better?

    for($j=0;$j<intval($this->css_totalparts);$j++)
    {
        $linkcode .= '<link rel="'.$this->css_rel;
        $linkcode .= '" media="'.$this->css_media;
        if ( $this->css_title != '' ) {     
            $linkcode .= '" title="'.htmlentities($this->css_title,ENT_QUOTES);
        } else {  }
        $linkcode .= '" type="text/css" href="'.$this->base_offset.ltrim($booster_path,'/').'/booster_css.php';
        $linkcode .= ($this->mod_rewrite ? '/' : '?');
        $linkcode .= 'dir='.htmlentities(str_replace('..','%3E',$source),ENT_QUOTES);
        $linkcode .= '&amp;cachedir='.htmlentities(str_replace('..','%3E',$this->booster_cachedir),ENT_QUOTES);
        $linkcode .= ($this->css_hosted_minifier ? '&amp;css_hosted_minifier=1' : '');
        $linkcode .= '&amp;totalparts='.intval($this->css_totalparts);
        $linkcode .= '&amp;part='.($j+1);
        $linkcode .= ($this->debug ? '&amp;debug=1' : '');
        $linkcode .= ($this->librarydebug ? '&amp;librarydebug=1' : '');
        $linkcode .= (!$this->js_minify ? '&amp;js_minify=0' : '');
        $linkcode .= '&amp;nocache='.$this->filestime.'" ';
        $linkcode .= ($this->markuptype == 'XHTML' ? '/' : '').'>'."\r\n";
    }

from css-js-booster.

Schepp avatar Schepp commented on May 23, 2024

Will be in the next release.

from css-js-booster.

Schepp avatar Schepp commented on May 23, 2024

BTW: Why don't you get your code from Booster's public function $booster->css_markup()? It would return all of the above and you had an easier life slapping in updates of the Booster into your MODx-plugin.

from css-js-booster.

Schepp avatar Schepp commented on May 23, 2024

Done

from css-js-booster.

exside avatar exside commented on May 23, 2024

Nice, thanks for the update, just implemented it and it works as expected =) both of the fixes! I knew there was a more elegant way to do what I tried above =P...I'm still a php n00b, just learning stuff every day...could you explain what you did here:

($this->css_title != '' ? ' title="'.htmlentities($this->css_title,ENT_QUOTES).'"' : '').

what is the "?" and where in the phpdocs can I read about this (btw. how is this called)?

thanks anyways, modx snippet working already, just have some trouble with booleans...

from css-js-booster.

Schepp avatar Schepp commented on May 23, 2024

Sure! The construction above is a shorthand-version of the if/else-logic. The complete logic needs to be set into parenthesis (), then first comes the condition to test for. Then comes a ? as a separator, followed by the value for the condition being TRUE. Then again there is a separator, the :, and last you have the value for the condition being FALSE.

You can find some examples here:
http://davidwalsh.name/javascript-shorthand-if-else-examples

I think in some cases (not all), especially when you have lots and lots of if/else-stuff concentrated in one point, or when you need to assign if/else-driven values to variables (see the top of booster_css.php for example), it helps keeping an overview and the code a little more compact and readable.

Tell me when your MODx-plugin is ready! Then I will include a link to it.

from css-js-booster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.