PDA

View Full Version : Problem with "random" link


joana
04-26-2006, 08:10 PM
Hello everybody, first post here. :)

Must say I am very happy with Pixelpost (ver. 1.4.3).

But I am having a little problem:

The <a href='?showimage=<IMAGE_RANDOM>'> that is on my image_template works fine, but it doesn't work on the links_template and the browse_template (it shows a "http://www.joanagarrido.com/photoblog/index.php?showimage= " link).

My photoblog: http://joanagarrido.com/photoblog/

Thank you.

raminia
04-26-2006, 09:50 PM
edit the addon file and exclude the if statement

joana
04-26-2006, 10:54 PM
edit the addon file and exclude the if statement

Which one? I see alot of "if"s, and I don't have a clue about php. :rolleyes:

joana
04-27-2006, 06:15 PM
Seems like a tricky thing...:eek:

raminia
04-27-2006, 11:27 PM
the main if about $_GET

joana
04-28-2006, 01:18 PM
Ther is no $_GET in the code (I assume you are talking about the random_image.php).

Check it out:

*/

$addon_name = "Random Image ";
$addon_description = "This addon will enables the tag &lt;IMAGE_RANDOM&gt;
which is the ID of a random image of your Pixelpost photoblog. Using this ID, you can link to a random image easily.
Usage:<br>
&lt;a href='$PHP_SELF?showimage=&lt;IMAGE_RANDOM&gt;' &gt; Random photo &lt;/a&gt; <br>
The above tag links to your photoblog with a random photo.";

$addon_version = "0.2";

// Get the number of thumbnails shown at once from the admin config
$cfgquery = mysql_query("select * from ".$pixelpost_db_prefix."config");
$cfgrow = mysql_fetch_array($cfgquery);

//---------------------------

$thmb_numb = 1 ;

// Code taken from index.php to get the thumbs ahead and behind
if(function_exists(gd_info)) {
$gd_info = gd_info();
if($gd_info != "") { // check that gd is here before this

if (isset($image_id)){
$thumbs_ahead = mysql_query("select DISTINCT id,headline,image from ".$pixelpost_db_prefix."pixelpost where id!=".$image_id." and datetime<='$cdate' order by rand() asc limit 0,$thmb_numb");
}
else{
$thumbs_ahead = mysql_query("select DISTINCT id,headline,image from ".$pixelpost_db_prefix."pixelpost and datetime<='$cdate' order by rand() asc limit 0,$thmb_numb");
}


if (list($id,$headline,$image) = mysql_fetch_row($thumbs_ahead)) {
$rnd_img_id = $id;

}

$tpl = ereg_replace("<IMAGE_RANDOM>",$rnd_img_id,$tpl);



} // gd_info()
} // func exist



?>

raminia
04-29-2006, 10:32 PM
try

<?php
/*

Requires Pixelpost version 1.3+
Random Image Addon version 0.4
Written by: Ramin Mehran
Contact: raminia@yahoo.com


Pixelpost www: http://www.pixelpunk.se/software/
License: http://www.gnu.org/copyleft/gpl.html

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

*/

$addon_name = "Random Image ";
$addon_description = "This addon will enables the tag &lt;IMAGE_RANDOM&gt;
which is the ID of a random image of your Pixelpost photoblog. Using this ID, you can link to a random image easily.
Usage:<br>
&lt;a href='$PHP_SELF?showimage=&lt;IMAGE_RANDOM&gt;' &gt; Random photo &lt;/a&gt; <br>
The above tag links to your photoblog with a random photo.";

$addon_version = "0.3";

// Get the number of thumbnails shown at once from the admin config
$cfgquery = mysql_query("select * from ".$pixelpost_db_prefix."config");
$cfgrow = mysql_fetch_array($cfgquery);

//---------------------------

$thmb_numb_r = 1 ;



if (isset($image_id)){
$thumbs_ahead = mysql_query("select DISTINCT id,headline,image from ".$pixelpost_db_prefix."pixelpost where id!=".$image_id." and datetime<='$cdate' order by rand() asc limit 0,$thmb_numb_r");
}
else{
$thumbs_ahead = mysql_query("select DISTINCT id,headline,image from ".$pixelpost_db_prefix."pixelpost where datetime<='$cdate' order by rand() asc limit 0,$thmb_numb_r");
}


if (list($id,$headline,$image) = mysql_fetch_row($thumbs_ahead)) {
$rnd_img_id = $id;

}

$tpl = ereg_replace("<IMAGE_RANDOM>",$rnd_img_id,$tpl);



?>

joana
04-30-2006, 03:22 PM
It is just perfect!

Thank you. ;)