bytesource Posted April 9, 2013 Share Posted April 9, 2013 I want to add an array variable to $config to store file paths, but is does not seem to work: $config->minify = array(); $config->minify[] = 'hello'; $config->minify[] = 'world'; echo count($config->minify); // => 0 On the other hand, adding a string works as expected: $config->minify = ''; $config->minify .= 'hello'; $config->minify .= 'world'; echo $config->minify; // => helloworld I am still new to PHP I am probably not seeing the obvious, so I would be glad if someone could point me in the right direction. Best regards, Stefan Link to comment Share on other sites More sharing options...
horst Posted April 9, 2013 Share Posted April 9, 2013 Hi Stefan, $config->imageSizerOptions = array( 'upscaling' => false, 'cropping' => true, 'quality' => 90 ); $config->minify = array( 'hello', 'world', 'some', 'more', 'text', 'end' ); should work.it is equivalent to: $config->minify = array( 0 => 'hello', 1 => 'world', 2 => 'some', 3 => 'more', 4 => 'text', 5 => 'end' ); 1 Link to comment Share on other sites More sharing options...
bytesource Posted April 9, 2013 Author Share Posted April 9, 2013 Hi Horst, Your suggested approach does indeed work: $config->minify = array( 'hello', 'world'); echo count($config->minify); // => 2 However, I would like to start with an empty array and add items dynamically. This does not seem to work with $config. Also, I would like to take a look at the implementation of $config, but couldn't find any automatically created API documentation of all Processwire objects. Cheers, Stefan Link to comment Share on other sites More sharing options...
diogo Posted April 9, 2013 Share Posted April 9, 2013 http://apigen.juzna.cz/doc/ryancramerdesign/ProcessWire/ Link to comment Share on other sites More sharing options...
Soma Posted April 9, 2013 Share Posted April 9, 2013 $config is WireData so you could $config->minify = new WireData(); $config->minify->set("test","hello world"); Or use an php array and set it to the minify config $minify = array(); $minify[] = 'test'; $minify[] = 'world'; $config->minify = $minify; 2 Link to comment Share on other sites More sharing options...
bytesource Posted April 9, 2013 Author Share Posted April 9, 2013 @diogo That is exactly what I was looking for. @Soma $config is WireDate, now it all makes sense. diogo, Somo, thanks a lot for your help! Cheers, Stefan Link to comment Share on other sites More sharing options...
bytesource Posted April 10, 2013 Author Share Posted April 10, 2013 I have one additional question: Is there a way to add a variable to $config that behaves like $config->styles? Example: $config->styles->add('default.js'); $config->styles->add('custom.js'); $config->styles->add('custom.js'); $config->styles->add('custom.js'); foreach($config->styles as $style) echo $style . ' '; // => default.js custom.js // no duplicates returned Cheers, Stefan Link to comment Share on other sites More sharing options...
Soma Posted April 10, 2013 Share Posted April 10, 2013 $config->minify = new FilenameArray(); $config->minify->add("test.js"); $config->minify->add("test2.js"); 5 Link to comment Share on other sites More sharing options...
bytesource Posted April 10, 2013 Author Share Posted April 10, 2013 That works brilliantly: $config->minify = new FilenameArray(); $config->minify->add("test.js"); $config->minify->add("test2.js"); $config->minify->add("test.js"); foreach($config->minify as $min) echo $min . ' '; // => test.js test2.js Thanks a lot! That is exactly what I wanted to achieve. Cheers, Stefan Link to comment Share on other sites More sharing options...
OllieMackJames Posted April 11, 2013 Share Posted April 11, 2013 Hi Stefan, Just a question, it looks like your solution is meant to include the extra files that are used with the minify module, but are currently outside the logical dir path. If so, would you be willing to share the solution? It would be an answer to my post here: http://processwire.com/talk/topic/1537-minify/ thanks! Link to comment Share on other sites More sharing options...
bytesource Posted April 12, 2013 Author Share Posted April 12, 2013 Hi Ollie, I am not using the Processwire minify module, but this solution: https://github.com/mrclay/minify In the HTML the different javascript files need to be output like this to trigger the minification (works also with CSS files): <script type='text/javascript' src='/min/?b=sovonex/site/templates/js&f=jquery-1.9.1.min.js,tabs-accordion/index.js,tabs-accordion/jquery.ba-resize.js,tabs-accordion/tabs-accordion.js,jquery.placeholder.min.js,include.js'></script> Cheers, Stefan 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now