PDA

View Full Version : Strings in templates?


mrBjordal
08-08-2007, 11:19 AM
Hi

I am trying to add my own vBulletin-powered pages, but I am new to php and vBulletin.

So far I have created a new file "job1.php" and added a new template at AdminCP. So far so good. Now I want to add more pages like "job2.php", "job3.php", on so on.

File "job1.php"
<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'job1'); // 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(
'job1',
);

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

);

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

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

$navbits = array();
$navbits[$parent] = 'Vacant Jobs';

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

?>


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

$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">Title</td>
</tr>
<tr>
<td class="alt1">Text</td>
</tr>
</table>

$footer
</body>
</html>



How do I add variables in the php-file when using the same template for all files? All the php-files does have different titles. I am used to ".asp"-programming. Can I add strings like this and how is the php code for strings:

In the page "job1.php"
#1) in the <title> field: strTitle = "Reception/Office Assistant"
#2) in the <body> field: strEmployer = "Opera Software ASA"

In the page "job2.php"
#1) in the <title> field: strTitle = "Tender Coordinator"
#2) in the <body> field: strEmployer = "FMC Kongsberg Subsea AS"


My two questions:
Question #1) How do I code this in the php files?
Question #2) How do I code this in the template?


Anyone?
:o

Opserty
08-08-2007, 11:43 AM
Variables are coded like this in php:

$variable = 'Your String';

In vBulletin it is possible to place variables in templates so you could write $strTitle in your template and then change it accordingly for each php file.

Is there a major difference between each of the jobX.php files?

You can create subpages within just a single job.php page, see this:
See the Creating Subpages section: https://vborg.vbsupport.ru/showthread.php?t=98009

Then you can access each section using the url http://anydomain.com/job.php?do=1 or something like that.

mrBjordal
08-08-2007, 01:43 PM
Thank you very much :)