Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-20-2010, 03:26 PM
ishare ishare is offline
 
Join Date: Jun 2006
Location: Stockholm
Posts: 118
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default IF CONDITION problem

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 :
Code:
<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...
Reply With Quote
  #2  
Old 09-20-2010, 03:45 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 09-20-2010, 04:19 PM
ishare ishare is offline
 
Join Date: Jun 2006
Location: Stockholm
Posts: 118
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Code:
<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...
Reply With Quote
  #4  
Old 09-20-2010, 04:27 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

...
Reply With Quote
  #5  
Old 09-20-2010, 05:01 PM
ishare ishare is offline
 
Join Date: Jun 2006
Location: Stockholm
Posts: 118
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks again kh99.

let me see if i will find a solution or not...
Reply With Quote
  #6  
Old 09-20-2010, 05:01 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oops (admin, you can remove this maybe?)
Reply With Quote
  #7  
Old 09-20-2010, 05:28 PM
ishare ishare is offline
 
Join Date: Jun 2006
Location: Stockholm
Posts: 118
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
    $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
Reply With Quote
  #8  
Old 09-20-2010, 05:38 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #9  
Old 09-20-2010, 05:48 PM
ishare ishare is offline
 
Join Date: Jun 2006
Location: Stockholm
Posts: 118
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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-tor...4858?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...
Reply With Quote
  #10  
Old 09-20-2010, 05:57 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:40 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04656 seconds
  • Memory Usage 2,248KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete