php forum
php mysql forum
php mysql smarty
 
Topic Options
#317049 - 05/23/08 12:12 AM [7.x] UBB.Post Templates v0.1
Gizmo Administrator Offline
Wizard

Registered: 01/10/00
Posts: 5115
Loc: Portland, OR, USA

   [7.x] UBB.Post Templates v0.1 to Del.icio.us Add to del.icio.us
  Digg [7.x] UBB.Post Templates v0.1 Digg it
Author: Gizmo (James of VNC Web Design)

Requirements:
  • Valid UBB.Threads 7.0 install and license


About:
This addon will allow you to create New Post Templates for your forum, these templates will be selectable from a dropdown on the New Topic page, and will appear in the text area where you normally make your post (users would just update the template then click the post button to post their new thread as normal).

Demo:
As it uses the New Topic scripts, there isn't really an ability for a demo; though I do have it on UGN Security on my "Review" forums.

File History
2540 - UBB Post Templates v01 (UBB.PostTemplates-v01.zip) - Released: 05/22/2008 - Initial Release

NOTE
To add more items, simply add additional "option" lines in newpost.tpl and the posttemplate.php language file.

NOTICE
As this modifies script files I've put it as a mod, as it's more than a minor template adjustment.


Attachments
UBB.PostTemplates-v01.zip (9 downloads)

_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design Owner

Top
#317050 - 05/23/08 12:50 AM Re: [7.x] UBB.Post Templates v0.1 [Re: Gizmo]
Gizmo Administrator Offline
Wizard

Registered: 01/10/00
Posts: 5115
Loc: Portland, OR, USA
BTW, if you're looking to "limit" certain ones to certain boards; or even limit templates in general on forums; I have my template change on my site set to:
Code:
{if $Board == 1 || $Board == 12 || $Board == 13 || $Board == 21 || $Board == 36 || $Board == 41 || $Board == 47 || $Board == 48}
<tr>
<td class="alt-2" valign="top">
<label for="posttemplate">{$lang.posttemp}</label>
</td>
<td class="alt-1" valign="top">
<select name="posttemplate" class="form-select" onchange="pull_template(); return false">
	<option value="" selected="selected">{$lang.select}</option>
{if $Board == 36}	<option value="{$lang.one_body}">{$lang.one_sub}</option>{/if}
{if $Board == 13}	<option value="{$lang.two_body}">{$lang.two_sub}</option>{/if}
{if $Board == 13}	<option value="{$lang.three_body}">{$lang.three_sub}</option>{/if}
{if $Board == 47}	<option value="{$lang.four_body}">{$lang.four_sub}</option>{/if}
{if $Board == 12 || $Board == 13 || $Board == 21 || $Board == 47 || $Board == 48}	<option value="{$lang.five_body}">{$lang.five_sub}</option>{/if}
{if $Board == 41}	<option value="{$lang.six_body}">{$lang.six_sub}</option>{/if}

</select>
</td>
</tr>
{/if}


Top if statement limits it to those boards, then the ones in the select area limit which are in which forums.
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design Owner

Top
#317052 - 05/23/08 10:51 AM Re: [7.x] UBB.Post Templates v0.1 [Re: Gizmo]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25408
Loc: Texas
hmm... could be very nice - do you have a screen grab of an example?
_________________________
- Allen wavey
- What Drives You?

Top
#317059 - 05/23/08 08:52 PM Re: [7.x] UBB.Post Templates v0.1 [Re: AllenAyres]
Gizmo Administrator Offline
Wizard

Registered: 01/10/00
Posts: 5115
Loc: Portland, OR, USA
here you go wink...

The dropdown shown selects the code; then it outputs into the text area; pretty self explanatory.


Attachments
mod.JPG (16 downloads)

_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design Owner

Top
#317372 - 07/05/08 04:14 AM Re: [7.x] UBB.Post Templates v0.1 [Re: Gizmo]
sirdude Moderator Offline
Enthusiast

Registered: 11/08/03
Posts: 439
Loc: SoCal
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

Top
#317373 - 07/05/08 06:10 AM Re: [7.x] UBB.Post Templates v0.1 [Re: sirdude]
Gizmo Administrator Offline
Wizard

Registered: 01/10/00
Posts: 5115
Loc: Portland, OR, USA
Lol I'm glad you of all people like it smile...

I'd like to eventually see it as being db driven and int he CP; but that's a little above me with where OOP is concerned...

I figured, I like some structure, hell even here would be great, as then users would have a defined list for some sort of conformity...

I'd also like to someday see it as a popular feature enough to be stock code, as I can really see usage at just about any forum wink...

_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design Owner

Top
#317374 - 07/05/08 12:48 PM Re: [7.x] UBB.Post Templates v0.1 [Re: Gizmo]
sirdude Moderator Offline
Enthusiast

Registered: 11/08/03
Posts: 439
Loc: SoCal
there is no true OoP used at all wink
_________________________

A taxpayer voting for Obama is like a chicken voting for Colonel Sanders.

Top


Moderator:  sirdude 
Top Posters Last 30 Days
AllenAyres 18
Gizmo 12
sirdude 6
GEN 3
tackaberry 2
Philipp 2
willing 2
Who's Online
0 Registered (), 36 Guests and 9 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
Team UBBDev Rides Again!
by Gizmo
08/28/08 11:45 PM
Multiple Identity Detector
by MattUK
08/28/08 04:10 PM
[7.3.x] ubb.links
by AllenAyres
08/26/08 09:57 AM
Installing FlashChat with 7.3
by Gizmo
08/23/08 05:36 AM
[7.2.1] - Naked shoutbox
by Iann128
08/22/08 07:27 PM
Nice Ajax Chat
by M4D
08/21/08 10:02 PM
51-card NVIDIA folding rig cranks out 265,200 ppd
by AllenAyres
08/13/08 10:10 PM
New Mods
Installing FlashChat with 7.3
by Paug
08/23/08 12:14 AM
[7.x] AddThis - Social Networking
by Gizmo
08/01/08 01:30 AM
[7.3.x] ubb.links
by AllenAyres
06/20/08 11:50 PM
[7.3] Dissallow quotes more then 3 levels deep
by blaaskaak
06/09/08 09:01 AM
[7.2.1] - Naked shoutbox
by sirdude
08/17/07 10:36 PM
Newest Members
welcomeback1, Paug, Tim Keating, anscers, Murphdog
13324 Registered Users

 

 

 
fusionbb message board php hacks