The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Idiot Admin PHP
Ok, so I really hate the way the templates are handled with plugins / products and everything. I want to have a simple setup that I can use to add new pages to my site but it constantly seems so complicated.
Can't there be an easy way of just having a php page that says: Code:
<? include("./globals.php"); include("./header.php"); include("./navbar.php"); // Wow you can put anything you want here include("./footer.php"); ?> As a site administrator, I can't stand how hard it is to do version control in development. So much of what makes the site tick is in the database and tracking incremental changes so I /or my staff can find what was changed when and what might have broken things is pretty hard. If vB would implement something like above, I might actually be able to find php developers who don't have to deal with such a large learning curve, do subversion checkin / checkout and so much more. I have one great vBulletin developer that has been with me for years, but finding another has been miserable, and trying to learn it myself is even worse which is making me want to switch platforms. |
#2
|
||||
|
||||
<a href="https://vborg.vbsupport.ru/showthread.php?t=228112" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=228112</a>
|
#3
|
|||
|
|||
Thanks Lynne, I tried using that page to create the pages I wanted so I could do standard include(); I got the header to display, but couldn't get the header and navbar to work when I did:
<? include("./header.php"); include("./navbar.php"); ?> I created some templates called idiotadmin-header and idiotadmin-navbar and left the appropriate code in each. I tried this for header.php Code:
<?php // ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // #################### DEFINE IMPORTANT CONSTANTS ####################### define('THIS_SCRIPT', 'test'); define('CSRF_PROTECTION', true); // change this depending on your filename // ################### 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('idiotadmin-header', ); // pre-cache templates used by specific actions $actiontemplates = array(); // ######################### REQUIRE BACK-END ############################ // if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line // chdir ('/path/to/your/forums'); include('./global.php'); // ####################################################################### // ######################## START MAIN SCRIPT ############################ // ####################################################################### // ###### YOUR CUSTOM CODE GOES HERE ##### $pagetitle = 'idiotadmin-header'; // ###### NOW YOUR TEMPLATE IS BEING RENDERED ###### $templater = vB_Template::create('idiotadmin-header'); $templater->register_page_templates(); $templater->register('pagetitle', $pagetitle); print_output($templater->render()); ?> Code:
<?php define('THIS_SCRIPT', 'idiotadmin-navbar'); define('CSRF_PROTECTION', true); // change this depending on your filename // ################### 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('idiotadmin-navbar', ); // pre-cache templates used by specific actions $actiontemplates = array(); // ######################### REQUIRE BACK-END ############################ // if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line // chdir ('/path/to/your/forums'); include('./global.php'); // ####################################################################### // ######################## START MAIN SCRIPT ############################ // ####################################################################### $navbits = construct_navbits(array('' => 'idiotadmin-navbar')); $navbar = render_navbar_template($navbits); // ###### YOUR CUSTOM CODE GOES HERE ##### $pagetitle = 'idiotadmin-navbar'; // ###### NOW YOUR TEMPLATE IS BEING RENDERED ###### $templater = vB_Template::create('idiotadmin-navbar'); $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('pagetitle', $pagetitle); print_output($templater->render()); ?> |
#4
|
||||
|
||||
You're going about this in the wrong way. The template lynne gives you, gives you the ability to build vBulletin pages. The vbulletin way, you're coming at this kind of sideways, in a way we wouldn't normally do this
You really want something closer to this Code:
<?php define('THIS_SCRIPT', 'idiotadmin-pagex'); define('CSRF_PROTECTION', true); // change this depending on your filename // ################### 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( 'header', 'headinclude', 'navbar', 'mypage', 'footer' ); // pre-cache templates used by specific actions $actiontemplates = array(); // ######################### REQUIRE BACK-END ############################ // if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line // chdir ('/path/to/your/forums'); include('./global.php'); // ####################################################################### // ######################## START MAIN SCRIPT ############################ // ####################################################################### $navbits = construct_navbits(array('' => 'navbar')); $navbar = render_navbar_template($navbits); // ###### YOUR CUSTOM CODE GOES HERE ##### $pagetitle = 'MyPage'; // ###### NOW YOUR TEMPLATE IS BEING RENDERED ###### $templater = vB_Template::create('mypage'); $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('pagetitle', $pagetitle); print_output($templater->render()); Defines what the page is (this_script) Requires the needed phrases (we didn't do that here, since we're not using any) Registers the templates that will be used on the page, these global templates at the top tell the software it needs these templates, so the software will get them all, instead of having to query for each template. Requires the needed files. Set's up the navbar Set's up the page title betwee the navbar stuff, and the page output stuff, you can do a lot of things. But if you just want a custom page, this is it And then finally renders the templates. Next, you'd add a new template in the software, based on my example it'd be mypage, AdminCP > Styles & Templates >STyle Manager > Add New Template I've added the templates, and my custom html, stuff in it, and saved. Now it actually is a real page. I did this pretty hastily, so I think I didn't get the navibts part right, but that is something I think with some trial and effort, and help from others, you should be able to nail down. |
Благодарность от: | ||
TheLastSuperman |
#5
|
|||
|
|||
Thank you so much for your help. I "learned" PHP about 15 years ago and am trying to get better but it seems so complicated when I am trying to figure out which problems are from php and which are vbulletin related. I have been running my vbulletin site for about 8 years and it has been heavily modified by Tigga (from vbadvanced) for the last 4 years. As much as I love everything he does, occasionally though I want to do something myself and get stuck over and over till I give up and outsource it AGAIN and AGAIN.
What am I supposed to do when I want to run PHP code? For example I want to create a page that has this code in the content area: Code:
<?php ini_set("display_errors",1); require_once '../../../jq-config.php'; // include the driver class require_once ABSPATH."php/jqGridPdo.php"; // include the jqGrid Class require_once ABSPATH."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 nested_category"; // set the table and primary key $tree->table = 'nested_category'; $tree->setPrimaryKeyId('category_id'); // set tree model and table configuration $tree->setTreeModel('nested'); $tree->setTableConfig(array('id'=>'category_id', 'left'=>'lft', 'right'=>'rgt')); // autoloading nodes $tree->autoLoadNodes = false; // 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"=>"Name", "width"=>170)); $tree->setColProperty('price',array("label"=>"Price", "width"=>90, "align"=>"right")); $tree->setColProperty('qty_onhand',array("label"=>"Qty", "width"=>90, "align"=>"right")); $tree->setColProperty('color',array("label"=>"Color", "width"=>100)); // hide the not needed fields $tree->setColProperty('category_id',array("hidden"=>true,"index"=>"accounts.account_id", "width"=>50)); $tree->setColProperty('lft',array("hidden"=>true)); $tree->setColProperty('rgt',array("hidden"=>true)); $tree->setColProperty('level',array("hidden"=>true)); $tree->setColProperty('uiicon',array("hidden"=>true)); $tree->navigator = true; // Enable only deleting $tree->setNavOptions('navigator', array("excel"=>true,"add"=>true,"edit"=>true,"del"=>true,"view"=>true, "search"=>true)); // and finaly set the expand column and height to auto $tree->setGridOptions(array( "ExpandColumn"=>"name", "height"=>"auto", "sortname"=>"account_id" )); $tree->renderTree('#tree', '#pager', true,null, null, true, true); ?> <? include("./globals.php"); include("./header.php"); include("./navbar.php"); // Above code goes here include("./footer.php"); ?> It just seems like a really complicated way to produce pages with a lot of going back and forth. It is making more sense why I have pages with 3000-4000 lines of code written by my programmer with tons of [if ($_POST['do'] == xxx] statements just to avoid dealing with vbulletin. |
#6
|
||||
|
||||
The entire snipet of code I gave you, is an ENTIRE page, in php.
Look at forum.php or showthread.php .You don't require a header.php opr navbar.php. It is its own page, and does its own things. Step 1: create mypage.php file on server with my code as above. Step 2: Create a template called mypage in the style manager Step 3, pull up domain.com/mypage.php on your site/server |
#7
|
|||
|
|||
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()); ?> 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()); ?> |
#8
|
||||
|
||||
|
#9
|
|||
|
|||
Thank you so much RichieBoy, that is an awesome mod which I will definitely make use of. While fidgeting with everything, I finally found something that works:
Code:
<?php define('THIS_SCRIPT', 'Supplier Grid'); $specialtemplates = array(); $phrasegroups = array(); $globaltemplates = array('shell_blank'); require_once('./global.php'); // ########################## content ############################## ob_start(); include("/var/www/workshopwarrior.com/grid/suppliers.php"); $html = ob_get_contents(); ob_clean(); // 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()); ?> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|