MyBB Hacks

Full Version: Testimonials Forum
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Requirement: XThreads
Last Updated: 7 October 2012

This idea based on Thread Description. But we will use it as a very simple Testimonials Forum

Here is a simple example to do that:

Multiline Textbox for testimonial message (the only custom thread fields in this sample).
Create a Custom Thread Fields with this settings:
  1. Title: Your Testimonial
  2. Key: xttes_tes
  3. Applicable Forums: 'select a forum where we will apply this modification'
  4. Input Field Type: Multiline Textbox
  5. Editable by / Required Field?: Everyone (required)
  6. Display Parsing: Plain text with newlines
    Modify it as our needs. Example: if we want users can use BBCode, select Use MyBB Parser (MyCode), and tick some options in MyBB Parser Options setting.
  7. Display Format:

    HTML Code
    <if THIS_SCRIPT == 'forumdisplay.php' then>
    <if $thread['replies'] > 0 then>
    <div class="post_body">{VALUE}</div>
    <div class="float_right smalltext">
    <a href="{$threadurl}">Read Comments</a> |
    <a href="newreply.php?tid={$thread['tid']}">Post Comment</a>
    </div>
    <else>
    <div class="post_body">{VALUE}</div>
    <div class="float_right smalltext">
    <a href="newreply.php?tid={$thread['tid']}">Post Comment</a>
    </div>
    </if>
    <else>
    {VALUE}
    </if>

    For displaying this field value, we need to put {$GLOBALS['threadfields']['xttes_tes']} variable in our template.



XThreads Options in Forum settings (the forum in the settings above):
  • Template Prefix: xttes_
  • Show first post on every showthread page: Yes
  • Settings Overrides:
    • Setting: Showthread Options -> Post Layout
      Value: horizontal

      Code:
      postlayout=horizontal

  • Allow Blank Post Message: Yes
  • Hide Forum: Yes
    We need to put this forum URL manually in our template.
  • Custom WOL Text:
    • Forum Display: Viewing Testimonials
    • New Thread: Create A New Testimonial
    • New Reply: Commenting <a href="{1}">{2}</a> Testimonial
    • Show Thread: Reading <a href="{1}">{2}</a> Testimonial

Create new templates in Global Template:
  1. Template Name: xttes_editpost_first

    HTML Code
    <html>
    <head>
    <title>{$mybb->settings['bbname']} - {$lang->edit_post}</title>
    {$headerinclude}
    <script type="text/javascript" src="jscripts/post.js?ver=1400"></script>
    </head>
    <body>
    {$header}
    {$preview}
    {$post_errors}
    {$attacherror}
    <form action="editpost.php?pid={$pid}&amp;processed=1" method="post" enctype="multipart/form-data" name="input">
    	<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
    	<div style="width: 600px; margin: auto auto;">
    		<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    			<tr>
    				<td class="thead" colspan="2"><strong>Edit Testimonial</strong></td>
    			</tr>
    			<tr>
    				<td class="trow2"><strong>Subject</strong></td>
    				<td class="trow2"><input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" /></td>
    			</tr>
    			{$extra_threadfields}
    			<tr style="display: none;">
    				<td class="trow2" valign="top"><strong>{$lang->your_message}:</strong></td>
    				<td class="trow2">
    				<textarea name="message" id="message" rows="20" cols="70" tabindex="3">{$message}</textarea>
    				</td>
    			</tr>
    		</table>
    		<br />
    		<div align="center"><input type="submit" class="button" name="submit" value="{$lang->update_post}" tabindex="3" />  <input type="submit" class="button" name="previewpost" value="{$lang->preview_post}" tabindex="4" /></div>
    		<input type="hidden" name="action" value="do_editpost" />
    		<input type="hidden" name="posthash" value="{$posthash}" />
    		<input type="hidden" name="attachmentaid" value="" />
    		<input type="hidden" name="attachmentact" value="" />
    	</div>
    </form>
    <br />
    <form action="editpost.php" method="post" name="editpost">
    <input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
    <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    <tr>
    <td class="thead" colspan="3"><strong>{$lang->delete_post}</strong></td>
    </tr>
    <tr>
    <td class="trow1" style="white-space: nowrap"><input type="checkbox" class="checkbox" name="delete" value="1" tabindex="9" /> <strong>{$lang->delete_q}</strong></td>
    <td class="trow1" width="100%">{$lang->delete_1}<br /><span class="smalltext">{$lang->delete_2}</span></td>
    <td class="trow1"><input type="submit" class="button" name="submit" value="{$lang->delete_now}" tabindex="10" /></td>
    </tr>
    </table>
    <input type="hidden" name="action" value="deletepost" />
    <input type="hidden" name="pid" value="{$pid}" />
    </form>
    {$footer}
    </body>
    </html>

  2. Template Name: xttes_forumdisplay_nothreads

    HTML Code
    <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    <tr>
    <td colspan="{$colspan}" class="trow1" align="center"><strong><em>There is no testimonial</em></strong></td>
    </tr>
    </table>

  3. Template Name: xttes_forumdisplay_sticky_sep

    HTML Code
    <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    <tr>
    <td class="trow_sep" colspan="{$colspan}" align="center">Important Testimonials</td>
    </tr>
    </table>

  4. Template Name: xttes_forumdisplay_thread

    HTML Code
    <br />
    <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    	<tr>
    		<td class="{$bgcolor}" width="100%">
    			<div>
    				<span><strong><a href="{$thread['threadlink']}" class="{$inline_edit_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a></strong></span>
    				<div class="author smalltext">by: {$thread['profilelink']}</div>
    			</div>
    			{$GLOBALS['threadfields']['xttes_tes']}
    		</td>
    		{$modbit}
    	</tr>
    </table>

  5. Template Name: xttes_forumdisplay_threadlist

    HTML Code
    <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    	<tr>
    		<td class="thead" align="center">
    			<div>
    				<strong><a href="{$forumurl}">{$foruminfo['name']}</a></strong>
    			</div>
    		</td>
    		{$inlinemodcol}
    	</tr>
    	<tr>
    		<td class="trow1" colspan="2">
    			{$threads}{$nullthreads}
    		</td>
    	</tr>
    </table>
    <div class="float_left">
    	{$multipage}
    </div>
    <div class="float_right" style="margin-top: 4px;">
    	{$newthread}
    </div>
    <br style="clear: both;" />
    <br />
    <div class="float_right" style="text-align: right;">
    	{$inlinemod}
    	{$forumjump}
    </div>
    <br style="clear: both" />
    {$inline_edit_js}
    <div class="smalltext clear" align="center">
    Testimonials<br />
    Powered By <a href="http://mybbhacks.zingaburga.com">XThreads</a> - <a href="http://mybbhacks.zingaburga.com">MyBB Hacks</a>
    </div>

  6. Template Name: xttes_forumdisplay_threads_sep

    HTML Code
    <br />
    <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    <tr>
    <td class="trow_sep" colspan="{$colspan}" align="center">Normal Testimonials</td>
    </tr>
    </table>

  7. Template Name: xttes_newthread

    HTML Code
    <html>
    <head>
    <title>{$lang->newthread_in}</title>
    {$headerinclude}
    <script type="text/javascript" src="jscripts/post.js?ver=1400"></script>
    </head>
    <body>
    {$header}
    {$preview}
    {$thread_errors}
    {$attacherror}
    <form action="newthread.php?fid={$fid}&amp;processed=1" method="post" enctype="multipart/form-data" name="input">
    	<div style="width: 600px; margin: auto auto;">
    		<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
    		<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    			<tr>
    				<td class="thead" colspan="2"><strong>Your Testimonial</strong></td>
    			</tr>
    			<tr>
    				<td class="trow2" width="20%">
    					<strong>Subject</strong>
    				</td>
    				<td class="trow2">
    					<input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" />
    				</td>
    			</tr>
    			{$extra_threadfields}
    			<tr style="display: none;">
    				<td class="trow2" valign="top">
    					<strong>{$lang->your_message}</strong>
    				</td>
    				<td class="trow2">
    					<textarea name="message" id="message" rows="20" cols="70" tabindex="2">{$message}</textarea>
    				</td>
    			</tr>
    			{$captcha}
    		</table>
    		<br />
    		<div style="text-align:center"><input type="submit" class="button" name="submit" value="{$lang->post_thread}" tabindex="4" accesskey="s" />  <input type="submit" class="button" name="previewpost" value="{$lang->preview_post}" tabindex="5" /></div>
    		<input type="hidden" name="action" value="do_newthread" />
    		<input type="hidden" name="posthash" value="{$posthash}" />
    		<input type="hidden" name="attachmentaid" value="" />
    		<input type="hidden" name="attachmentact" value="" />
    		<input type="hidden" name="quoted_ids" value="{$quoted_ids}" />
    		<input type="hidden" name="tid" value="{$tid}" />
    		{$editdraftpid}
    	</div>
    </form>
    {$forumrules}
    {$footer}
    </body>
    </html>

  8. Template Name: xttes_postbit

    HTML Code
    {$ignore_bit}
    <a name="pid{$post['pid']}" id="pid{$post['pid']}"></a>
    <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="{$post_extra_style} {$post_visibility}" id="post_{$post['pid']}">
    	<tbody>
    		<tr>
    			<td class="trow2 post_content {$unapproved_shade}">
    				{$post['posturl']}
    				<br class="clear" />
    				<div class="post_body" id="pid_{$post['pid']}">
    					{$post['message']}
    				</div>
    				<br class="clear" />
    				<div class="float_right">
    					<span class="smalltext">
    						<em>Commented by:
    						<a href="{$post['profilelink_plain']}" id="profile_{$post['pid']}">{$post['username_formatted']}</a>
    						</em>
    					</span>
    					<div id="profile_{$post['pid']}_popup" class="trow1" style="display: none;width: 350px;">
    						<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    							<tr>
    								<td class="tcat" align="center" colspan="2">
    									<span class="largetext"><strong>User Info</strong></span>
    								</td>
    							</tr>
    							<tr>
    								<td class="post_avatar trow1" width="1" style="{$post['avatar_padding']}">
    									{$post['useravatar']}
    								</td>
    								<td class="post_author trow1">
    									<strong><span class="largetext">{$post['profilelink']}</span></strong> {$post['onlinestatus']}<br />
    									<span class="smalltext">
    										{$post['usertitle']}<br />
    										{$post['userstars']}
    										{$post['groupimage']}
    									</span>
    								</td>
    							</tr>
    						</table>
    					</div>
    				</div>
    				<div class="post_management_buttons float_left">
    					{$post['button_edit']}{$post['button_quickdelete']}{$post['button_report']}{$post['button_warn']}
    				</div>
    				<div class="post_meta clear" id="post_meta_{$post['pid']}">
    					{$post['iplogged']}
    				</div>
    			</td>
    		</tr>
    	</tbody>
    </table>
    <script type="text/javascript">
    // <!--
    	if(use_xmlhttprequest == "1")
    	{
    		new PopupMenu("profile_{$post['pid']}");
    	}
    // -->
    </script>

  9. Template Name: xttes_postbit_first

    HTML Code
    {$ignore_bit}
    <a name="pid{$post['pid']}" id="pid{$post['pid']}"></a>
    <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="{$post_extra_style} {$post_visibility}" id="post_{$post['pid']}">
    	<tbody>
    		<tr>
    			<td class="tcat tc largetext">
    				<div>{$post['subject']}</div>
    			</td>
    		</tr>
    		<tr>
    			<td class="trow2 post_content {$unapproved_shade}">
    				<div class="post_body" id="pid_{$post['pid']}">
    					{$GLOBALS['threadfields']['xttes_tes']}
    					{$post['message']}
    				</div>
    				<br class="clear" />
    				<div class="float_right">
    					<span class="smalltext">
    						<em>Submitted by:
    						<a href="{$post['profilelink_plain']}" id="profile_{$post['pid']}">{$post['username_formatted']}</a>
    						</em>
    					</span>
    					<div id="profile_{$post['pid']}_popup" class="trow1" style="display: none;width: 350px;">
    						<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    							<tr>
    								<td class="tcat" align="center" colspan="2">
    									<span class="largetext"><strong>Submitter Info</strong></span>
    								</td>
    							</tr>
    							<tr>
    								<td class="post_avatar trow1" width="1" style="{$post['avatar_padding']}">
    									{$post['useravatar']}
    								</td>
    								<td class="post_author trow1">
    									<strong><span class="largetext">{$post['profilelink']}</span></strong> {$post['onlinestatus']}<br />
    									<span class="smalltext">
    										{$post['usertitle']}<br />
    										{$post['userstars']}
    										{$post['groupimage']}
    									</span>
    								</td>
    							</tr>
    						</table>
    					</div>
    				</div>
    				<div class="post_management_buttons float_left">
    					{$post['button_edit']}{$post['button_quickdelete']}{$post['button_report']}{$post['button_warn']}
    				</div>
    				<div class="post_meta clear" id="post_meta_{$post['pid']}">
    					{$post['iplogged']}
    				</div>
    			</td>
    		</tr>
    	</tbody>
    </table>
    <script type="text/javascript">
    // <!--
    	if(use_xmlhttprequest == "1")
    	{
    		new PopupMenu("profile_{$post['pid']}");
    	}
    // -->
    </script>

  10. Template Name: xttes_showthread

    HTML Code
    <html>
    <head>
    <title>{$thread['subject']}</title>
    {$headerinclude}
    <script type="text/javascript">
    <!--
    	var quickdelete_confirm = "{$lang->quickdelete_confirm}";
    // -->
    </script>
    <script type="text/javascript" src="jscripts/thread.js?ver=1400"></script>
    </head>
    <body>
    {$header}
    <div>
    	{$first_post}
    </div>
    <br />
    <div align="center">
    	<strong>&laquo; <a href="{$next_oldest_link}">{$lang->next_oldest}</a> | <a href="{$next_newest_link}">{$lang->next_newest}</a> &raquo;</strong>
    </div>
    <br />
    <div id="posts">
    	{$posts}
    </div>
    <br />
    <div class="float_left">
    	{$multipage}
    </div>
    <div style="padding-top: 4px;" class="float_right">
    	{$newreply}
    </div>
    <br style="clear: both;" />
    {$quickreply}
    {$threadexbox}
    {$similarthreads}
    <br />
    <div class="float_right" style="text-align: right;">
    	{$moderationoptions}
    	{$forumjump}
    </div>
    <div class="smalltext clear" align="center">
    Testimonials<br />
    Powered By <a href="http://mybbhacks.zingaburga.com">XThreads</a> - <a href="http://mybbhacks.zingaburga.com">MyBB Hacks</a>
    </div>
    {$footer}
    </body>
    </html>


That is the very simple example Testimonials Forum. We can still expand it, like adding Product List, so users can select whether the testimonial is for general testimonial or a testimonial specified for the selected product. We can add other fields like "rate" based on some specified things, like quality, support, and etc. So, users can "rate" our site or product based on those specified things.
The template above based on MyBB 1.4

Screenshots:

1. Testimonial "Index":
[attachment=280]

2. Thread:
[attachment=281]

3. Newthread/editpost:
[attachment=282]

Live Demo:
http://www.14.mynie.co.cc/forumdisplay.php?fid=38
Thanks for the post RateU Smile
Another remarkable use. Don't forget to add it to the LIST
Very good. Smile
Looks fantastic! RateU   Smile
how to insert text editor and smile in the "Newthread / EditPost:" Rules ?
Update:
Use Settings Overrides for the Force Postbit Layout settings in create/edit forum settings:
  • Settings Overrides:
    • Setting: Showthread Options -> Post Layout
      Value: horizontal

      Code:
      postlayout=horizontal

how can i fix this?

[attachment=901]
Set the Allow Blank Post Message setting to Yes. I've updated the first post.
What is template code to display last posted testimonial with user posted it ?
means if i put that code in any template it show last testimonial with user posted it.
Reference URL's