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

Reply
 
Thread Tools Display Modes
  #1  
Old 07-02-2008, 09:56 PM
vuiveclub vuiveclub is offline
 
Join Date: Dec 2006
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help me please

Hi, I try to code some script but I dont know how to do that.

for ex,:
I have this code:

PHP Code:
if ($_REQUEST['do'] == 'mypage')
{
    
$id $vbulletin->input->clean_gpc('r''id'TYPE_INT);

    
$mypages $db->query_first("SELECT * FROM " TABLE_PREFIX ."mypage WHERE id = $id");

    while(
$mypage $vbulletin->db->fetch_array(mypages))
    {
    
$mypage['field1'] = $mypage[field1];

    eval(
'$mytemp .= "' fetch_template('mytemp') . '";');
    }

}

    
$navbits = array();  
    
$navbits[$parents] = 'My page';
    
$navbits construct_navbits($navbits);
    eval(
'$navbar = "' fetch_template('navbar') . '";');
    eval(
'print_output("' fetch_template('mypage_home') . '");'); 
In my template 'mypage_home', I add $mypage[field1] it doesnt show anything. Shows only in template $mytemp if I add $mypage[field1]

Does anyone know how to do that it will show $mypage[field1] in template mypage_home ?

Sorry for my bad English, I dont know how to tell better


Thank you
Reply With Quote
  #2  
Old 07-03-2008, 06:39 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
if ($_REQUEST['do'] == 'mypage')
{
    
$id $vbulletin->input->clean_gpc('r''id'TYPE_UINT);
    
$mypage $vbulletin->db->query_first("
        SELECT *
        FROM " 
TABLE_PREFIX ."mypage
        WHERE id = 
$id
    "
);
}

$navbits = array();  
$navbits[$parent] = 'My page';
$navbits construct_navbits($navbits);

eval(
'$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('mypage_home') . '");'); 
Reply With Quote
  #3  
Old 07-03-2008, 06:26 PM
vuiveclub vuiveclub is offline
 
Join Date: Dec 2006
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello, thank you for your answering.
But I need to use with this,

PHP Code:
    while($mypage $vbulletin->db->fetch_array($mypages)) 
    { 
    
$mypage['field1'] = $mypage[field1]; 

    eval(
'$mytemp .= "' fetch_template('mytemp') . '";'); 
    } 
Reply With Quote
  #4  
Old 07-03-2008, 11:26 PM
Blindspot Blindspot is offline
 
Join Date: Oct 2004
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by vuiveclub View Post
Hello, thank you for your answering.
But I need to use with this,

PHP Code:
    while($mypage $vbulletin->db->fetch_array($mypages)) 

    
$mypage['field1'] = $mypage[field1]; 

    eval(
'$mytemp .= "' fetch_template('mytemp') . '";'); 

you dont need to assign it again as its already stored in the array you are fetching...

PHP Code:
while($mypage $vbulletin->db->fetch_array($mypages)) 
{
    eval(
'$mytemp .= "' fetch_template('mytemp') . '";'); 

Reply With Quote
  #5  
Old 07-04-2008, 04:59 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
if ($_REQUEST['do'] == 'mypage')
{
    
$id $vbulletin->input->clean_gpc('r''id'TYPE_UINT);
    
$mypage $vbulletin->db->query_first("
        SELECT *
        FROM " 
TABLE_PREFIX ."mypage
        WHERE id = 
$id
    "
);

    eval(
'$mytemp = "' fetch_template('mytemp') . '";'); 
}

$navbits = array();  
$navbits[$parent] = 'My page';
$navbits construct_navbits($navbits);

eval(
'$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('mypage_home') . '");'); 
You don't need a loop, you're only using query_first(), which will return the first result as an array.
Reply With Quote
  #6  
Old 07-05-2008, 06:09 PM
vuiveclub vuiveclub is offline
 
Join Date: Dec 2006
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can't tell you what I mean because I am too bad in English

But today I can show you what I need to do.

Please browser this page: http://www.mfgz.co.uk/forum/nmaps.php?do=cat&cat_id=1

You can see this ID category is 1 and category name is Site News (this is eval template)

Now I need some code which I can add that category name to <title> tag in output template.

The code of this script
PHP Code:
// #####################################################################
// ############## VIEWING CATEGORIES   ########################################
// #####################################################################
if ($do == 'cat')
{
$cat_id2 $vbulletin->input->clean_gpc('g''cat_id'TYPE_INT);
$cat_id3 $vbulletin->input->clean_gpc('p''cat_id'TYPE_INT);

    
$cat_id = (isset($cat_id2) ? trim($cat_id2) : (isset($cat_id3) ? trim($cat_id3) : ''));
    
    
// Count all log entries 
    
$news_count $db->query_first("SELECT COUNT(*) AS `news_count` FROM `" TABLE_PREFIX "nmaps_news` WHERE `auth_id`='" $vbulletin->userinfo['userid'] . "' ");  
    
    
// Make sure all these variables are cool 
    
sanitize_pageresults($news_count['news_count'], $pagenumber$perpage100$settings['max_stories']); 
    
    
// Default lower and upper limit variables 
    
$limitlower = ($pagenumber 1) * $perpage 1
    
$limitupper $pagenumber $perpage
    if (
$limitupper $news_count['news_count']) 
    { 
        
// Too many for upper limit 
        
$limitupper $news_count['news_count']; 
        if (
$limitlower $news_count['news_count']) 
        { 
            
// Too many for lower limit 
            
$limitlower $news_count['news_count'] - $perpage
        } 
    } 
    if (
$limitlower <= 0
    { 
        
// Can't have negative or null lower limit 
        
$limitlower 1
    }
    
    
$cat_query $vbulletin->db->query_read("SELECT * FROM " TABLE_PREFIX "nmaps_cats WHERE `cat_id`='$cat_id' LIMIT 1");
    while (
$cat_title $vbulletin->db->fetch_array($cat_query))
    {
        
$cat_name $cat_title['cat_name'];
    
        
$cat_stories $vbulletin->db->query_read("
                            SELECT news.*, author.* FROM " 
TABLE_PREFIX "nmaps_news as news 
                            LEFT JOIN " 
TABLE_PREFIX "user as author ON (author.userid = news.auth_id)
                            WHERE `cat_id`='
$cat_id' ORDER BY post_date DESC LIMIT " . ($limitlower 1) . ", $perpage"); 
        while (
$cat_news $vbulletin->db->fetch_array($cat_stories))
        {
            
$cat_news_story $cat_news['news_title'];
            
$news_id $cat_news['news_id'];
            
$cat_news_auth_id $cat_news['auth_id'];
            
$cat_news_auth $cat_news['username'];
            
$cat_news_message $cat_news['message'];
            
            
$date vbdate($vbulletin->options['dateformat'], $cat_news['post_date']);
            
$time vbdate($vbulletin->options['timeformat'], $cat_news['post_date']);
            
            
$pagenav construct_page_nav($pagenumber$perpage$news_count['news_count'], "$nmaps_file?" $vbulletin->session->vars['sessionurl'] . 'do=cat');
            
            eval(
'$pg_cat_bit .= "' fetch_template("nmaps_pg_cat_bit") . '";');
        }

            
$navbits = array();
            
$navbits["$nmaps_file"] = $nmaps_title
            
$navbits[$parent] = $vbphrase['nmaps_news']; 
            
$navbits construct_navbits($navbits); 
            eval(
'$navbar = "' fetch_template('navbar') . '";'); 
            
            eval(
'$left_col = "' fetch_template('nmaps_col_left') . '";');
            eval(
'$right_col = "' fetch_template('nmaps_col_right') . '";');
            eval(
'print_output("' fetch_template('nmaps_pg_cat') . '");');
        
    }

Reply With Quote
  #7  
Old 07-06-2008, 06:14 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just put the variable of the title into the template....
Reply With Quote
  #8  
Old 07-06-2008, 05:15 PM
vuiveclub vuiveclub is offline
 
Join Date: Dec 2006
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for your helping Dis.
But I tried to add $cat_news_story into the output template nmaps_pg_cat the title tag but it does not show.

nmaps_pg_cat template:
HTML Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>$vboptions[bbtitle] - $cat_news_story</title>
</head>
<body>

$header
$navbar

<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
	<tr>
		
		<if condition="$show_left_col == 'YES'">
		<td valign="top" width="$col_width_left">
			$left_col
		</td>
		<td valign="top" width="$col_spacer"><img alt="" src="$vboptions[bburl]/$vboptions[cleargifurl]" /></td>		
		</if>
		<td valign="top">	
		<table cellpadding="0" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"><tr><td>
		<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" width="100%" align="center" border="0">
		<thead><tr><td class="tcat" colspan="3"><span class="smallfont"><strong>Category: $cat_name</strong></span></td></tr></thead>
		<tr><td class="thead">Story</td><td class="thead">Author</td><td class="thead">Post Date</td></tr>
		$pg_cat_bit
		</table>

		<table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin-bottom:3px">
		<tr valign="bottom">
		<td class="smallfont">&nbsp;</td>
		<if condition="$pagenav"><td align="$stylevar[right]">$pagenav</td></if>
		</tr>
		</table>
		
		<img alt="" src="$vboptions[bburl]/$vboptions[cleargifurl]" />
		</td></tr></table>
		
		

		</td>
		<if condition="$show_right_col == 'YES'">
		<td valign="top" width="$col_spacer"><img alt="" src="$vboptions[bburl]/$vboptions[cleargifurl]" /></td>
		<td valign="top" width="$col_width_right">
			$right_col
		</td></if>
	</tr>
</table>



$footer
</body>
</html>
The original hack: https://vborg.vbsupport.ru/showthrea...88#post1568288

thanks Dis
Reply With Quote
  #9  
Old 07-07-2008, 06:15 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The category name is $cat_name...
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:21 AM.


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.07368 seconds
  • Memory Usage 2,331KB
  • Queries Executed 11 (?)
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_html
  • (7)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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_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