Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2005, 02:00 PM
Oreamnos's Avatar
Oreamnos Oreamnos is offline
 
Join Date: Dec 2004
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default passing arguements to function

I have a simple function in my includes/functions.php file. it requires 2 arguements (userid, forumid).

I am trying to make a template conditional that uses this function

where do the userid and forumid get passed to this function?

any help with this would be great because i am super noob to templates

thanks
eric
Reply With Quote
  #2  
Old 02-10-2005, 02:19 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Without a few exceptions (like can_moderate() or in_array()) you can't use functions in Templates!
Reply With Quote
  #3  
Old 02-10-2005, 02:23 PM
Oreamnos's Avatar
Oreamnos Oreamnos is offline
 
Join Date: Dec 2004
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks

I realize you are quite limited in what you can do in the template conditionals.

But how do the arguements get passed to say, the following function, found in /inludes/functions.php?
PHP Code:
// ###################### Start queryphrase #######################
function fetch_phrase($phrasename$phrasetypeid$strreplace ''$doquotes true$alllanguages false$languageid = -1)

Reply With Quote
  #4  
Old 02-10-2005, 03:22 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$phrase fetch_phrase('someerror'PHRASETYPEID_ERROR); 
for Example, if this is what you wanted to know ...
Reply With Quote
  #5  
Old 02-10-2005, 06:47 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just to make things a bit clear. You are now talking about a php-script, not about a template.
Reply With Quote
  #6  
Old 02-10-2005, 11:21 PM
Oreamnos's Avatar
Oreamnos Oreamnos is offline
 
Join Date: Dec 2004
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks but I am still lost. Let me be more specific.

I have this function (which I didn't write) which is in my inludes/function.php. what it is supposed to do is check if the user has started a thread in forum number 10.
PHP Code:

// ###################### Check if user posted Introductory thread #######################
function posted_in_forum($userid,$forumid 10) {
    global 
$DB_site;
    
$posted $DB_site->query_first("SELECT threadid FROM ".TABLE_PREFIX."thread WHERE postuserid='$userid' AND forumid='$forumid' LIMIT 0,1");
    if (
$posted['threadid'])
        return 
true;
    else
        return 
false;    

First, is the function correct and if so, what should my template conditional look like? right now it looks like this <if condition="$posted_in_forum"> but i have a strong feeling that's wrong

Can someone help me with this? Thanks!
Eric
Reply With Quote
  #7  
Old 02-11-2005, 12:17 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1) The function does what it is supposed to do
2) You can't use this function in Template conditionals
Reply With Quote
  #8  
Old 02-11-2005, 12:19 AM
Oreamnos's Avatar
Oreamnos Oreamnos is offline
 
Join Date: Dec 2004
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I realize i cant use it in a template conditional. But can i use the result of this function in a template conditional?
Reply With Quote
  #9  
Old 02-11-2005, 12:22 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes.
Calll it in a PHP file like

PHP Code:
$hasposted posted_in_forum($userid$forumid
and then use

HTML Code:
<if condition="$hasposted">
stuff here
</if>
(There is a way to make custom functions work in Template conditionals, but as this can be dangerous I won't recommend it)
Reply With Quote
  #10  
Old 02-11-2005, 12:39 AM
Oreamnos's Avatar
Oreamnos Oreamnos is offline
 
Join Date: Dec 2004
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i think we are getting closer.

I put this in my functions.php file:
PHP Code:
// ###################### Check if user posted Introductory thread #######################
function posted_in_forum($userid,$forumid) {
    global 
$DB_site$bbuserinfo;
    
$posted $DB_site->query_first("SELECT threadid FROM ".TABLE_PREFIX."thread WHERE postuserid='$userid' AND forumid='$forumid' LIMIT 0,1");
    if (
$posted['threadid'])
        return 
true;
    else
        return 
false;    
}


$hasposted posted_in_forum($bbuserinfo['userid'], 10); 
and this is my template conditonal:
HTML Code:
<if condition="$hasposted">
<tr>
<td class="vbmenu_option" align="left">Not Posted</td>
</tr>
<else />
<tr>
<td class="vbmenu_option" align="left">Posted</td>
</tr>
</if>
But still no luck... is it ok to have this $hasposted = posted_in_forum($bbuserinfo['userid'], 10); in my functions.php file? or should it go somewhere else?
Reply With Quote
Reply

Thread Tools
Display Modes

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 01:45 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.03989 seconds
  • Memory Usage 2,268KB
  • 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
  • (2)bbcode_html
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete