vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Cutom Field on Custom Page?? (https://vborg.vbsupport.ru/showthread.php?t=216711)

Dismounted 06-29-2009 04:38 AM

Quote:

Originally Posted by cono1717 (Post 1837790)
Basically I want to make the following

HTML Code:


<if condition="$auinfo[field7] <(is less than) $conditional">
Post count not met
</if>

PHP Code:

if ($auinfo['field7'] == "I don\'t have a package")
{
    
$conditional 0;
} else if (
$auinfo['field7'] == "SHARED A")
{
    
$conditional 5;
} else if (
$auinfo['field7'] == "SHARED B")
{
    
$conditional 15;
} else if (
$auinfo['field7'] == "SHARED C")
{
    
$conditional 20;
} else if (
$auinfo['field7'] == "SHARED D")
{
    
$conditional 20;
} else if (
$auinfo['field7'] == "RESELLER A")
{
    
$conditional 25;
}
 else if (
$auinfo['field7'] == "RESELLER B")
{
    
$conditional 75;
} else if (
$auinfo['field7'] == "RESELLER C")
{
    
$conditional 200;
}
 else if (
$auinfo['field7'] == "RESELLER D")
{
    
$conditional 200;
} else if (
$auinfo['field7'] == "Custom/Other")
{
    
$conditional 00;



You're trying to do a comparison with a text field and a numeric field? :confused:

cono1717 06-29-2009 06:37 PM

No in the php file I was trying to set a number to the variable $conditional then use the HTML code to see if the number is lessthan the required number

Dismounted 06-30-2009 04:50 AM

And the problem is that $conditional currently does not contain anything, right?

cono1717 06-30-2009 10:45 AM

I think so, if you go to http://www.geekstep.com/activity.php?styleid=19 you will see that the column "posts required" is not showing any numbers which means that the action required field cannot function.

@Cryo :- Your suggestion did not work since it is a custom template not the postbit.

cono1717 07-01-2009 11:45 AM

Anymore suggestions please?

cono1717 07-02-2009 11:58 AM

Sorry will have to bump again I really need this please.

Lynne 07-02-2009 02:19 PM

Quote:

Originally Posted by cono1717 (Post 1841372)
Sorry will have to bump again I really need this please.

You've made several changes since you first posted your code. Why don't you post exactly what your code and template currently is now so we don't have to look back and try to figure it out.

cono1717 07-02-2009 04:04 PM

Ok here is the activity.php file.

PHP Code:

<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''activity');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('ACTIVITY','ACTIVITY_bits''ACTIVITY_mbits''ACTIVITY_ybits''MEMBERINFO''memberinfo_profilefield');

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

if(empty($_REQUEST['do']))
{

    
// sanitize the variables myself
    
if(empty($_REQUEST['m']))
    {
        
$month vbdate('n');
        
$monthliteral vbdate('F');
    }
    else
    {
        
$month intval($_REQUEST['m']);
        
$monthliteral $months["$_REQUEST[m]"];
    }
    
    if(empty(
$_REQUEST['y']))
    {
        
$year vbdate('Y');
    }
    else
    {
        
$year intval($_REQUEST['y']);
    }

    
// generate months dropdown
    
$months = array(
        
=> 'January',
        
=> 'February',
        
=> 'March',
        
=> 'April',
        
=> 'May',
        
=> 'June',
        
=> 'July',
        
=> 'August',
        
=> 'September',
        
10 => 'October',
        
11 => 'November',
        
12 => 'December'
    
);
    
    foreach(
$months AS $mkey => $mval)
    {
        if(
$mkey == $month)
        {
            
$checked ' selected="selected"';
        }
        eval(
'$mbits .= "' fetch_template('ACTIVITY_mbits') . '";');
        unset(
$checked);
    }
    
    
// generate years dropdown
    
for($i intval(vbdate('Y')); $i intval(vbdate('Y')) + 4$i++)
    {
        if(
$i == $year)
        {
            
$checked2 ' selected="selected"';
        }
        eval(
'$ybits .= "' fetch_template('ACTIVITY_ybits') . '";');
        unset(
$checked2);
    }            
    
    
// important cutoff data
    
$cutoffstart gmmktime(000$month1$year);
    
$cutoffend gmmktime(000$monthvbdate('t'$cutoffstart), $year);
    
    
//echo $cutoffstart . '=' . TIMENOW;
    
    
if($cutoffstart TIMENOW)
    {
        eval(
standard_error('This date is in the future. You cannot select it. Go back and select antoher.'));    
    }
    
    
// limit our records
    
$limit 30000;    

    
// run query
$getusers $vbulletin->db->query("
    SELECT COUNT(p.postid) AS total, p.userid, u.username, u.joindate, f.field7
    FROM " 
TABLE_PREFIX "post AS p
    LEFT JOIN " 
TABLE_PREFIX "user AS u USING (userid)
    LEFT JOIN " 
TABLE_PREFIX "userfield AS f USING (userid)
    WHERE p.dateline > 
$cutoffstart
        AND p.dateline < 
$cutoffend
    GROUP BY userid
    ORDER BY total DESC
    LIMIT 
$limit
"
);  
    
    
$c 0;
    while(
$auinfo $db->fetch_array($getusers))
    {
        
$c++;
        
$auinfo['joindate'] = vbdate($vbulletin->options['dateformat'], $auinfo['joindate'], true);
        eval(
'$userbits .= "' fetch_template('ACTIVITY_bits') . '";');    

    }

    
$navbits construct_navbits(array('' => 'Activity Statistics'));
    eval(
'$navbar = "' fetch_template('navbar') . '";');
    eval(
'$aufield7 = "' fetch_template('postbit') . '";');
    eval(
'print_output("' fetch_template('ACTIVITY') . '");');    
}


if (
$auinfo['field7'] == "I don\'t have a package")
{
    
$conditional 0;
} else if (
$auinfo['field7'] == "SHARED A")
{
    
$conditional 5;
} else if (
$auinfo['field7'] == "SHARED B")
{
    
$conditional 15;
} else if (
$auinfo['field7'] == "SHARED C")
{
    
$conditional 20;
} else if (
$auinfo['field7'] == "SHARED D")
{
    
$conditional 20;
} else if (
$auinfo['field7'] == "RESELLER A")
{
    
$conditional 25;
}
 else if (
$auinfo['field7'] == "RESELLER B")
{
    
$conditional == 75;
} else if (
$auinfo['field7'] == "RESELLER C")
{
    
$conditional == 200;
}
 else if (
$auinfo['field7'] == "RESELLER D")
{
    
$conditional 200;
} else if (
$auinfo['field7'] == "Custom/Other")
{
    
$conditional 00;
}

?>

Here is the ACTIVITY template

HTML Code:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>$vboptions[bbtitle] - Activity Statistics</title>
</head>
<body>
$header
$navbar
<div align="center">
<form action="activity.php" method="get">
<strong>Choose another timeframe:</strong><br />
<select name="m">$mbits</select> <select name="y">$ybits</select> <input type="submit" name="submit" value="Go" />
</form>
</div>
<br />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
        <td class="tcat" colspan="6">
                Activity Statistics for $monthliteral
        </td>
</tr>
<tbody>
        <tr>
                <td class="thead">Rank</td>
                <td class="thead">Username</td>
                <td class="thead">Current Package</td>
                <td class="thead">Posts This Month</td>
                <td class="thead">Posts Required</td>
                <td class="thead">Action Needed?</td>

        </tr>
$userbits
</tbody>


</table>
<br /><center>
$vbphrase[accopy]
</center><br />
$footer

</body>
</html>

Here is the ACTIVITY_bits template (incase you need it)

HTML Code:

<tr>
                <td class="alt1">$c</td>
                <td class="alt2"><a href="member.php?$session[sessionurl]u=$auinfo[userid]">$auinfo[username]</a>
                <td class="alt1">$auinfo[field7]</td>
                <td class="alt2">$auinfo[total]</td>
                <td class="alt1">$conditional</td>
</tr>

They are the only templates that I use in the whole system.

Lynne 07-02-2009 10:08 PM

You've evaled your ACTIVITY_bits template before you've done all the php to define the variable $conditional. You need to define $conditional before you eval the template otherwise the information isn't available to you in that template.

cono1717 07-03-2009 12:11 PM

Ok I have moved the code and still nothing, here is the new activity.php file

PHP Code:

<?php



// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''activity');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('ACTIVITY','ACTIVITY_bits''ACTIVITY_mbits''ACTIVITY_ybits''MEMBERINFO''memberinfo_profilefield');

// pre-cache templates used by specific actions
$actiontemplates = array();


// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################


if(empty($_REQUEST['do']))
{

    
// sanitize the variables myself
    
if(empty($_REQUEST['m']))
    {
        
$month vbdate('n');
        
$monthliteral vbdate('F');
    }
    else
    {
        
$month intval($_REQUEST['m']);
        
$monthliteral $months["$_REQUEST[m]"];
    }
    
    if(empty(
$_REQUEST['y']))
    {
        
$year vbdate('Y');
    }
    else
    {
        
$year intval($_REQUEST['y']);
    }

    
// generate months dropdown
    
$months = array(
        
=> 'January',
        
=> 'February',
        
=> 'March',
        
=> 'April',
        
=> 'May',
        
=> 'June',
        
=> 'July',
        
=> 'August',
        
=> 'September',
        
10 => 'October',
        
11 => 'November',
        
12 => 'December'
    
);
    
    foreach(
$months AS $mkey => $mval)
    {
        if(
$mkey == $month)
        {
            
$checked ' selected="selected"';
        }
        eval(
'$mbits .= "' fetch_template('ACTIVITY_mbits') . '";');
        unset(
$checked);
    }
    
    
// generate years dropdown
    
for($i intval(vbdate('Y')); $i intval(vbdate('Y')) + 4$i++)
    {
        if(
$i == $year)
        {
            
$checked2 ' selected="selected"';
        }
        eval(
'$ybits .= "' fetch_template('ACTIVITY_ybits') . '";');
        unset(
$checked2);
    }            
    
    
// important cutoff data
    
$cutoffstart gmmktime(000$month1$year);
    
$cutoffend gmmktime(000$monthvbdate('t'$cutoffstart), $year);
    
    
//echo $cutoffstart . '=' . TIMENOW;
    
    
if($cutoffstart TIMENOW)
    {
        eval(
standard_error('This date is in the future. You cannot select it. Go back and select antoher.'));    
    }
    
    
// limit our records
    
$limit 30000;    

    
// run query
$getusers $vbulletin->db->query("
    SELECT COUNT(p.postid) AS total, p.userid, u.username, u.joindate, f.field7
    FROM " 
TABLE_PREFIX "post AS p
    LEFT JOIN " 
TABLE_PREFIX "user AS u USING (userid)
    LEFT JOIN " 
TABLE_PREFIX "userfield AS f USING (userid)
    WHERE p.dateline > 
$cutoffstart
        AND p.dateline < 
$cutoffend
    GROUP BY userid
    ORDER BY total DESC
    LIMIT 
$limit
"
);  
//Let's define those variables

if ($auinfo['field7'] == "I don\'t have a package")
{
    
$conditional 0;
} else if (
$auinfo['field7'] == "SHARED A")
{
    
$conditional 5;
} else if (
$auinfo['field7'] == "SHARED B")
{
    
$conditional 15;
} else if (
$auinfo['field7'] == "SHARED C")
{
    
$conditional 20;
} else if (
$auinfo['field7'] == "SHARED D")
{
    
$conditional 20;
} else if (
$auinfo['field7'] == "RESELLER A")
{
    
$conditional 25;
}
 else if (
$auinfo['field7'] == "RESELLER B")
{
    
$conditional == 75;
} else if (
$auinfo['field7'] == "RESELLER C")
{
    
$conditional == 200;
}
 else if (
$auinfo['field7'] == "RESELLER D")
{
    
$conditional 200;
} else if (
$auinfo['field7'] == "Custom/Other")
{
    
$conditional 00;
}
    
    
$c 0;
    while(
$auinfo $db->fetch_array($getusers))
    {
        
$c++;
        
$auinfo['joindate'] = vbdate($vbulletin->options['dateformat'], $auinfo['joindate'], true);
        eval(
'$userbits .= "' fetch_template('ACTIVITY_bits') . '";');    

    }

    
$navbits construct_navbits(array('' => 'Activity Statistics'));
    eval(
'$navbar = "' fetch_template('navbar') . '";');
    eval(
'$aufield7 = "' fetch_template('postbit') . '";');
    eval(
'print_output("' fetch_template('ACTIVITY') . '");');    
}




?>

--------------- Added [DATE]1246626817[/DATE] at [TIME]1246626817[/TIME] ---------------

If it is easier I could do it in the template system but I don't know if that would be possible


All times are GMT. The time now is 02:11 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.01535 seconds
  • Memory Usage 1,899KB
  • 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
  • (3)bbcode_html_printable
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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