vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Parsing values in phrases (https://vborg.vbsupport.ru/showthread.php?t=127269)

Lionel 09-22-2006 02:34 PM

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>. 


nico_swd 09-22-2006 03:31 PM

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']); 


Lionel 09-22-2006 03:44 PM

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?

nico_swd 09-22-2006 03:51 PM

%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

Lionel 09-22-2006 04:14 PM

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}

nico_swd 09-22-2006 06:27 PM

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...

Lionel 09-22-2006 09:12 PM

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']))); 


nico_swd 09-22-2006 09:28 PM

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.

Lionel 09-22-2006 09:29 PM

It is defined

nico_swd 09-22-2006 09:37 PM

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


All times are GMT. The time now is 07:43 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.01771 seconds
  • Memory Usage 1,753KB
  • 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
  • (1)bbcode_code_printable
  • (9)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete