View Full Version : IF CONDITION problem
ishare
09-20-2010, 03:26 PM
I have 2 folders for images. The 1st folder is for admin upload. And 2nd folder is for users. I would like to make a condition for first check the 1st folder, if not available then check 2nd folder and if not available there too then display the noimage file.
Something like this :
<if condition="image_ID.jpg">
<img src="1stfolder/image_ID.jpg">
<else />
<img src="2ndfolder/image_ID.jpg">
<else />
<img src="noimage.jpg">
</if>
But i couldn't make it work.
Any idea about how to do that ?
Thanks in advance...
I don't think there's any way to do that in a template conditional. You'd have to use code in a plugin, or maybe there's some way to insert javascript to make the browser load alternate images if one's not available.
ishare
09-20-2010, 04:19 PM
thank you kh99.
actually what i wrote above was just an example. the thing i would like to do is little bit different. but main idea is like above mentioned example.
let me be more clear with what i would like to do.
<if condition="$castinfo[photo] != ''">
<a href='info/person.php?id=$castinfo[id]'><img src="./cache/person/$castinfo[id].jpg" alt="$castinfo[name]" /></a>
<else />
<a href=''info/person.php?id=$castinfo[id]'><img src="./cache/person/noimage.jpg" alt="$castinfo[name]" /></a></if>
as you can see through example, its first checking if there is any image for the person or not. if image/photo is available, then its showing it. if not, then it displays the "noimage.jpg" file.
but since i do not want to display "noimage.jpg" on pages that much, i upload the pictures myself. and due to script do the logging, it's not working if i upload the picture to the "person" folder (thats where the files are stored).
so i've created a "custom" folder under "person" folder. before displaying the "noimage.jpg" file if file do not exists, i would like to make it check the "person/custom" folder too...
ishare
09-20-2010, 05:01 PM
thanks again kh99.
let me see if i will find a solution or not...
oops (admin, you can remove this maybe?)
ishare
09-20-2010, 05:28 PM
$postbit_movieinfo_cast = '';
$i = 1;
foreach ($movieinfo['cast'] AS $castinfo)
{
$filename = './cache/person/' . $castinfo['id'] . '.jpg';
if ($castinfo['photo'] AND $castinfo['id'] AND !file_exists($filename))
{
require_once(DIR . '/includes/class_image.php');
$content = file_get_contents($castinfo['photo']);
$handler = @fopen($filename, 'w');
@fwrite($handler, $content);
@fclose($handler);
$thmbnail_class = vB_Image::fetch_library($vbulletin);
$thumbnail = $thmbnail_class->fetch_thumbnail($castinfo['id'] . '.jpg', $filename, 100, 140);
unlink($filename);
$filename = './cache/cast/' . $castinfo['id'] . '.jpg';
$handler = @fopen($filename, 'w');
@fwrite($handler, $thumbnail['filedata']);
@fclose($handler);
}
Above is the code in appropriate hook for the plugin... And frankly speaking i still couldn't solve it...
But i did something much easier. (maybe we can not call it a solution)
Instead of noimage.jpg file, i forced <else /> condition to show the image in "person/custom" folder... If there is no image in that folder too, its not showing anything. So when i see that kind of empty columns (no picture in the table), i upload the image manually. And its showing...
I know its not a proper way to display the image but since am not a coder, thats the most practical/easiest way for me :)
and once again i would like to thank you for your kind answers and help kh99
OK - sorry I deleted my answer above, I misunderstood and thought you wanted to see if anyone else knew of an answer.
(nvm - that code was wrong...need to understnd it better).
ishare
09-20-2010, 05:48 PM
I did your advise but nothing changed... Thank you.
If you would like to see the live example of what i would like to do here it is :
http://www.dwshare.com/f831/gran-torino-2008-a-34858?langid=14
Since the website is still under construction, some posts/threads are still not showing due to the data loss during the database move...
Looks nice.
Sorry, I keep posting before thinking. It would probably be necessary to see more of the code to be able to post a solution.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.