vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   how to do a conditional element on the postbit (https://vborg.vbsupport.ru/showthread.php?t=205255)

columbusgeek 02-13-2009 01:34 PM

how to do a conditional element on the postbit
 
I am involved in a pretty heavy rework of a template. I need to know how to do a conditional element on the postbit.

For example if there is data inserted into a custom field then it will display the title of the custom field and the data, but if there is no data added to the field the title will not be displayed.

suggestions are appreciated.

Spank 02-13-2009 02:09 PM

Code:

<if condition="$post['field#']">$post[field#]</if>
Be sure to replace the # with the field number.

UKBusinessLive 02-13-2009 02:09 PM

Hi

You need to add something like this

Code:

<if condition="$post['fieldX']">
whereas the 'fieldx' is the field attribute from the user custom field

Don't forget to end it too

Code:

</if>
--------------- Added [DATE]1234541403[/DATE] at [TIME]1234541403[/TIME] ---------------

Quote:

Originally Posted by Spank (Post 1742905)
Code:

<if condition="$post['field#']">$post[field#]</if>
Be sure to replace the # with the field number.

SNAP :D:D

Lynne 02-13-2009 02:21 PM

Usually you can get a sense of how to do a condition by looking at others in the same template. In your case, see this one:
HTML Code:

<if condition="$post['field2']"><div>$vbphrase[location_perm]: $post[field2]</div></if>
You should be able to copy that and change field2 to fieldx for your field and then just change the phrase being used also. So....
HTML Code:

<if condition="$post['fieldx']"><div>Whatever: $post[fieldx]</div></if>
edit: Darn, I was late on this one! That's what I get for filling up my tabs in my browser window.

columbusgeek 02-13-2009 02:52 PM

Thanks for all the great advice, worked perfect.

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

I think I phrased my question wrong though. I the custom fields I was able to do, but my issues lies with replies to the post.

This is going to sound odd, but I am phrasing this to sound generic, and not necessarily the way it will be implemented on the board.

A user posts a topic. Below the topic area it is totally empty. (no quick reply, no nothing) When a person replies to the topic, text will come up saying "replies to topic below", and obvioulsy, the reply will show.

So it's just a matter of showing or hiding a chunk of text belwo the post, and above the replies, depending upon if there are replies.

Lynne 02-13-2009 03:04 PM

So you actually need something to show up under the first post in a thread?

columbusgeek 02-13-2009 03:13 PM

I'm the middle man here between the designer so sorry about my slight confusion, but yes, that sounds like the ticket. I think it only needs to be text.

Lynne 02-13-2009 04:23 PM

Just add something like this to the end of the postbit (or postbit_legacy) template (of course, format it correctly). Or use $template_hook[postbit_end] to add it:
HTML Code:

<if condition="$post['postid']==$thread['firstpostid']">
stuff after first post
</if>


columbusgeek 02-13-2009 05:44 PM

As always, thank you for your suggestions Lynne, and everybody else for that matter.

connectr 02-14-2009 03:39 AM

Hi guys,
I'm the guy working with Matt on this project :)

What i was trying to figure out, was how to wrap the entire postbits block with a conditional check - if posts exist show postbits block, else show alternate block (or nothing).

<if condition="$post==1>
<div id="posts">
$postbit
</div>
<else/>
<p>There are no posts in this category.</p>
</if>

Hope that clarifies :)

Thanks again to everyone who took the time to reply - its much appreciated!!

Cheers,
Chris

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

To further clarify, i've uploaded a screenie of the layout i'm wokring on.. http://www.quicksnapper.com/connectr...load-details2/

Its the download details page in vbdynamic download manager. The postbits section is handled by vb and that is the updates block below the main image (i have pretty much stripped out all the usual forumy bits).

Essentially we want the postbits (updates stream) block only to show if there are updates posted for that particular download.

Cheers,
Chris

Lynne 02-14-2009 03:53 AM

I'm not sure I understand. It sounds like you are simply using the postbit template, but not the showthread page, correct? So, do these posts even have post numbers? If so, then I suppose <if condition="$post[postcount] == '1'"> may be valid. I really can't tell because I'm not sure if you are using the same variable names at all for these posts.

connectr 02-14-2009 04:09 AM

Hi Lynne :)
Thanks for the reply and sorry for the confusion. I'll try explain in more detail.

As mentioned before, we're essentially styling the download manager plugin, vbdynamix. Each download has a details page, where you can post updates in the form of posts and optionally allow users to reply etc. This part of the page seems is handled by vb. Since we've told VBD to use its own template, we can go crazy on it without worrying about messing up the main forum.

My aim with this project is to get the downloads page to look un-forum-y as possible ;) This is what i have in the downloads details page (ADV_DYNA_SHOWENTRY):

PHP Code:

<if condition="$post[postcount] == '1'">
  <
div id="updates">
    <
h2>Update Stream:</h2>
    <
ul>$postbit</ul>
  </
div>
</if> 

I tried the conditional posts check you suggested, but unfortunately it didnt work.

In the postbit_legacy i have this:
PHP Code:

<li class="updates">
$template_hook[postbit_start]
$template_hook[postbit_messagearea_start]
<
class="update-date">$post[postdate]</p>
<
class="update-message">$post[message]</p>
<if 
condition="is_member_of($bbuserinfo, 6)"><a href="$post[editlink]name="vB::QuickEdit::$post[postid]">Edit</a></if>
$template_hook[postbit_end]
</
li

and the postbit_wrapper i have this (there was a bunch of other unnecessary html which i stripped out):
PHP Code:

$postbit 

Hope this helps..
Cheers,
Chris

Lynne 02-14-2009 04:19 AM

<if condition="$post[postcount] == '1'"> doesn't work? If not it's probably because $post[postcount] doesn't exist. You may have to spit out some variables in the templates in order to see exactly what is available and then determine what you want to use for your conditions.I am unfamiliar with vbdynamix so I really don't know that I can be of much help.

connectr 02-14-2009 04:38 AM

Hi Lynne,
I tried adding $post[postcount] into the ADV_DYNA_SHOWENTRY page and it didnt output anything. I then went on to add it to the postbit_legacy file and it now shows a 1,2,3 etc on each of the posts. So i'm guessing hte postcount option only works when inside of the postbit template.

You mentioned spitting out some variables to see what is available. Could you elaborate?

Thanks,
Chris

Lynne 02-14-2009 04:52 AM

It sounds like you did what I was suggesting - putting something like $post[postcount] in the template to see what gets spit out. Unfortunately, I don't understand what this output page is you are talking about. If that variable works in the template, isn't that where you wanted to use it? You could do what you were saying in the postbit_legacty template by just wrapping it all in a condition, no?

HTML Code:

<if condition="$post[postcount] == '1'">
<li class="updates">
$template_hook[postbit_start]
$template_hook[postbit_messagearea_start]
<p class="update-date">$post[postdate]</p>
<p class="update-message">$post[message]</p>
<if condition="is_member_of($bbuserinfo, 6)"><a href="$post[editlink]" name="vB::QuickEdit::$post[postid]">Edit</a></if>
$template_hook[postbit_end]
</li>
<else />
something else
</if>


connectr 02-14-2009 05:30 AM

Your comment just sparked an idea! The postcount works when its inside of the postbit template, so if i move the stuff from the ADV_DYNA_SHOWENTRY template into the postbit_wrapper, the postcount should work and we would be golden. I'm gona give it a shot now and will post my findings once i've tested it..
Thanks again!
Chris

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

close but no cigar :( it seems that postbit_wrapper is part of the postbit loop. The download that has no updates doesnt display the updates block, which is what we want, but then the download that has 5 updates displays the updates block, but only outputs one post.

Any ideas?

connectr 02-14-2009 05:51 AM

1 Attachment(s)
My goal has been to completely hide the updates block if no updates are available, but thinking more for consistency sake having the block always there isnt necessarily a bad thing. So now i am trying your suggestion, adding the check to the postbit_legacy template:

<if condition="$post[postcount] == '1'">
<li class="updates">
$template_hook[postbit_start]
$template_hook[postbit_messagearea_start]
<p class="update-date">$post[postdate]</p>
<p class="update-message">$post[message]</p>
<if condition="is_member_of($bbuserinfo, 6)"><a href="$post[editlink]" name="vB::QuickEdit::$post[postid]">Edit</a></if>
$template_hook[postbit_end]
</li>
<else />
<li class="no-updates">
$template_hook[postbit_start]
$template_hook[postbit_messagearea_start]
There are no updates for this template.
$template_hook[postbit_end]
</li>
</if>

Based on the above, you would expect that the updates block will always be there and if update posts exist, they are displayed, else show a message saying that no updates are available.

Unfortunately, what i've ended up with is just the updates heading on the page that doest have any updates (ie, no message saying no updates below the heading) and then on the page that does have updates i have the first update message displaying, but then the no updates messages outputted 3 times where the other updates should be.

I know that probably doesnt make sense, so i've attached two images - one showing the download that doesnt have any posts and one of the download that does have posts.

Thanks,
Chris

connectr 02-14-2009 05:54 AM

Looking at the code again, and studying the output of the postcount variable, i think i know why its outputting the way it is. It looks like the conditional is saying "if postcount is equal to 1", essentially targeting only the post whose post count is 1, ie the first post.

What do you think? Is it possible to tweak the conditional to say if posts exist, else...

Dismounted 02-14-2009 10:16 AM

I'm a bit confused, but can't you just use the adlocation_firstpost template?

connectr 02-14-2009 12:20 PM

Hi Dismounted,
You'll have to excuse as this is my first vb project and am not yet 100% on par with how everything works. Would you mind elaborating on how you see it working? I recall seeing the adlocation_firspost variable in the postbit, but figured it was just a placeholder for a banner ad after the first post..
Cheers,
Chris

Dismounted 02-15-2009 04:00 AM

Actually the template is ad_showthread_firstpost (just checked :p). Don't let the name fool you, it is just a template that gets placed after the first postbit in a thread.

connectr 02-15-2009 07:27 AM

Hi Dismounted,
I'm still not sure how that can be used to conditionally wrap around the postbit to get the end result i am trying for.. How do u see that working?
Thanks,
Chris


All times are GMT. The time now is 08:04 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.01274 seconds
  • Memory Usage 1,806KB
  • 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
  • (4)bbcode_code_printable
  • (4)bbcode_html_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (22)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