Hey everyone!
I don't know if there is anyplace currently used as a mini snippet repository. The package manger is awesome, it really makes MODx a joy to use. I am talking about "mini" snippets. Little one-off ones that you make to do something, if you made one for a site there is a small chance that someone might need to make the same thing. Or maybe someone can improve upon the code and share it with everyone else.
I was thinking of something like
http://snipplr.com and using a MODx tag. Or something like
http://jsfiddle.net with working examples.
For example I made this one today. It displays the download link for device you are using. It is too specific and simple for package manager. I see many of snippets like this getting lost in the forums. Suggestions? Comments?
<?php
//$iOS_chunk = $modx->getOption('ios',$scriptProperties);
//$Android_chunk = $modx->getOption('droid',$scriptProperties);
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
//check if user is using ipod, iphone or ipad...
if( $iPod || $iPhone || $iPad ){
$output = $modx->getChunk($scriptProperties['ios']);
}else if($Android){
$output = $modx->getChunk($scriptProperties['droid']);
}
return $output;