PDA

View Full Version : Help me please


vuiveclub
07-02-2008, 09:56 PM
Hi, I try to code some script but I dont know how to do that.

for ex,:
I have this 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
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,


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

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

Blindspot
07-03-2008, 11:26 PM
Hello, thank you for your answering.
But I need to use with this,


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

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

Dismounted
07-04-2008, 04:59 AM
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

// ################################################## ###################
// ############## 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, $perpage, 100, $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:

$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/showthread.php?p=1568288#post1568288

thanks Dis :)

Dismounted
07-07-2008, 06:15 AM
The category name is $cat_name...