Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-06-2004, 07:44 PM
Bonee70 Bonee70 is offline
 
Join Date: Aug 2003
Location: Germany
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Show signature only once?

Is there a hack that shows a users signature only once per thread (in the first post by the user but then not again when the user replies for another time in the same thread)?

Thx!
Reply With Quote
  #2  
Old 09-06-2004, 10:26 PM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you want to show something only once for a page that is being generated, start with the template that is used to produce the bits for the pages -- threadbits, forumbits, memberbits, whatever. In that template, to conditionalize the thing being displayed, use an associative array. An associate array has a key and a value. When you see "$frobs['thing']", that is a reference to an associate array and will return the VALUE for the KEY named 'thing'.

We're getting there...

So, in the template that you have to modify, you can *create* an associative array. Yes, you can create one that is not created by the PHP code that uses the template. So, let's say that you want to only show a signature once on a page, you would create an associative array that is keyed by userid or username. We will stick with userid. The first time the process to output a page encounters a userid, set a value in the associative array for userid "###', like so:

$userid_has_been_seen[###] = 'Yup'

The next time that the template is run, check to see if you have already seen this user. You would do that like so with a template conditional:
Code:
<if condition="NOT $userid_has_been_seen[###]">
    do stuff for a user we have not yet seen on this page
</if>
Now, the "###' shown above will have to be replaced with the a reference to a userid, but you get the idea. Also, the conditional I showed is not quite right. What you really want is a test that checks to see if you have seen this user before, and *if* you have not, then note it so that you will notice the next time that you have seen it. Here's how you would do that:
Code:
<if condition="NOT $userid_has_been_seen['###'] AND $userid_has_been_seen[###] = true">
     do stuff for the first time you have seen this user
</if>
This will strike a non-programmer as an odd looking idiom, so we'll break it down. It is a test that is composed of two sub-tests: if the first one fails (I have not yet seen this user), then the second one runs (note that I have seen this user).

With this code, the second time that you encounter the userid, the HTML between the "<if ...>" line and the "</if>" line will not be included in the output.

The final step is to ask how this would work in the case of a user's signature when displaying a page of posts.

Posts are displayed by showthread.php. In there it uses the "postbit" template to generate the output for every post. Look inside the "postbit" template and find out how they are referring to the USERID.

I am looking right now...

In the "postbit" template, they refer to the USERID as "$post[userid]". That is our '###' reference we used earlier. What I need to do is replace my '###' with this real reference. If I do that, the code I offered above becomes this:
Code:
<if condition="NOT $userid_has_been_seen[$post[userid]] AND $userid_has_been_seen[$post[userid]] = true">
     do stuff for the first time you have seen this user
</if>
All I did was replace the '###' above with '$post[userid]'.

There is only one more lie to reveal. I used "NOT" to make things clear, but for PHP you have to say "!" to mean "NOT". So, if you want to turn a test around, you use "!" before the test.

The very last step is to find the code in the template that emits the signature.

I am looking... ... Here is is from "postbit":
Code:
		<if condition="$post['signature']">
		<!-- sig -->
			<div>
				__________________<br />
				$post[signature]
			</div>
		<!-- / sig -->
		</if>
So what you want to do is put this line before this section:
<if condition="! $userid_has_been_seen[$post[userid]] AND $userid_has_been_seen[$post[userid]] = true">

and then put this line after that section:
</if>
Reply With Quote
  #3  
Old 09-07-2004, 12:12 PM
Bonee70 Bonee70 is offline
 
Join Date: Aug 2003
Location: Germany
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow man, thx a lot for this little coding lesson, nice work. A guy on another board guided me to another code I use now to show the signatures only once.

Open includes/function_showthread.php, find:
Code:
$post['signature'] = $sigcache["$post[userid]"];

Replace with:

//$post['signature'] = $sigcache["$post[userid]"];
$post['signature'] = "";
It works perfectly.

Thx again man, I realy apreciate doing such a long post for a coding monkey like I'm ....
Reply With Quote
  #4  
Old 09-07-2004, 12:25 PM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Bonee70
Wow man, thx a lot for this little coding lesson, nice work. A guy on another board guided me to another code I use now to show the signatures only once.

See previous post for showthread.php mod...

It works perfectly.

Thx again man, I realy apreciate doing such a long post for a coding monkey like I'm ....
My pleasure.

One minor point for other readers though...

The approach you have adopted does suffer from the disadvantage of requiring a mod to a script file rather than a straight template edit to add a couple of lines.
Reply With Quote
  #5  
Old 10-18-2005, 05:27 PM
Dybukk Dybukk is offline
 
Join Date: Jan 2002
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any idea what file this would be on 3.5?
Reply With Quote
  #6  
Old 10-18-2005, 05:29 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="https://vborg.vbsupport.ru/showthread.php?t=96368" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=96368</a>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:38 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.06292 seconds
  • Memory Usage 2,217KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete