Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Nov 2003
Posts: 482
Enthusiast
Enthusiast
Offline
Joined: Nov 2003
Posts: 482
love your mod, so i went and made it a little more flexible (note: this is for 7.3.1):

1) no need to edit templates/newpost.tpl, because i just append to $iconselect
2) language file wordlets changed to specify
a) valid forums for each template
b) valid user groups for each template
3) moved all of the markup building into scripts/newpost.inc.php

Mod follows:

open scripts/newpost.inc.php

find:
PHP Code
$iconselect = $html -> icon_select();
if (
$is_gallery) $iconselect = "";

add below it:
PHP Code
 // Check to see if there are any post templates applicable for this forum
$posttemplate = "";
if (
$ubbt_lang['NUM_POST_TEMPLATES']) {

// Gonna need to get the user groups
$sth = $dbh->do_query("SELECT GROUP_ID FROM {$config['TABLE_PREFIX']}USER_GROUPS WHERE USER_ID={$user['USER_ID']}");
$groups = array();
while(
$result = $dbh->fetch_array($sth)) {
$groups[] = $result['GROUP_ID'];
}

// Check to see if this forum is enabled for each template,
// then check if the group(s) apply
for($i=1; $i <= $ubbt_lang['NUM_POST_TEMPLATES']; $i++) {
$forumok = false;
if(
$ubbt_lang['SUB_'.$i.'_FORUMS'] != "") {
$forumok = in_array($Board,explode(',',$ubbt_lang['SUB_'.$i.'_FORUMS']));
} else {
$forumok = true;
}
// Forums good, now check on groups
if ($forumok) {
$groupok = false;
if(
$ubbt_lang['SUB_'.$i.'_GROUPS']) {
$pulldowngroups = explode(',',$ubbt_lang['SUB_'.$i.'_GROUPS']);
foreach(
$pulldowngroups as $g) {
if (
in_array($g,$groups)) {
$groupok = true;
}
}
} else {
$groupok = true;
}
}
// Add to template, if we have something
if ($forumok and $groupok) {
// 1st time thru - add the header crapola
if ($posttemplate == '') {
$posttemplate = '<tr><td class="alt-2" valign="top"><label for="posttemplate">';
$posttemplate .= $ubbt_lang['POST_TEMPLATE'] . '</label></td><td class="alt-1" valign="top">';
$posttemplate .= '<select name="posttemplate" class="form-select" onchange="pull_template(); return false;">';
$posttemplate .= '<option value="" selected="selected">' . $ubbt_lang['SELECT'] . '</option>';
}
$posttemplate .= '<option value="' . $ubbt_lang['SUB_'.$i.'_BODY'] . '">' . $ubbt_lang['SUB_'.$i] . '</option>';
}
}
// Finish off the template, if it has some good stuff
if ($posttemplate) {
$posttemplate .= '</select></td></tr>';
}
}
// Glom this puppy onto the iconselect :D
$iconselect .= $posttemplate;

Save the file

File: languages/english/posttemplate.php (new format)
PHP Code

<?php
$ubbt_lang
['POST_TEMPLATE'] = 'Post Template:';
$ubbt_lang['SELECT'] = '--- Select ---';
$ubbt_lang['NUM_POST_TEMPLATES'] = '1';
$ubbt_lang['SUB_1'] = 'Fishing Report';
$ubbt_lang['SUB_1_FORUMS'] = '2,3,7,69';
$ubbt_lang['SUB_1_GROUPS'] = '1,2,3';
$ubbt_lang['SUB_1_BODY'] = 'Body of water:
General location(s):
Date:
Time:
Shore or boat:
Water temp:
Depth fished: (surface, mid, bottom):
Max depth:
Methods: (cast, troll, etc.)
Lures used:
Bait used:
Tide:
Species caught:
Total # of fish caught:
Fish weights:
Fish lengths:
Kept or released:
Gear used:
'
;
?>


key things to note:
1) NUM_POST_TEMPLATES is the number of templates total
2) Every template has
a) SUB_x -- pulldown descriptor
b) SUB_x_FORUMS -- comma separated list of forums. (blank is any forum)
c) SUB_x_GROUPS -- comma separated list of groups. (blank is any group)
d) SUB_x_BODY -- the template itself

Final note, i just copy/pasted Giz javascript function into ubb_jslib.js at the bottom.

Ty Giz for the good start on a great mod! smile

Sponsored Links
Entire Thread
Subject Posted By Posted
[7.x] UBB.Post Templates v0.1 Gizmo 05/23/2008 7:12 AM
Re: [7.x] UBB.Post Templates v0.1 Gizmo 05/23/2008 7:50 AM
Re: [7.x] UBB.Post Templates v0.1 AllenAyres 05/23/2008 5:51 PM
Re: [7.x] UBB.Post Templates v0.1 Gizmo 05/24/2008 3:52 AM
Re: [7.x] UBB.Post Templates v0.1 sirdude 07/05/2008 11:14 AM
Re: [7.x] UBB.Post Templates v0.1 Gizmo 07/05/2008 1:10 PM
Re: [7.x] UBB.Post Templates v0.1 sirdude 07/05/2008 7:48 PM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)