Well, I happen to figure it out. Luckly I have some PHP skills ;-)
I added on MaxiGallerySolo some stuff that somebody may need. They are:
Type
DIRECT - Call the picture by its ID;
OLDEST - Call the oldest picture;
POS - Call the picture by it’s position (which you can configure always).
New variables
ORDER_POS - ASCending or DESCending for POS type?
PID - What’s the picture’s ID?
Now the code and my notes on changes. It wasn’t really that hard.
MaxiGallerySolo edit
<?php
//<?//////////////////////////////////////////////////////////////////////////////////////////
// MaxiGallerySolo by XriS (modified by doze) v.1.1.1 (to be used with maxigallery v0.5 betas)
// -------------------------------------------------------------------------------------------
//
// This snippet gets the latest or random pictures from selected galleries
//
// Call like [!MaxiGallerySolo? &galIDs=`23,51,61` &pics_to_show=`5` &type=`random` &open=`gallery_browser`!]
//
// Parameters:
// &galIDs = Comma delimitted IDs of the documents that has [MaxiGallery] calls
// &pics_to_show = [ number ] : How many pics to show. Default: 1
// &type = [ "random" | "latest" | "direct" | "oldest" | "pos" ] : Show random pics or latest pics? Default: "latest" --ADDED "direct", to show the image by its id, "oldest", to show the first inserted images on that gallery and "pos" to order it by it's position
// &open = [ "lightbox" | "gallery_browser" | "gallery_overview" ] : When clicking the link, should it open in lightbox,
// gallery browser or should it open the gallery overview where that picture is. Default: "lightbox"
// &language = [ "en" | "fr" | etc.. ] : Lightboxv2 language (you have to have the language files in maxigallery ligthboxv2 folder. Defaul: "en"
// $pid = Picture ID for the "direct" type
// $order_pos = [ "ASC" | "DESC" ] : ASC for Ascending and DESC for DESCENDING in the "pos" type
if(!function_exists(MGSoloRegClientScripts)) {
function MGSoloRegClientScripts($language){
global $modx;
//lightbox scripts
$lightboxv2_css_link = '<link rel="stylesheet" href="' . $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/css/lightbox.css" type="text/css" media="screen" />';
$lightboxv2_script_link1 = $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/js/lightbox_setup.js';
$lightboxv2_settings = 'assets/snippets/maxigallery/lightboxv2/js/lightbox_lang_'.$language.'.js';
if(file_exists($modx->config['base_path'].$lightboxv2_settings)){
$lightboxv2_script_link2 = $modx->config['base_url'] . $lightboxv2_settings;
}else{
$lightboxv2_script_link2 = $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/js/lightbox_lang_en.js';
}
$lightboxv2_script_link3 = $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/js/prototype.js';
$lightboxv2_script_link4 = $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/js/scriptaculous.js?load=effects';
$lightboxv2_script_link5 = $modx->config['base_url'] . 'assets/snippets/maxigallery/lightboxv2/js/lightbox.js';
$modx->regClientCSS($lightboxv2_css_link);
$modx->regClientStartupScript($lightboxv2_script_link1);
$modx->regClientStartupScript($lightboxv2_script_link2);
$modx->regClientStartupScript($lightboxv2_script_link3);
$modx->regClientStartupScript($lightboxv2_script_link4);
$modx->regClientStartupScript($lightboxv2_script_link5);
}
}
$returnstring="";
if(isset($galIDs)){
$pics_to_show = isset($pics_to_show) ? $pics_to_show - 1 : 0;
$type = isset($type) ? $type : "latest";
/*** Start ADDED by bsides ***/
$pid = isset($pid) ? $pid : "1";
$order_pos = isset($order_pos) ? $order_pos : "DESC";
/*** End ADDED by bsides ***/
$open = isset($open) ? $open : "lightbox";
$language = isset($language) ? $language : "en";
$galIDs = str_replace(",", "','", $galIDs);
$pics=$modx->getIntTableRows("*","maxigallery", "gal_id IN ('" . $galIDs . "')","pos,date","DESC");
$i=0;
/*** Start ADDED by bsides ***/
if($type == "direct"){
$pics=$modx->getIntTableRows("*","maxigallery", "gal_id IN ('" . $galIDs . "')","id=$pid","$order_pos");
}
if($type == "oldest"){
$pics=$modx->getIntTableRows("*","maxigallery", "gal_id IN ('" . $galIDs . "')","date","ASC");
}
if($type == "pos"){
$pics=$modx->getIntTableRows("*","maxigallery", "gal_id IN ('" . $galIDs . "')","pos","$order_pos");
}
/*** End ADDED by bsides ***/
if($type == "random"){
shuffle($pics);
}
if($open=="lightbox"){
$forcount = count($pics);
}else{
$forcount = $pics_to_show+1;
}
for($i = 0; $i < $forcount; $i++) {
$pic = $pics[$i];
$path_to_gal = "assets/galleries/".$pic['gal_id']."/";
$file = $modx->config['site_url'] . $path_to_gal . $pic['filename'];
$tn_file = $modx->config['site_url'] . $path_to_gal . "tn_" . $pic['filename'];
if($open=="lightbox"){
$returnstring .= "<a href=\"$file\" rel=\"lightbox[maxigallery]\" title=\"<b>".htmlentities(stripslashes($pic['title']))."</b><br />".htmlentities(stripslashes($pic['descr']))."\">";
}else if($open=="gallery_browser"){
$returnstring .= "<a href=\"".$modx->makeUrl($pic['gal_id'], '', "&pic=".$pic['id'])."\">";
}else{
$returnstring .= "<a href=\"".$modx->makeUrl($pic['gal_id'], '', '')."\">";
}
$returnstring .= ($i > $pics_to_show ? "" : "<img src=\"$tn_file\" class=\"thumbnail\">" ) . "</a>";
}
if($open=="lightbox"){
MGSoloRegClientScripts($language);
}
}
return $returnstring;
?>
OBS - I know it should be rewritten so the SQL queries should be more efficient (like putting a ORDER_BY call and clean LATEST variable) but I’m late to get my bus so I’m gonna see it at home.