vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Help me please (https://vborg.vbsupport.ru/showthread.php?t=184233)

vuiveclub 07-02-2008 09:56 PM

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

Dismounted 07-03-2008 06:39 AM

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') . '");'); 


vuiveclub 07-03-2008 06:26 PM

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') . '";'); 
    } 


Blindspot 07-03-2008 11:26 PM

Quote:

Originally Posted by vuiveclub (Post 1566048)
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') . '";'); 



Dismounted 07-04-2008 04:59 AM

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.

vuiveclub 07-05-2008 06:09 PM

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') . '");');
        
    }



Dismounted 07-06-2008 06:14 AM

Just put the variable of the title into the template....

vuiveclub 07-06-2008 05:15 PM

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 :)

Dismounted 07-07-2008 06:15 AM

The category name is $cat_name...


All times are GMT. The time now is 09:40 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.01147 seconds
  • Memory Usage 1,827KB
  • 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_html_printable
  • (7)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete