vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Design and Graphics Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=253)
-   -   Picking Alternate Posts With A Conditional (https://vborg.vbsupport.ru/showthread.php?t=259307)

madshark 02-23-2011 07:56 AM

Picking Alternate Posts With A Conditional
 
I'm trying to pick out ever alternating post with a conditional. I recall successfully doing this with


Code:

<vb:if condition="$post['postcount'] % 2 == 0">
on 4.0.3 or the likes.

However with 4.1.2 it doesn't seem to work. Or I just cant remember the correct coding. Could anyone please shed some light?

A typical usage would be to have alternating postbit colours.

Thank You.

Lynne 02-23-2011 05:05 PM

What template are you putting this in? And can we see exactly what you are adding and where?

madshark 02-23-2011 05:30 PM

I basically want the postbit userinfo to alternate. Left and Right. Ive done it before. I just haven't used VB for awhile and cant remeber how the heck I did it for the life of me as my forum was pretty much closed down.

What I do know is that I used it in the postbitlegacy template.

And basically I used a second CSS for userinfo (i.e userinfo1) with a float right.

Code:

.postbitlegacy .userinfo1 {
        float:{vb:stylevar right};
        position: relative;
        width:{vb:math {vb:stylevar postbitlegacy_userinfo_width}-{vb:math {vb:stylevar padding}*2}};
        padding: 2px {vb:stylevar padding} {vb:math {vb:stylevar padding}/2};
        font-size: {vb:stylevar small_fontSize};
        display:block;
  background: {vb:stylevar postbit_userinfo_background};
        clear:both;
}

So in theory and again if memory serves me well the code should look something like this I take it...

Code:

<div class="postdetails">

                <vb:if condition="$post['postcount'] % 2 == 0"><div class="userinfo"><vb:else /><div class="userinfo"></vb:if>

                        <div class="username_container">
                        <vb:if condition="$post['userid']">
                                {vb:raw memberaction_dropdown}
                                {vb:raw post.onlinestatus}
                        <vb:else />
                                <span class="username guest">{vb:raw post.musername}</span>
                        </vb:if>
                        </div>

Im fairly certain I used something very similar to the above. For some reason it seems to break the whole post bit this time around. However if i just switch the userinfo to userinfo1 minus the conditional the post bit displays the userinfo on the right with no issue. So the css seems to be problem free.

Any ideas?

Thanks.

Lynne 02-23-2011 05:35 PM

You do see that you have the same class in both the if and else?

HTML Code:

<div class="userinfo"><vb:else /><div class="userinfo">
It works fine on my forum if I change that line to have different classes.

madshark 02-23-2011 06:19 PM

My bad I typed that out half asleep. whee hours of the morning here lol. Pretty sure I used different classes when I tried it.

Odd. I shall check it again in the a.m and post back. But basically you implemented exactly what I posted above yes ?

Lynne 02-23-2011 08:25 PM

I implemented the class change in my postbit_legacy and it worked. I did not check your CSS, but the class is definitely changing in alternate posts.

madshark 02-26-2011 05:41 AM

The CSS needed to be changed in more than one place. Postdetails needed to be aligned as well. And another conditional needed to be added. Not too shabby.

Thanks Lynne


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.01079 seconds
  • Memory Usage 1,724KB
  • 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)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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