vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How to made if and else in vbulletin? (https://vborg.vbsupport.ru/showthread.php?t=170660)

BrotherX 02-16-2008 12:20 PM

How to made if and else in vbulletin?
 
Hello, I want to put code in postbit so that I am able to have in some specific forums banners but when I don't have them (too many) than one common banner or message. Thanx in advance.

So here is the code and explanation inside that code:
Code:


OPTION I

<if condition="!in_array($forumid, array(FORUMID1))">

    <td class="alt1" align="center">
        <div>
<a href="$vboptions[forumhome].php$session[sessionurl_q]"><img src="banner_path.jpg" border="0" alt="$vboptions[bbtitle]" /></a></td>
<if />

OPTION II

<if condition="!in_array($forumid, array(FORUMID2))">

    <td class="alt1" align="center">
        <div>
<a href="$vboptions[forumhome].php$session[sessionurl_q]"><img src="banner_path.jpg" border="0" alt="$vboptions[bbtitle]" /></a></td>
<if />

IF NOT OPTION I AND OPTION II, THAN GENERAL OPTION

<if condition="!in_array($forumid, array(ANY OTHER FORUM ID))">

    <td class="alt1" align="center">
        <div>

MARKETING

        </div>
    </td>
<if />


Opserty 02-16-2008 01:13 PM

I'm not sure what you are asking really but is this what you want:
Code:

<if condition="in_array($forumid, array(1, 2, 3))">
        Displayed to users in forum 1, 2 & 3
<else />
        <if condition="in_array($forumid, array(4, 5, 6)">
                Displayed to users in forum 4, 5 & 6
        <else />
                Displayed to everyone who is NOT in forum 1, 2, 3, 4, 5 or 6
        </if>
</if>


BrotherX 02-16-2008 01:22 PM

No, I want to display different banners for different forums, no different user groups.

Banner 1 for forumID35
Banner 2 for forumID67
...
Banner 5 for forumID32
Banner 6 for all other forum ID's on my forum

So we need command else and if. I know something about that, but I don't have idea how to made that in vbulletin.

I want to display different banners on different forums, so I have few banners (for example 5) and I want every banner for one forum. So five banners for five forums. Now becouase I have more than for example 50 forums, for rest I want to display one general banner, so when users are on the forums which don't have own banner (from group of the 5 banners) I want to display one general banner.

Guest210212002 02-16-2008 01:26 PM

Ops has it right, if I get your meaning. Use the first conditional to show your forum specific banners (if condition = forum 1/2/3), else show the default banner.

BrotherX 02-16-2008 02:17 PM

Quote:

Originally Posted by Chris-777 (Post 1444432)
Ops has it right, if I get your meaning. Use the first conditional to show your forum specific banners (if condition = forum 1/2/3), else show the default banner.

I know that, will you give me specific code, becouase that is what I don't know in vbulletin, I don't know how shell I write specific code if and else? Jst take code from first post and made if and else how must be. Thanks.

Option I for forumid1

if not

Option II for forumid2

if not

Option III for forumid3

if not GENERAL OPTION for rest of the forums

Guest210212002 02-16-2008 02:26 PM

The code is in Opserty's post man. :)

Opserty 02-16-2008 02:42 PM

It it all in my post... I can't understand what you don't get...
Quote:

Option I for forumid1

if not

Option II for forumid2

if not GENERAL OPTION for rest of the forums
Code:

<if condition="$forumid == 1">
        Displayed to users in forum 1
<else />
        <if condition="$forumid == 2">
                Displayed to users in forum 2
        <else />
                Displayed to everyone who is NOT in forum 1 or 2
        </if>
</if>

I match up colours...does it make sense now?:erm:

cheesegrits 02-16-2008 04:27 PM

Except that the "Displayed to ..." text now doesn't match the conditions. ;)

-- hugh

Opserty 02-16-2008 04:34 PM

~ Edited.

BrotherX 02-17-2008 09:40 AM

Quote:

Originally Posted by Opserty (Post 1444473)
It it all in my post... I can't understand what you don't get...

Code:

<if condition="$forumid == 1">
        Displayed to users in forum 1
<else />
        <if condition="$forumid == 2">
                Displayed to users in forum 2
        <else />
                Displayed to everyone who is NOT in forum 1 or 2
        </if>
</if>

I match up colours...does it make sense now?:erm:

No, it is not that. It allways show me third (general option), even on forumid1 and forumid2? So I suppose error is in third option, where must be condition for rest of the forums (id) AND it must exclude forum id 1 and forum id 2.

How is now I think that code displey banner from third (general) option on all forums, even on forum id 1 and forum id 2?

Opserty 02-17-2008 10:09 AM

Why didn't you say! :p

Instead of $forumid try $foruminfo['forumid'] and if that doesn't work try $thread['forumid'] or $post['forumid']. One of them is bound to work!

If it doesn't...what template are you putting this code it?

BrotherX 02-17-2008 10:13 AM

Quote:

Originally Posted by Opserty (Post 1445049)
Why didn't you say! :p

Instead of $forumid try $foruminfo['forumid'] and if that doesn't work try $thread['forumid'] or $post['forumid']. One of them is bound to work!

If it doesn't...what template are you putting this code it?

It is in postbit template but banner will be plaiced in second post where for guests will be displayed on one way, for members on other way.

But now I want first finish for members becouase it is easier. Later I will see how to made this for guests.

OK, I will try now what you said.

--------------- Added [DATE]1203251199[/DATE] at [TIME]1203251199[/TIME] ---------------

I will post this code so you will be able to see what is wrong. Note this is code just for members. Foruminfo, thread and post does not made anything different. Still GENERAL banner is displayed on all forums.




Code:

<if condition="THIS_SCRIPT == 'showthread' AND !$GLOBALS['FIRSTPOSTID'] AND ($show[member])">

<if condition="$show['spacer']">
    </div>
    $spacer_close
</if>

<if condition="$show['spacer']">
    $spacer_open
    <div id="edit$post[postid]" style="padding:0px 0px $stylevar[cellpadding]px 0px">
    <if condition="!$post['islastshown']"><!-- this is not the last post shown on the page --></if>   
</if>

<table class="tborder" id="post$post[postid]" align="center" border="0" cellpadding="6" cellspacing="1" width="100%">
<tbody><tr>
    <td class="thead" id="td_post_$post[postid]">
  <div class="normal">
        Marketing
    </div>
    </td>
</tr>
<tr>

    <td class="alt1" align="center">
        <div>



<if condition="$forumid == 72">

          <a href="$vboptions[forumhome].php$session[sessionurl_q]">
              <img src="images/banners/banner_test_001.jpg" border="0" alt="$vboptions[bbtitle]" />
          </a>

<else />
<if condition="$forumid == 77">

          <a href="$vboptions[forumhome].php$session[sessionurl_q]">
              <img src="images/banners/banner_test_002.jpg" border="0" alt="$vboptions[bbtitle]" />
          </a>


<else />



              <a href="$vboptions[forumhome].php$session[sessionurl_q]">
              <img src="images/banners/banner_test_general.jpg" border="0" alt="$vboptions[bbtitle]" />

        </if>

</if>




                      </div>
                  </td>
</tr>
</tbody>
</table>
</if>


Opserty 02-17-2008 10:32 AM

Have you changed Instead of $forumid as I said above?

Quote:

Instead of $forumid try $foruminfo['forumid'] and if that doesn't work try $thread['forumid'] or $post['forumid']. One of them is bound to work!

BrotherX 02-17-2008 10:40 AM

Quote:

Originally Posted by Opserty (Post 1445061)
Have you changed Instead of $forumid as I said above?

Yes and it is the same.

To clear this, code was like this $foruminfo['77'], or like this $foruminfo[77], $thread['77'] or
$post['77'] but still general banner is allways displayed?

Opserty 02-17-2008 10:48 AM

NO! lol :p

Just substitute the text in as I gave it to you. So $forumid becomes $foruminfo['forumid']!

Simple ;)

BrotherX 02-17-2008 11:20 AM

Quote:

Originally Posted by Opserty (Post 1445074)
NO! lol :p

Just substitute the text in as I gave it to you. So $forumid becomes $foruminfo['forumid']!

Simple ;)

Now I understand you.

This code working.


Code:

<if condition="$thread['forumid'] == 77">
Thank you Opserty

Opserty 02-17-2008 11:21 AM

No problem. Glad you finally got it working. :)


All times are GMT. The time now is 10:42 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.01137 seconds
  • Memory Usage 1,773KB
  • 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
  • (6)bbcode_code_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (17)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