vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   vB4 Template Conditionals List (https://vborg.vbsupport.ru/showthread.php?t=231525)

egyptsons 02-04-2010 12:44 AM

this is not work too with me :(
Code:

<vb:if condition="$forum[forumid] == x">Show this if forum id is x</vb:if>
anyone can advice ??

isurua 02-04-2010 02:20 AM

Quote:

Originally Posted by flypaper (Post 1973788)
that

Yes well aren't I the ignorant one? Hahah

Do you know if there is any work around?

btotw 02-06-2010 08:59 PM

I have an idea.

I want to give someone control of their own thread. I figure that a good way to do that would be to duplicate the supermoderator group, calling it "threadModerator", then only display the "show admintools" dropdown IF the current user is both a threadAdmin AND is author of the current thread.

In other words, if the threadmoderator group is "100," How can I then say

If currently_logged_in_user is threadmoderator and
If currently_logged_in_user = thread_starter then
show admintools

I figure its something close to:

<vb:if condition="is_member_of($bbuserinfo, 100)">
<vb:if condition="is_author_of($thread)">
show admintools
</vb:if>
</vb:if>

It has to be something close to this...though I dont know how to query the system to find out the author of a thread...nor do I know how to reference the "show admintools" function...but I figure I've reasoned this out and given enough effort that one of you...who are MUCH better programmers than I...is willing to help me (and anyone that wants to use the code, giving myself and the person who cleans this up the credit).

How bout it people? Can someone help with this...?

mabersoft 02-09-2010 08:24 PM

What would the code be to only show on forumhome?

matthieugoua 02-10-2010 01:58 PM

Quote:

Originally Posted by egyptsons (Post 1974321)
this is not work too with me :(
Code:

<vb:if condition="$forum[forumid] == x">Show this if forum id is x</vb:if>
anyone can advice ??

not work for me

Adam H 02-11-2010 08:25 PM

Can any one tell me what i would have to use to get a sign to come up only when a thread is closed ?

So basically if a thread is closed i want a certain peace of HTML to show up

TheSupportForum 02-19-2010 08:16 AM

i need some help with the variables below to work with certian group and also an option not to show to certian groups can anyone help

so far i have this



Code:


<vb:if condition="is_member_of($bbuserinfo, {vb:raw vboptions.wmf_grp_perm})">
<vb:if condition="$vboptions['paypal_enable']">
 
 
 
<vb:else />
{vb:raw vboptions.wmf_closedreason}
</vb:if>

i need to where to add the section to not allow certain groups
i hope i got the code in the correct order so far

i wanna add {vb:raw vboptions.wmf_grp_noperm}

but not sure where to put it and if i need to add anything else to my exist code after the one i want inserted

AzzidReign 02-21-2010 03:16 PM

lol Wish I would have saw this before. Oh well, I figured it out :P Thanks for this though!

smartkidbk5 02-25-2010 03:41 AM

Quote:

Originally Posted by egyptsons (Post 1972657)
Thanks for your article

I want to add advertisement after the first post in some special forums
so I edit the "ad_showthread_firstpost" Template and add this

Code:

<vb:if condition="in_array($forum['forumid'], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>
But nothing change in the special forums and the ads not appear

also if I used this
Code:

<vb:if  condition="!in_array($forum[forumid], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>
it's appear in all forums not only the special (1,2,3)

Can you advice me plz ?

Best regards

Same with me. Anyone know the correct conditionals?

Alp Ozdemir 02-25-2010 11:52 AM

Try this;

Code:

<vb:if condition="in_array($foruminfo[forumid], array(x,y,z))">
code here!
</vb:if>


princeedward 03-04-2010 08:24 AM

:erm: errrmmm... hi

how about showing something here to a thread starter but not to his first post....is there any conditional on this please?

appreciate any help

thanks and best regards...

:p

hatchet 03-06-2010 10:47 PM

Is there anything that I can pull the date of the last post of a thread?
$thread['lastpostdate'] or something like that. I'm trying to see if the last post date is older than 90 days and if so - output a custom phrase.
Thanks.

boatdesign 03-11-2010 05:54 AM

I'm trying to use a conditional to color code certain forums in the What's New and Search Results.

In search_threadbit I've tried the following, with no success (only the else shows for threads in these forums too.)
Code:

<vb:if condition="in_array($foruminfo[forumid],array(26,29,56,25,27))">
<div class="threadpostedin td alt">
<p>Test Different Color Div will go here For these Forums</p>
</div>
<vb:else />
<div class="threadpostedin td alt">
<p>
{vb:rawphrase forum}: <a href="{vb:link forum, {vb:raw thread}, null, 'forumid', 'forumtitle'}" title="{vb:raw thread.forumtitleclean}">{vb:raw thread.forumtitle}</a>
</p>               
</div>
</vb:if>

I thought that since forumid is actually in the link, it would be a piece of cake, but it's a no go as above. I must be missing something obvious.

I read here about assigning a variable to a template, so tried creating a new plugin to do so, but can't seem to make that work either. One question is that the template is labeled search_threadbit but that's not a choice in the add plugin screen for a hook location - only search_results_threabit which doesn't seem to exist as a template. So I'm a bit lost there.

Any guidance? Many thanks.
(new to VB4 today)

DesignWerks 03-11-2010 10:50 AM

Quote:

Originally Posted by M4tEUSh (Post 1993295)
So how to properly construct a condition with {vb:raw var}?

Bumping this question. I have my conditional working but it would be more efficient if I could use it with a plugin for an external php page which updates several areas of my site at once so <vb:if condition="!is_member_of($bbuserinfo, 12)">{vb:raw includemyexternalpage}</vb:if> hides the section from usergroup 12.

Is it possible to put the condition in the plugin?

boatdesign 03-12-2010 03:59 AM

Quote:

Originally Posted by boatdesign (Post 2001366)
I'm trying to use a conditional to color code certain forums in the What's New and Search Results.

In search_threadbit I've tried the following, with no success (only the else shows for threads in these forums too.)
Code:

<vb:if condition="in_array($foruminfo[forumid],array(26,29,56,25,27))">
<div class="threadpostedin td alt">
<p>Test Different Color Div will go here For these Forums</p>
</div>
<vb:else />
<div class="threadpostedin td alt">
<p>
{vb:rawphrase forum}: <a href="{vb:link forum, {vb:raw thread}, null, 'forumid', 'forumtitle'}" title="{vb:raw thread.forumtitleclean}">{vb:raw thread.forumtitle}</a>
</p>               
</div>
</vb:if>

I thought that since forumid is actually in the link, it would be a piece of cake, but it's a no go as above. I must be missing something obvious.

I read here about assigning a variable to a template, so tried creating a new plugin to do so, but can't seem to make that work either. One question is that the template is labeled search_threadbit but that's not a choice in the add plugin screen for a hook location - only search_results_threabit which doesn't seem to exist as a template. So I'm a bit lost there.

Any guidance? Many thanks.
(new to VB4 today)

Sorry - I got lost and couldn't see the forest for the trees. Thanks to Lynne for pointing out that for the search_threadbit template $thread[forumid] not $foruminfo[forumid] was the ticket.

kingMOB 03-13-2010 09:22 PM

Is there an "at least this" conditional?

I have this conditional to list just the blogs from a specific category:

PHP Code:

<vb:if condition="$blog['categories'] == 6"

It works well, but only if the blog entry is marked with only this category (6). If I choose one more category to the blog, let's say 5 and 6, this conditional no longer works.

Any help? =)

nack 03-15-2010 10:12 PM

Hi, how would you direct guests to login with <if condition>?

MrToasty 03-16-2010 10:10 AM

I have a custom template being called at the template hook in the postbit called postbit_userinfo_right_after_posts which works fine with static text from the template outside of conditionals, however when I try to use text in a conditional or pull a field such as {vb:var post.fieldX}, nothing happens...

I am able to call conditionals in the postbit template without any problems, just not in the custom template.

The conditional and field I'm trying to use is:-

Code:

<vb:if condition="$post['fieldX']"><dt>Field Title</dt> <dd>{vb:var post.fieldX}</dd></vb:if>
Any ideas?

cmiller1014 03-19-2010 03:03 AM

What about a conditional to have an ad appear after every 2 posts? used to be easy in vb 3.8, not now! :( :(

meonet 03-19-2010 06:44 AM

Hello,

I would like to show different size ads for memvers and guests, someone can help me to see if this code it's correct?

Quote:

<vb:if condition="in_array($bbuserinfo['usergroupid'], array(usergroupshere))">
advert here
</vb:if>
Thanks

princeedward 03-19-2010 12:02 PM

is there any conditional list to show something only if the said member is offline?
it means the below code belong to the user...so i want to hide it when they are online...
it can only be seen once that they are offline...is that possible guys?
Code:

<vb:if condition="$post['lastactivity']">
<dt>{vb:rawphrase last_online_activity}</dt><dd>{vb:raw post.lastactivity_date} {vb:raw post.lastactivity_time}</dd>
</vb:if>

appreciate any possible help on this guys...

thanks and best regards...

:o

princeedward 03-21-2010 10:40 AM

Quote:

Originally Posted by princeedward (Post 2006433)
is there any conditional list to show something only if the said member is offline?
it means the below code belong to the user...so i want to hide it when they are online...
it can only be seen once that they are offline...is that possible guys?
Code:

<vb:if condition="$post['lastactivity']">
<dt>{vb:rawphrase last_online_activity}</dt><dd>{vb:raw post.lastactivity_date} {vb:raw post.lastactivity_time}</dd>
</vb:if>

appreciate any possible help on this guys...

thanks and best regards...

:o

any cofirmation at least for the thread starter or some more experienced coder out there please...or any respectable staff?

hmmm...:rolleyes:

princeedward 03-24-2010 06:29 PM

Bump!-Bump!-Bump!

:mad:

TalkVirginia 03-24-2010 07:02 PM

It seems simple enough.. I wish I could help. Unfortunately I'm not familar in that area. Hopefully my response will help in attracting attention to your question. ;)

princeedward 03-26-2010 04:36 AM

TalkVirginia...thanks a lot but i guess and notice that most of well experienced coder are not quite there anymore or interested of replying to any message who needs help regarding code like this or product...we have still some around but not paying or giving attention to post message like this...but if you post it to paid forum...they are quite fast and your pm box is full in a minute or 2....:p well thats my own opinion only...well i am not like that or tryin not to be like that...as long as i can...i am willing always to share my knowledge...or anything that i know...without any single cents...thanks is quite enough...

anyway hope someone who is more experienced coder someday will go reply here and share his knowledge...i might share him too some cents...;)

best regards to all

:p

TalkVirginia 03-26-2010 08:33 AM

I think most want us to do as much research on our own, provide our analysis and findings before they offer any input. Granted, this is important to do but sometimes we need a knudge in the right direction... sometimes. :) Off the top of my head I would say you might be able to find something already existing in postbit and/or postbit_legacy where it shows the online status icon. I'll have to go back and re-read the thread I guess in case that's not what you are looking for.

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

Quote:

Originally Posted by M4tEUSh (Post 1993295)
So how to properly construct a condition with {vb:raw var}?

for example, if {vb:raw var} is smaller than 6, show XYZ

I don't know if anyone has answered this or if you have already figured it out but you would need to handle this logic in your php code then render the variable accordingly.

Mutt 04-18-2010 03:23 PM

I'd like to add that you can use AND & OR for example

Code:

<vb:if condition="$show['member'] AND THIS_SCRIPT == 'calendar'">show text</vb:if>

Olivier Turbis 04-25-2010 08:58 PM

What about show to users having one post? Please? Thank you in advance! :)

zipperty 05-02-2010 10:24 AM

Crystal clear - Subscribed.... thank you

Blackhat 05-02-2010 11:23 PM

I'm trying this in the css files stored among the templates. Anyone care to tell me whats wrong ? :)

Quote:

html {
<vb:if condition="$post['field26']">
background-image:url($post[field26]);
<vb:else />
background:{vb:stylevar doc_background};
</vb:if>
}

Flyte 05-03-2010 10:02 PM

is there a way to get this to work in a CMS article? or maybe with bbcode?

TimberFloorAu 05-17-2010 08:55 PM

Can we set conditional to ONLY show if user has filled in Profile Field ? Otherwise it is blank

spillage 05-31-2010 12:37 PM

I've been working with some of the code provided here to show Adsense ads to non members only.

I found that using <vb:if condition... gave an error when trying to save the code.
Missing if statment relative to the </vb:if>

The following worked
Code:

<if condition="in_array($bbuserinfo['usergroupid'], array(1,3,4,8))">
Adsense code here
</if>


merk_aus 06-13-2010 03:15 AM

Wow thanks for this greatly appreciated; I have dedicated this entire day to me to fix up all the little things on my site such as all of the template edits, permissions and most importantly all of the conditionals and so this thread and the time taken to create it is greatly appreciated.

malmazan 06-16-2010 04:18 PM

Quote:

Originally Posted by BBR-APBT (Post 1941139)
Show in several forums:
Code:

<vb:if condition="in_array($forum['forumid'], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>

I all templates i edit the above did not work.

What did work was:
Code:

<if condition="!in_array($GLOBALS[forumid], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if>
Though your conditional may work in some other templates.

merk_aus 06-18-2010 12:53 AM

Can someone tell me if this is right to put in our footer to not have something show on the CMS and to not show it to guests:

Code:

<vb:if condition="THIS_SCRIPT != 'CMS'"><vb:if condition="is_member_of($bbuserinfo, 1,2,3)">Code here!</vb:if></vb:if>
I just want someone to tell me if it is correct, if not what is correct.

Lizard King 06-19-2010 02:02 PM

The correct this_script for CMS is

HTML Code:

<vb:if condition="THIS_SCRIPT == 'vbcms'"></vb:if>

Trek 06-22-2010 02:31 AM

****UPDATE***

Ok, finally figured it out, had to pass in usergroups in the $show variable from the plugin.

So in the plugin:

$show[gm_ugs] = explode(',', trim($vbulletin->options['gm_user_groups_allowed']));

and in the template, the condition is:

<vb:if condition="is_member_of($bbuserinfo, $show[gm_ugs])">

I'm sure that's obvious to most of you, but... just incase someone else has the same question, hopefully that helps.

--------------------------

How do you check multiple usergroups in a template?

Such as:

<vb:if condition="is_member_of($bbuserinfo, $usergroups)">

where $usergroups = "6,15,10"

Specifically:

<vb:if condition="is_member_of($bbuserinfo, array($vboptions['gm_user_groups_allowed']))">

Is what I am trying, but it only seems to work if $vboptions['gm_user_groups_allowed'] is not an array and is a single value.

Webmist 06-23-2010 03:26 AM

Quote:

Originally Posted by SledgeHead (Post 1950116)
How would I make it so a profile option could disable a toolbar? To be more specific I am trying to make Tweetboard and Wibiya Toolbars optional via user options.



I have profile field 8 with radio single selection as the type. It's set with options of yes and no. It seems to be working.


Code:

<vb:if condition="in_array($bbuserinfo['field8'], array(yes))">
Script or code here
</vb:if>


noppid 06-23-2010 04:28 AM

Quote:

Originally Posted by Webmist (Post 2057874)
I have profile field 8 with radio single selection as the type. It's set with options of yes and no. It seems to be working.


Code:

<vb:if condition="in_array($bbuserinfo['field8'], array(yes))">
Script or code here
</vb:if>


This would use many many less clock cycles and allocate less memory.

Code:

<vb:if condition="$bbuserinfo[field8] == 'yes'">
Script or code here
</vb:if>

And watch how you spell 'yes' when you create your custom fields, case matters.


All times are GMT. The time now is 02:46 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01940 seconds
  • Memory Usage 1,850KB
  • 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
  • (19)bbcode_code_printable
  • (1)bbcode_html_printable
  • (1)bbcode_php_printable
  • (12)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete