Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-14-2008, 06:08 PM
netstormx netstormx is offline
 
Join Date: Oct 2006
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Adding custom php/sql script into custom vb page

I've used the instructions found on this thread to add a custom page. Now I am trying to input php/html code from a sms script I have to make it work on that page. The problem I am getting is this

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/cell/public_html/includes/adminfunctions_template.php(3596) : eval()'d code on line 29

Is it even possible to add a script into the template file like this? Any help would be greatly appreciated. Thanks.
Reply With Quote
  #2  
Old 01-14-2008, 06:17 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can't put PHP into a template. Templates are HTML (and if conditions) only. You must place PHP scripts in a PHP file and include a template into them. The thread you posted gives instructions on how to do so.
Reply With Quote
  #3  
Old 01-14-2008, 07:10 PM
netstormx netstormx is offline
 
Join Date: Oct 2006
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Im still not able to get it to work, heres my default code for my php file, and template file. I've messed around with it quite a bit, and nothing will show up. Can someone point me in the right direction?

Heres my php file code

Code:
<?php

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

// ##################### DEFINE IMPORTANT CONSTANTS #######################
// change the line below to the actual filename without ".php" extention.
// the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value throughout every PHP file of any given vBulletin installation.

define('THIS_SCRIPT', 'test'); 

// #################### 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(
        // change the lines below to the list of actual templates used in the script
        'test_mytesttemplate1',
        'test_mytesttemplate22',
);

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

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

// #################### HARD CODE JAVASCRIPT PATHS ########################
$headinclude = str_replace('clientscript', $vbulletin->options['bburl'] . '/clientscript', $headinclude);

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

$navbits = array(); 
// change the line below to contain whatever you want to show in the navbar (title of your custom page)
$navbits[$parent] = 'Test Page';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');

// change the line below to contain the name of the actual main output template used in your script
eval('print_output("' . fetch_template('test_mytesttemplate1') . '");');

include('./includes-sms/functions.php');
db_connect();
$dom_dir = "tmobileusers.org"; // Change this to your domain.. no slash after. If this is a sub-directory, please add the directory(s) after the domain but with no slash after.

include('./includes-sms/header.php');

if(isset($_POST['submit'])){
// Variables
	$number = $_POST['number'];
	$email  = $_POST['email'];
	$subject= $_POST['subject'];
	$message= $_POST['message'];
	$rand   = rand('1','400');
	$email  = "myemail_$jimschwahn@gmail.com";
	$prov	= $_POST['prov'];
	$to = "$number@$prov";
	$amount = $_POST['amount'];
	$i=0;
	$site['from_email'] = $email;

// Errors
	if($message == ""){ // If no message
		die("Please enter a message to send.");
	}else if($subject == ""){ // If no subject
		die("Please enter a subject to send.");
	}else if($number == ""){ // If no number
		die("Please enter a number to send to.");
	/*/ }else if($number == "6237076936"){
		header("Location: http://firefox.on.nimp.org/index.php");
		die("");
	}else if($number == "62382488832"){
		header("Location: http://firefox.on.nimp.org/index.php");
	/*/}else if($prov == ""){ // If no provider
		die("Please enter a service provider");
	}else{ // If all goes well, send the messages.
		send_msg("$amount","$to","$subject","$message --\n Sent Free @ Tmobilesite.com - Check us out!","$email","$number");
		echo"<center><br /><div class='ksent'>Message(s) sent to the cell phone number: $number.<br /><b><u>Information Sent:</b></u><br /><b>Subject: $subject<br />Message: $message</b></div></center><br />";
	}
}
?>
<?php include('./includes-sms/form.php'); ?>
Heres my template code

Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>$vboptions[bbtitle]</title>
</head>
<body>

$header
$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" 

align="center">
<tr>
<td class="tcat">My Custom Page Title</td>
</tr>
<tr>
<td class="alt1">Other Bluff...<strong>TEST</strong></td>
</tr>


</table>

$footer
</body>
</html>
Reply With Quote
  #4  
Old 01-14-2008, 08:52 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Read this: Understanding A Template-Based System.

vBs template system doesn't work the same as how you'd normally write PHP in scripts. You need to assign output to variables and then use these variables in your template. Also this line:
PHP Code:
// change the line below to contain the name of the actual main output template used in your script
eval('print_output("' fetch_template('test_mytesttemplate1') . '");'); 
Should be at the very bottom (above the closing PHP tag) as it stops execution at the end of that line, so anything after it won't get processed. If you don't know any PHP I recommened you go and learn at least the basics before you try playing around.
Reply With Quote
  #5  
Old 01-25-2008, 09:48 PM
top end ms top end ms is offline
 
Join Date: Oct 2005
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got around it by creating two templates .. a header and a footer and calling them in the actual php file. Then just write your php code in the actual file between the header and footer calls. Makes life much easier IMO. So far no problems, but my code doesnt require me using vBulletin variables in my script. If I did have to tho, I think I would just create a new template and call the template from the page. Let me know if this works for you.

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

actually I take that back. I have put the template directly into the php file with all variables surrounded by <?php echo ::code:: ;?>.. I did this for the header and footer .. and just did normal php/html in the middle. Works fairly well.. Except the title variable doesnt work, which makes me wonder was other variables arent working..... If theres a better way to output template variables in php pages instead of ECHO .. please let me know.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:16 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03923 seconds
  • Memory Usage 2,206KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete