Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2006, 06:16 PM
whitejeep whitejeep is offline
 
Join Date: May 2006
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default The fetch_template how do I test to see if the templete exist in PHP

In the following PHP code

I want to test the what the templatecache or the database
or both how do it in PHP of the line below.

$dummy = fetch_template('groups_index_listbit'); // returns a string
echo $dummy;

What is actualy being returned here ?
string fetch_template (string $templatename);
where
string $templatename: Name of template to be fetched

So How do I debug this and echo the values correctly above here.

Note: This works fine here and I can echo the values in the actaul array.

echo $groupslist[id];
echo "<br>";
echo $groupslist[groupname];
echo "<br>";

eval('$groupslist .= "' . fetch_template('groups_index_listbit') . '";');

Why does the line above need the . dot operator is it becuse it is a string type being returned ?

How does the eval work in the above case in vbullutin please explain. THANKS
Reply With Quote
  #2  
Old 05-20-2006, 06:46 AM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The groups_index_listbit template is a template that will be looped several times. When you add the concatenating assignment operator ('.='), this will allow you to call this template over and over again untill the MySQL query runs out of data.

For example: If you wanted to echo every username in your database, you would create a mysql query telling the database to give you all usersname is the user row. And echo everyname. Heres how we would do this.

The $query variable holds the mysql commands.
Code:
$query = $db->query_read("
        SELECT username
        FROM " . TABLE_PREFIX . "user
");
This next code is creating an array. Each and every row of the usertable will be instered into the $user variable. The while() function will loop this array. Read the highlited comments in the code below...
Code:
while ($user = $db->fetch_array($templates))
{
        //now you are able to echo the username over and over again. You could simply add this...
        echo $user['username']; //remember $user is the array, and the "username" is the row you want to echo, you can only echo the rows you have selected from your query above. (SELECT username FROM...etc...)

        // if you want to use a template to echo the information, you wouldn't want to create 500 templates just because you have 500 usernames in the database. Hell no, you would simply add one BIT template and use the following code...
        eval('$mynewtemp .= "' . fetch_template('username_templatebit') . '";');

        // now, in your template where you want the results to show, you would add $mynewtemp anywhere in your main template code.
        // in the template called username_templatebit you would use the user[username] var to echo echo username

}
Hope this helps. It's late and explaing something is hard right now. I've had a couple of drinks.
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 03:53 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.03242 seconds
  • Memory Usage 2,173KB
  • 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_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)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