Log in

View Full Version : help needed with template installer script


Dep
01-28-2005, 01:44 PM
ok im just starting to work this out. i got it to place the templates onto the style. Just wondering how do i make the templates go into there own sub heading rather then having them all listed right at the top of the template section in admin

my script so far looks like

<?php

error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS', 1);

require_once('./global.php');
require_once('./includes/adminfunctions_template.php');

$scriptname = 'BETA';
$version = '0.1';

print_cp_header('dep Templater ' . $scriptname . ' Install', '', '<style type="text/css">
<!--
.redalert
{
background: #FF0000;
color: #000000;
}
-->
</style>');

if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'home';
}

// ##################### Make Template Function #####################
function insert_template($name, $content)
{
global $DB_site;

$template = compile_template($content);

$DB_site->query("DELETE FROM " . TABLE_PREFIX . "template WHERE title = '$name' AND styleid = '-1'");

$DB_site->query("INSERT INTO " . TABLE_PREFIX . "template (templateid, title, template, template_un, styleid, templatetype, dateline, username, version) VALUES (NULL, '$name', '" . addslashes($template) . "', '" . addslashes($content) ."', '-1', 'template', '" . time() . "', 'dep', '3.0.6')");

echo '<span class="smallfont">Created Template - ' . $name . '</span><br />';
}

// ####################### Templates ################################
$maintemplates = array(
'template_title_1' =>
'template text',

'template_title_2' =>
'template text'

);

// #################### Main Welcome Page ########################
if ($_REQUEST['do'] == 'home')
{

echo '<p><b>Welcome to dep template installler.</b><br /><br />';

echo '<a href="?do=templates&amp;only=1"><b>Click here to install ONLY the templates <font size="1"></font> --&gt;</b></a>';

}

// ##################### Insert Templates #########################
if ($_REQUEST['do'] == 'templates')
{

foreach ($maintemplates AS $name => $content)
{
insert_template($name, $content);
}

{
build_all_styles(0, 0, iif($_REQUEST['only'], 'template_install.php' . '?do=finished'));
}
}

// ############################ Last Step #############################
if ($_REQUEST['do'] == 'finished')
{

echo 'dep ' . $scriptname . ' installation complete!<br /><br />';

echo '<font size="3" color="red"><b>You should now delete this file from your admincp directory.<br />Leaving this file here could be a security risk!</b></font><br /><br />';

echo '<a href="index.php"><b>Click here to log into your Admin CP. --&gt;</b></a><br />';

}

?>

many thanks in advance

Jolten
01-28-2005, 06:19 PM
Categorizing the templates into their own group requires an edit to the includes/adminfunctions_tempalte.php file. It's not a database configuration thing.

Dep
01-28-2005, 07:17 PM
just so ive got this right id goto

/forum/includes/adminfunctions_template.php

Find:
'aaa' => 'AAA Old Backup'

Above that Add:
'Tester' => 'Testing Templates',

so all the templates i add must start with
Tester_

Jolten
01-29-2005, 05:02 AM
yup That will work. Templates should start with Tester the _ won't be mandatory but it's helpful for visual reference sometimes.

Dep
01-29-2005, 11:45 AM
great thanks alot