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

Reply
 
Thread Tools Display Modes
  #1  
Old 09-22-2006, 03:34 PM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Parsing values in phrases

How do you parse values in phrases? I'd like to get the userid. In the phrase searchnoresults When doing a finduser if there are no results I added in the phrase to go somewhere else but I can't get the userid

PHP Code:
href="/forums/dothis.php?do=getuser&u={$vbulletin->GPC[userid]}">mypage</a>. 
Reply With Quote
  #2  
Old 09-22-2006, 04:31 PM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not quite sure if I understand what you're trying to do. Want to add a variable to a phrase which will be parsed and replaced with a userid?

You could use for example sprintf()

PHP Code:
$phrase 'href="/forums/dothis.php?do=getuser&u=%d">mypage</a>.'

$parsed sprintf($phrase$vbulletin->GPC['userid']); 
Reply With Quote
  #3  
Old 09-22-2006, 04:44 PM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nico_swd
Not quite sure if I understand what you're trying to do. Want to add a variable to a phrase which will be parsed and replaced with a userid?

You could use for example sprintf()

PHP Code:
$phrase 'href="/forums/dothis.php?do=getuser&u=%d">mypage</a>.'
 
$parsed sprintf($phrase$vbulletin->GPC['userid']); 
that's for the search.php?
what do i put in phrase?
Reply With Quote
  #4  
Old 09-22-2006, 04:51 PM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

%d - This will be replaced with the second argument of the sprintf() function. (If numeric in this case)

http://us2.php.net/manual/en/function.sprintf.php
Reply With Quote
  #5  
Old 09-22-2006, 05:14 PM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well thank you but that does not work. I tried many options.

Basically what I want to do is when someone does a search to find all posts by a user, I altered the searchnoresults phrase with a link to redirect them somewhere else. So one thing I tried to simplify it was

PHP Code:
 if (empty($forumids))
 {
  
$phrase "%d";
  
$parsed sprintf($phrase$vbulletin->GPC['userid']); 
  eval(
standard_error(fetch_error('searchnoresults'$displayCommon), ''false));
 } 
and in search no results I did ?u=%d
I also tried {%d} and
{1}
Reply With Quote
  #6  
Old 09-22-2006, 07:27 PM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, I get you now. Try this.

PHP Code:
eval(standard_error(construct_phrase(fetch_error('searchnoresults'), $vbulletin->GPC['userid']))); 
The trick is in the construct_phrase() function and numbers between brackets.

Example.
PHP Code:
construct_phrase(input textargument 1argument 2argument 3,...) 
input text is the pharse which you can fetch using fetch_error('searchnoresults'). {1} in the phrase will be replaced with argument 1, {2} will be replaced with argument 2, etc...
Reply With Quote
  #7  
Old 09-22-2006, 10:12 PM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks again... but that does not work.
I also tried to put $vbphrase

PHP Code:
eval(standard_error(construct_phrase(fetch_error($vbphrase['searchnoresults']), $vbulletin->GPC['userid']))); 
Reply With Quote
  #8  
Old 09-22-2006, 10:28 PM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You have to define the vriable userid first.

PHP Code:
$vbulletin->input->clean_array_gpc('r', array(
    
'userid' => TYPE_UINT
)); 
I've tested my code and it works for me.
Reply With Quote
  #9  
Old 09-22-2006, 10:29 PM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It is defined
Reply With Quote
  #10  
Old 09-22-2006, 10:37 PM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Weird. This is how I tested it.
PHP Code:
<?php

include('./global.php');


$vbulletin->input->clean_array_gpc('r', array(
    
'userid' => TYPE_UINT
));

eval(
standard_error(construct_phrase(fetch_error('searchnoresults'), $vbulletin->GPC['userid'])));  

?>
My searchnoresults phrase looks like this
Code:
Sorry - no matches. Please try some different terms. 

{1}
{1} will be replaced with the userid I enter in the URL.

Is the source in the clean_array_gpc() function set right? (First argument)

g = $_GET
p = $_POST
r = $_REQUEST
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 07:52 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.04598 seconds
  • Memory Usage 2,272KB
  • 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
  • (1)bbcode_code
  • (9)bbcode_php
  • (1)bbcode_quote
  • (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