Hi there,
I’ve written a little snippet that retrieves the top positioned image from MaxI-Gallery’s MySQL table and puts it at the top of a ditto summarised item. Now, being well pleased by being able to resolve what I needed to get working on a plain php page, which doesn’t have any [+id+] implemented into it, I then went on to integrate it into ModX 0.95 and ditto 2.02.
Now I can get the php script to echo the [+id+] but I’m entirely unable to get it to run through the MySQL query!
I replace the [+id+] with "59" or 59 and it works fine!
It is as if I’m not able to interrogate the MySQL DB using Ditto’s placeholders or it’s an actual declaration problem that I’m missing!
<?php
// --------------------------------------------------------------------
// Create a top image dynamically from a typical config for maxigallery
// version 0.1 - 10th April 2007
// created by TXRX
// For exclusive use with modx 0.95 and Maxigallery 0.5 (final)
// ie: not tested in any way, means or differing environments
// --------------------------------------------------------------------
$sqlusername="sqlusername";
$sqlserver="sqlserver";
$sqlpass="sqlpass";
//$gti_id="59";
//$gti_page_id=$gti_id;
$gti_page_id="[+id+]";
$gti_id=0;
$gti_row=1;
$gti_result="";
$gti_name="";
$gti_loop=0;
$gti_numofarticles=6;
echo "<H2>This is a php script to determine the topmost image and show it on the news pages</h2>";
echo "<BR>PAGEID:".$gti_page_id."<BR>";
$gti_location="http://modxserver/cms_tests/assets/galleries/".$gti_page_id;
$gti_output_tn="";
$gti_output_full="";
//mysql_connect($sqlserver, $sqlusername, $sqlpass) or die(mysql_error());
mysql_select_db("modx") or die(mysql_error());
$gti_result = mysql_query("SELECT * FROM modx_maxigallery where gal_id = '$gti_page_id' order by pos ");
While ($gti_row = mysql_fetch_array($gti_result)and($gti_loop<=$gti_numofarticles)) {;
$gti_pos[$gti_id]=$gti_row['pos'];
$gti_name[$gti_id]=$gti_row['filename'];
$gti_loop++;
}
echo "THIS IS Sort of WORKING ::::".$gti_page_id.":::::";
$gti_output_tn="tn_".$gti_name[0];
$gti_output_full=$gti_name[0];
echo "<BR>Image location : ".$gti_location."/";
echo "<BR>Top image thumbnail : ".$gti_output_tn;
echo "<BR>Top image large : ".$gti_output_full;
?>
What am I doing wrong? I’m fairly new into ModX but I’m stumped at this one for now!
I’ve tried the below topic which worked well but I wanted to then utilise Maxi-Gallery’s ease of use etc since the below method needed you to specify a TopStoryImage via a template variable but it I’m able to streamline the frontend editting options to not having to upload images on more than one occasion I’ll be over the moon!
http://modxcms.com/forums/index.php/topic,13623.0/topicseen.html