vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   IF CONDITION problem (https://vborg.vbsupport.ru/showthread.php?t=250866)

ishare 09-20-2010 03:26 PM

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...

kh99 09-20-2010 03:45 PM

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.
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...

kh99 09-20-2010 04:27 PM

...

ishare 09-20-2010 05:01 PM

thanks again kh99.

let me see if i will find a solution or not...

kh99 09-20-2010 05:01 PM

oops (admin, you can remove this maybe?)

ishare 09-20-2010 05:28 PM

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

kh99 09-20-2010 05:38 PM

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-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...

kh99 09-20-2010 05:57 PM

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.


All times are GMT. The time now is 10:09 AM.

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.01089 seconds
  • Memory Usage 1,735KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete