Thread: Idiot Admin PHP
View Single Post
  #7  
Old 03-03-2014, 09:39 PM
ajhalls ajhalls is offline
 
Join Date: Nov 2006
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok so, I might be close. Looking at a page on my site I came up with the minimal code needed is this:
Code:
<?php
define('THIS_SCRIPT', 'Simple Page');
$specialtemplates = array();
$phrasegroups = array();
$globaltemplates = array('shell_blank');
require_once('./global.php');
// ##################  content ###################
$html = "Type anything you want here";

// ##################   build   ####################
$navbits[] = 'Simple Page';
$navbits = construct_navbits($navbits);
$navbar = render_navbar_template($navbits);


$templater = vB_Template::create('shell_blank');
$templater->register_page_templates();
$templater->register('html', $html);
$templater->register('navbar', $navbar);
print_output($templater->render());
?>
And that works great for a basic HTML setup, but when I tried including a jquery grid I don't know a way to have it just execute the main render command and assign it to the $html variable so it is put in the right spot. The output of all the other code looks like this: http://workshopwarrior.com/grid/suppliers.php which is supposed to be in the template.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <link rel="stylesheet" type="text/css" media="screen" href="./themes/redmond/jquery-ui-custom.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="./themes/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="./themes/ui.multiselect.css" />
    <style type="text">
        html, body {
        margin: 0;			/* Remove body margin/padding */
    	padding: 0;
        overflow: hidden;	/* Remove scroll bars on browser window */
        font-size: 75%;
        }
    </style>
	<script src="./js/jquery.js" type="text/javascript"></script>
    <script src="./js/i18n/grid.locale-en.js" type="text/javascript"></script>
	<script type="text/javascript">
	$.jgrid.no_legacy_api = true;
	$.jgrid.useJSON = true;
	</script>
    <script src="./js/jquery.jqGrid.min.js" type="text/javascript"></script>
    <script src="./js/jquery-ui-custom.min.js" type="text/javascript"></script> 

<?php
define('THIS_SCRIPT', 'Supplier Grid');

$specialtemplates = array();

$phrasegroups = array();

$globaltemplates = array('shell_blank');

require_once('./global.php');
// ##########################  content ##############################
ini_set("display_errors",1);

require_once '/var/www/workshopwarrior.com/grid/config.php';
// include the driver class
require_once "/var/www/workshopwarrior.com/grid/php/jqGridPdo.php";
// include the jqGrid Class
require_once "/var/www/workshopwarrior.com/grid/php/jqTreeGrid.php";


// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqTreeGrid instance
$tree = new jqTreeGrid($conn);

$tree->SelectCommand = "SELECT * FROM suppliers";

// set the table and primary key
$tree->table = 'suppliers';
$tree->setPrimaryKeyId('id');
// set tree model and table configuration
$tree->setTreeModel('adjacency');
$tree->setTableConfig(array('id'=>'id', 'parent'=>'parent_id'));


// autoloading is disabled
$tree->autoLoadNodes = false;
// collapse all nodes (default)
$tree->expandAll = true;
// show any error (if any ) from server
$tree->showError = true;

$tree->setColModel();

$tree->setUrl('treegrid.php');
$tree->dataType = 'json';

// Some nice setting
$tree->setColProperty('name',array("label"=>"<b>Name</b>", "width"=>470));
$tree->setColProperty('street',array("label"=>"Street Address", "width"=>270));
$tree->setColProperty('city',array("label"=>"City", "width"=>150, "align"=>"center"));
$tree->setColProperty('state',array("label"=>"State", "width"=>60, "align"=>"center"));
$tree->setColProperty('zip',array("label"=>"Zip", "width"=>70, "align"=>"center"));
$tree->setColProperty('phone',array("label"=>"Phone Number", "width"=>170, "align"=>"center"));
$tree->setColProperty('url',array("label"=>"Website", "width"=>370, "align"=>"center", "formatter"=>"link"));

// hide the not needed fields
$tree->setColProperty('id',array("hidden"=>true));
$tree->setColProperty('parent_id',array("hidden"=>true));
$tree->setColProperty('description',array("hidden"=>true));
$tree->setColProperty('category',array("hidden"=>true));
$tree->setColProperty('product',array("hidden"=>true));

// and finaly set the expand column and height to auto
$tree->setGridOptions(array(
	"ExpandColumn"=>"name",
	"height"=>'auto',
	"width"=>1100,
	"sortname"=>"id",
    "sortable"=>true,
	// allow automatic scrolling of the rows
	"scrollrows"=>true
	));
// enable key navigation
$tree->callGridMethod('#tree', 'bindKeys');
$tree->navigator = true;
$tree->setNavOptions('navigator', array("add"=>true,"edit"=>true, "del"=>true, "search"=>true, "excel"=>true));
$tree->renderTree('#tree', '#pager', true,null, null, true, true);
if($tree->oper == 'edit') {

	$data = $_POST;
	// $data is the posted data
	// do what you want with it
	$post_data = json_encode($data, JSON_FORCE_OBJECT);
	$json_data = "[";
	$json_data .= $post_data;
	$json_data .= "]";
	file_put_contents("json.txt", $json_data);
}

// build
$navbits[] = 'Supplier Grid';
$navbits = construct_navbits($navbits);
$navbar = render_navbar_template($navbits);


$templater = vB_Template::create('shell_blank');
$templater->register_page_templates();
$templater->register('html', $html);
$templater->register('navbar', $navbar);
print_output($templater->render());

?>
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01287 seconds
  • Memory Usage 1,799KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete