Show only the 4 newest albums on Frontpage of a site Show only the 4 newest albums on Frontpage of a site
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Show only the 4 newest albums on Frontpage of a site

Started by MasterMilos, February 06, 2007, 05:20:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MasterMilos

Hi there,

I have got a thing here, I wanted to show only the 4 newest - uploaded Albums on my frontpage: So I used this code, but it doesn´s work. I can still see the 4 empty boxes but no pictures. Maybe someone of you has an idea how to solve this thing whith coppermmine "cpg_1.4.10_joomla_int" everything works fine - but, how I sad, no pictures on the frontpage.

I got this code from an friend, he ralized it for Nuke but I rally don´t know how to rewrite it, that it works whith joomla...  ???

Here is the code I put in a php-box on my frontpage: (I think the mistake is in the bold lines below.)


<?php

function vieralben()
{
global $db;
$i=0;


echo"<div id='vieralben' class='vieralben'><center>";

$sql="SELECT aid,title,description,thumb FROM jos_cpg_albums WHERE thumb!='0' ORDER by aid DESC LIMIT 4 ";
$result = $db->sql_query($sql);

while(list($album_id,$title,$description,$thumb)=$db->sql_fetchrow($result)) {

$alben_id[$i] = $album_id;
$descriptions[$i] = $description;
$titles[$i] = $title;
$thumbs[$i] = $thumb;
$i++;
}
$ident=" ";
$descriptions[0] = preg_replace("/<br.*?>[\r\n]*/i", '<br />' . $ident , bb_decode($descriptions[0]));
$descriptions[1] = preg_replace("/<br.*?>[\r\n]*/i", '<br />' . $ident , bb_decode($descriptions[1]));
$descriptions[2] = preg_replace("/<br.*?>[\r\n]*/i", '<br />' . $ident , bb_decode($descriptions[2]));
$descriptions[3] = preg_replace("/<br.*?>[\r\n]*/i", '<br />' . $ident , bb_decode($descriptions[3]));
//Erstes Album - Start
$sql_bild1="SELECT filepath,filename FROM jos_cpg_pictures WHERE aid='$alben_id[0]' AND pwidth > pheight order by rand() LIMIT 1";
$result_bild1 = $db->sql_query($sql_bild1);
list($filepath_bild1,$filename_bild1)=$db->sql_fetchrow($result_bild1);
//Erstes Album - Ende

//Zweites Album - Start
$sql_bild2="SELECT filepath,filename FROM jos_cpg_pictures WHERE aid='$alben_id[1]' AND pwidth > pheight order by rand() LIMIT 1";
$result_bild2 = $db->sql_query($sql_bild2);
list($filepath_bild2,$filename_bild2)=$db->sql_fetchrow($result_bild2);
//Zweites Album - Ende

//Drittes Album - Start
$sql_bild3="SELECT filepath,filename FROM jos_cpg_pictures WHERE aid='$alben_id[2]' AND pwidth > pheight order by rand() LIMIT 1";
$result_bild3 = $db->sql_query($sql_bild3);
list($filepath_bild3,$filename_bild3)=$db->sql_fetchrow($result_bild3);
//Drittes Album - Ende

//Viertes Album - Start
$sql_bild4="SELECT filepath,filename FROM jos_cpg_pictures WHERE aid='$alben_id[3]' AND pwidth > pheight order by rand() LIMIT 1";
$result_bild4 = $db->sql_query($sql_bild4);
list($filepath_bild4,$filename_bild4)=$db->sql_fetchrow($result_bild4);
//Viertes Album - Ende

$bild_1 = $filepath_bild1."thumb_".$filename_bild1;
$bild_2 = $filepath_bild2."thumb_".$filename_bild2;
$bild_3 = $filepath_bild3."thumb_".$filename_bild3;
$bild_4 = $filepath_bild4."thumb_".$filename_bild4;
}
echo"<div id='partypeople_beschriftung' style='width:150px; font-weight:bold; background-color:#FFFFFF;'>Neueste Partybilder</div>";
?>
<script type="text/javascript">
Rico.Corner.round('partypeople_beschriftung',{corners:"bottom"});
</script>
<?

echo"<div style='float:left; margin-left:2px; margin-right:6px; margin-top:4px; margin-bottom:4px; padding:5px; width:138px; background-color:#ffffff; border:1px solid; border-color:#BCBCBC;'>";
echo"<a href='modules.php?name=coppermine&file=thumbnails&album=$alben_id[0]'><img
border='0' src='/cpg/phpThumb.php?src=$bild_1&w=138&q=85&fltr[]=gam|0.9' alt='$titles[0]' width='138' height='103'/></a>";
echo"<div style='width:138px;'>$descriptions[0]</div></div>";

echo"<div style='float:left; margin-top:4px; margin-bottom:4px; padding:5px; width:138px; background-color:#ffffff; border:1px solid; border-color:#BCBCBC;'>";
echo"<a href='modules.php?name=coppermine&file=thumbnails&album=$alben_id[1]'><img
border='0' src='/cpg/phpThumb.php?src=$bild_2&w=138&q=85&fltr[]=gam|0.9' alt='$titles[1]' width='138' height='103'/></a>";
echo"<div style='width:138px;'>$descriptions[1]</div></div>";

echo"<div style='float:left; margin-left:2px; margin-right:6px; margin-top:4px; margin-bottom:4px; padding:5px; width:138px; background-color:#ffffff; border:1px solid; border-color:#BCBCBC;'>";
echo"<a href='modules.php?name=coppermine&file=thumbnails&album=$alben_id[2]'><img
border='0' src='/cpg/phpThumb.php?src=$bild_3&w=138&q=85&fltr[]=gam|0.9' alt='$titles[2]' width='138' height='103'/></a>";
echo"<div style='width:138px;'>$descriptions[2]</div></div>";

echo"<div style='float:left; margin-top:4px; margin-bottom:2px; padding:5px; width:138px; background-color:#ffffff; border:1px solid; border-color:#BCBCBC;'>";
echo"<a href='modules.php?name=coppermine&file=thumbnails&album=$alben_id[3]'><img
border='0' src='/cpg/phpThumb.php?src=$bild_4&w=138&q=85&fltr[]=gam|0.9' alt='$titles[3]' width='138' height='103'/></a>";
echo"<div style='width:138px;'>$descriptions[3]</div></div>";

}?>


THX for help together to solve this small problem.

Greetings to @ll coppermine users  ;)


MasterMilos

Thanks 4 the answer, but I think my question is a little bit stupid, I didn´t wrote it clear enougth.  :P

I know the internal funktions very well. THX.

OK maybe the Attach-Picture is clear enought to explain my problem.

Number 1: On an separeate Page (Nr. 1) should only appear the newest 4 albums with desription and random of pictures in this albums on page refresh. If you click on one of these random showed newest pictures of the ... 4 newest albums... you will be redirected to the main page of this album where you have clicked on. (Nr. 2)

My posted code works very fine with Nuke, but not with joomla, because in Nuke the cpg is an module and not a separate insallation. The mistake is in the bold lines and below, I don´t know how to rewrite the path to the pictures and the albums which are shown on the frontpage (Nr. 1).


Joachim Müller

Quote from: MasterMilos on February 07, 2007, 09:37:45 AM
My posted code works very fine with Nuke, but not with joomla, because in Nuke the cpg is an module and not a separate insallation.
We don't know nor support nuke. You can't expect us to look into proprietary custom code.