J Testimonials allow you to add unlimited number of testimonials. It has both front-end and back-end functionality. From front-end it shows testimonials with pre-configured value. Logged in user can post new testimonials from front-end. Once admin approve that post then it will be shown in the front-end. User can upload his picture , company name, email address, website etc.

Super admin will get option to post new testimonials , approve post and delete post. There is option to configure the front-end view too. There are couple of templates to show testimonials at the front-end. During assigning the component at the front-end there is option to show some text at the very top of testimonials.

So let's have a basic idea about this component. We will go through briefly over the component. Let's say we have a folder called com_jtestimonials. Now in that folder we have below files and folder:

  • com_jtestimonials.xml
  • install.com_jtestimonials.php
  • uninstall.com_jtestimonials.php
  • admin
    • index.html
    • config.xml
    • admin.jtestimonials.php
    • views
      • index.html
      • pending
        • view.html.php
        • index.html
        • tmpl
          • default.php
          • index.html
      • list_detail
        • view.html.php
        • index.html
        • tmpl
          • index.html
          • form.php
          • js
            • calendar_us.js
            • index.html
          • images
            • cal.gif
            • index.html
            • next_mon.gif
            • next_year.gif
            • no_cal.gif
            • pixel.gif
            • prev_mon.gif
            • prev_year.gif
            • shade_bl.png
            • shade_bm.png
            • shade_br.png
            • shade_mr.png
            • shade_tr.png
          • css
            • calendar.css
            • index.html
      • list
        • view.html.php
        • index.html
        • tmpl
          • index.html
          • default.php
      • jtestimonials
        • view.html.php
        • index.html
        • tmpl
          • index.html
          • default.php
      • config
        • view.html.php
        • index.html
        • tmpl
          • index.html
          • form.php
      • category_detail
        • view.html.php
        • index.html
        • tmpl
          • form.php
          • index.html
      • category
        • view.html.php
        • index.html
        • tmpl
          • default.php
          • index.html
    • tables
      • category_detail.php
      • config.php
      • index.html
      • list_detail.php
    • models
      • category.php
      • category_detail.php
      • config.php
      • index.html
      • list.php
      • list_detail.php
      • pending.php
      • pending_detail.php
    • images
      • testimonials_icon.png
      • testimonials.png
      • pending_task.png
      • pending_icon.png
      • pending.png
      • not_approve.png
      • jtestimonials_icon.png
      • jtestimonials_front.png
      • jtestimonials.png
      • index.html
      • control_panel_task.png
      • control_panel_icon.png
      • control_panel.png
      • configuration_icon.png
      • configuration.png
      • category_icon.png
      • category.png
      • template_preview
        • 1.png
        • 2.png
        • 3.png
        • 4.png
        • index.html
      • gallery
        • default_user_icon.jpg
        • index.html
    • help
      • index.html
      • en-GB
      • screen.jtestimonials.list.html
      • screen.jtestimonials.help.html
      • screen.jtestimonials.config.html
      • screen.jtestimonials.category.html
      • screen.jtestimonials.approval.html
      • index.html
      • images
        • category.jpg
        • Configuration.jpg
        • cpanel.jpg
        • index.html
        • jtestimonials.jpg
        • list.jpg
        • new_category.jpg
        • new_list.jpg
        • pending.jpg
    • elements
      • index.html
      • jtestimonials.php
    • controllers
      • category.php
      • category_detail.php
      • config.php
      • index.html
      • jtestimonials.php
      • list.php
      • list_detail.php
      • pending.php
      • pending_detail.php
  • modules
    • mod_jtestimonials
      • mod_jtestimonials.xml
      • mod_jtestimonials.php
      • index.html
      • helper.php
      • tmpl
        • coda-slider.1.1.1.pack.js
        • default.php
        • index.html
        • jquery-easing-1.3.pack.js
        • jquery-easing-compatibility.1.2.pack.js
        • style.css
        • ycodaslider-2.0.pack.js
  • site
    • router.php
    • jtestimonials.php
    • index.html
    • views
      • index.html
      • jtestimonials
        • view.html.php
        • index.html
        • tmpl
          • default.php
          • default.xml
          • index.html
    • tables
      • jtestimonials_detail.php
      • index.html
    • models
      • index.html
      • jtestimonials.php
      • jtestimonials_detail.php
    • images
      • black_bottom.gif
      • cal.gif
      • default_bottom.gif
      • index.html
      • lightgreen_bottom.gif
      • minus.png
      • next_mon.gif
      • next_year.gif
      • no_cal.gif
      • pixel.gif
      • plus.png
      • prev_mon.gif
      • prev_year.gif
      • shade_bl.png
      • shade_bm.png
      • shade_br.png
      • shade_mr.png
      • shade_tr.png
      • silver_bottom.gif
    • controllers
      • index.html
      • jtestimonials.php
      • jtestimonials_detail.php
    • assets
      • addtestimonialspanel.css
      • calendar.css
      • calendar_us.js
      • index.html
      • jquery-1.3.2.js
      • style.css
      • view.default.css

Now This component has many functionality. To view each and one of the files will bring complexity of this tutorial. So i am focusing on one function of front-end and one function of back-end. So let's start with front-end testimonials entry function. If we go to com_jtestimonials now we will see below files:

a) router.php

b) jtestimonials.php

c) index.html

Now let's open router.php file.

<?php
function jtestimonialsBuildRoute(&$query)
{
$segments = array();
if(isset($query['search']))
{
$segments[] = $query['search'];
unset($query['search']);
};
if(isset($query['country']))
{
$segments[] = $query['country'];
unset($query['country']);
};
return $segments;
}
function jtestimonialsParseRoute($segments)
{
$vars = array();
// view is always the first element of the array
$count = count($segments);
if ($count)
{
$count--;
$segment = array_shift($segments);
if (strlen( $segment )==1) {
$vars['search'] = $segment;
} else {
$vars['country'] = $segment;
}
}
if ($count)
{
$count--;
$segment = array_shift($segments);
if (strlen( $segment )==1) {
$vars['search'] = $segment;
} else {
$vars['country'] = $segment;
}
}
return $vars;
}
?>

Now this is router file to build extra search functionality and other function. Now let's open jtestimonials.php which is the main php file.

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$controller = JRequest::getVar('controller','jtestimonials' );
require_once (JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php');
JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');
JTable::addIncludePath('path'.DS.'to'.DS.'tables');
$classname = $controller.'controller';
$controller = new $classname( array('default_task' => 'display') );
$controller->execute( JRequest::getVar('task' ));
$controller->redirect();
?>

This file call the default controller (jtestimonials), which is then load the controller, model , view, tmpl files. So at first it will go to controller. So find out jtestimonials.php files functionality:

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.controller' );
class jtestimonialsController extends JController
{
function __construct( $default = array())
{
parent::__construct( $default );
}
function display() {
parent::display();
}
}
?>

Here this controller only load default view file. Controller may have many functions but here we load only the default view file. Now it will knock on view.html.php file. So let's open that file in views->jtestimonials to get code:

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.view' );

class jtestimonialsViewjtestimonials extends JView
{
function __construct( $config = array())
{

global $context;
$context = 'jtestimonials.list.';

parent::__construct( $config );
}


function display($tpl = null)
{
global $mainframe, $context;

$document = & JFactory::getDocument();
$document->addStyleSheet('components/com_jtestimonials/assets/view.default.css');
$document->addStyleSheet('components/com_jtestimonials/assets/style.css');
$document->addStyleSheet('components/com_jtestimonials/assets/calendar.css');
$document->addScript('components/com_jtestimonials/assets/calendar_us.js');

$params = &$mainframe->getPageParameters();
$lists = array();
$uri = JURI::base();
$jtestimonials_id = JRequest::getVar( 'id', 0, '', 'int' );
$slink = 'index.php?option=com_jtestimonials&view=jtestimonials&id='.$jtestimonials_id;
$this->assignRef('slink', $slink);

$filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 'h.id' );
$filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '' );

$lists['order'] = $filter_order;
$lists['order_Dir'] = $filter_order_Dir;

$items = & $this->get( 'Data');
$total = & $this->get( 'Total');
$pagination = & $this->get( 'Pagination' );

$this->assignRef('user', JFactory::getUser());
$this->assignRef('lists', $lists);
$this->assignRef('items', $items);
$this->assignRef('pagination', $pagination);
$this->assignRef('params', $params);
$this->assignRef('baseurl', $uri);

parent::display($tpl);
}
}
?>

Now here we have called sorting code , pagination code etc. This will call tmpl files , which show the html part of this project. So let's open default.php file inside tmpl folder.

<?php
defined('_JEXEC') or die('Restricted access');
JHTML::_('behavior.tooltip');
JHTML::_('behavior.mootools');

$document =& JFactory::getDocument();
$document->addScript('includes/js/joomla.javascript.js');
$editor =& JFactory::getEditor();
echo '<div style="display:none;">'.$editor->display('', '', '550', '400', '60', '20', false).'</div>';
?>
<link rel="stylesheet" href="/components/com_jtestimonials/assets/addtestimonialspanel.css" type="text/css" media="screen" />
<script type="text/javascript" src="/components/com_jtestimonials/assets/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".trigger").click(function(){
$(".panel").toggle("fast");
$(this).toggleClass("active");
return false;
});
});
</script>
<script language="javascript" type="text/javascript">
function checkform() {
var form = document.addjtestimonialsform;
if (form.name.value == ""){
alert( "<?php echo JText::_( 'Please Enter Name', true ); ?>" );
form.name.style.border='1px solid red';
form.name.focus();
}
else if (form.email.value == ""){
alert( "<?php echo JText::_( 'Please Enter Email Address', true ); ?>" );
form.email.style.border='1px solid red';
form.email.focus();
}
else if (echeck(form.email.value)==false){
form.email.value=""
form.email.focus();
//return false
}
else if (form.date.value == 0){
alert( "<?php echo JText::_( 'Please Enter Date', true ); ?>" );
form.date.style.border='1px solid red';
form.date.focus();
}
else if (form.category.value == 0){
alert( "<?php echo JText::_( 'Please Select Category', true ); ?>" );
form.category.style.border='1px solid red';
form.category.focus();
}
else if (form.viewtemplate.value == 0){
alert( "<?php echo JText::_( 'Please Select Template', true ); ?>" );
form.viewtemplate.style.border='1px solid red';
form.viewtemplate.focus();
}
else { form.submit(); } }

function echeck(str) {
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(at,(lat+1))!=-1){
alert("Invalid E-mail ID")
return false
}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(dot,(lat+2))==-1){
alert("Invalid E-mail ID")
return false
}

if (str.indexOf(" ")!=-1){
alert("Invalid E-mail ID")
return false
}

return true
}
</script>
<?php
if ( $this->params->get( 'show_comp_description')==1 )
{ ?>
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center" class="jtestimonials_heading">
<tr><td width="100%" valign="top" height="10"></td></tr>
<tr>
<td width="100%" valign="top">
<div class="jtestimonials<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php echo $this->params->get('comp_description'); ?>
</div>
</td>
</tr>
<tr><td width="100%" valign="top" height="10"></td></tr>
</table>
<?php } ?>

<div class="clear"></div>

<form action="<?php echo JRoute::_($this->slink);?>" method="post" name="adminForm" >
<?php

$db =& JFactory::getDBO();
$query="SELECT * FROM #__jtestimonials_config WHERE id='1'";
$db->setQuery($query);
$result = @$db->loadObject();

$k = 0;
for ($i=0, $n=count( $this->items ); $i < $n; $i++)
{
$row = &$this->items[$i];
?>
<?php if($row->viewtemplate=='1'){ ?>
<!-- Default Template Code Start Here -->
<div id="editcell">
<table border="0" cellpadding="0" cellspacing="0" width="80%" align="center">
<tr>
<td width="100%" height="2" class="default_topbar"></td>
</tr>
<tr>
<td width="100%" height="150" valign="top" class="default_mainwrapper">
<?php
if($result->testimoniallength!=0){
$main_text= mb_substr($row->testimonial, 0, $result->testimoniallength, 'UTF-8');
echo $main_text;
}
else{
echo $row->testimonial;
}
?>
</td>
</tr>
<tr>
<td width="100%" height="5" class="default_bottombar">
<div id="default_bottomarrow"></div>
</td>
</tr>
<tr>
<td width="100%" height="80" class="default_info" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td width="100%" height="15"></td>
</tr>
<tr>
<td width="100%" height="63">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td width="85%" height="63" valign="top" class="defaultfooter_text">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<?php if($row->name && $result->nameshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->name; ?>
</td>
<?php } ?>
<?php if($row->company && $result->companyshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->company; ?>
</td>
<?php } ?>
<?php if($row->city && $result->cityshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->city; ?>
</td>
<?php } ?>
</tr>
<tr>
<?php if($row->state && $result->stateshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->state; ?>
</td>
<?php } ?>
<?php if($row->country && $result->countryshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->country; ?>
</td>
<?php } ?>
<?php if($row->email && $result->emailshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->email; ?>
</td>
<?php } ?>
</tr>
<tr>
<?php if($row->website && $result->websiteshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo '<a href="'.$row->website.'" target="_blank">'.$row->website.'</a>'; ?>
</td>
<?php } ?>
<?php if($row->date && $result->dateshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->date; ?>
</td>
<?php } ?>
<?php if($row->category && $result->categoryshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->category; ?>
</td>
<?php } ?>
</tr>
</table>
</td>
<td width="15%" height="63" align="center" valign="top">
<?php if($row->category && $result->pictureshow=='1'){ ?>
<img src="/administrator/components/com_jtestimonials/images/gallery/<?php if($row->imagelocation){ echo $row->imagelocation; } else{ echo 'default_user_icon.jpg'; } ?>" width="60" height="60" border="0" />
<?php } ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- Default Template Code End Here -->
<?php } ?>
<?php if($row->viewtemplate=='2'){ ?>
<!-- Silver Template Code Start Here -->
<div id="editcell">
<table border="0" cellpadding="0" cellspacing="0" width="80%" align="center">
<tr>
<td width="100%" height="2" class="silver_topbar"></td>
</tr>
<tr>
<td width="100%" height="150" valign="top" class="silver_mainwrapper">
<?php
if($result->testimoniallength!=0){
$main_text= mb_substr($row->testimonial, 0, $result->testimoniallength, 'UTF-8');
echo $main_text;
}
else{
echo $row->testimonial;
}
?>
</td>
</tr>
<tr>
<td width="100%" height="5" class="silver_bottombar">
<div id="silver_bottomarrow"></div>
</td>
</tr>
<tr>
<td width="100%" height="80" class="silver_info" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td width="100%" height="15"></td>
</tr>
<tr>
<td width="100%" height="63">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td width="85%" height="63" valign="top" class="silverfooter_text">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<?php if($row->name && $result->nameshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->name; ?>
</td>
<?php } ?>
<?php if($row->company && $result->companyshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->company; ?>
</td>
<?php } ?>
<?php if($row->city && $result->cityshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->city; ?>
</td>
<?php } ?>
</tr>
<tr>
<?php if($row->state && $result->stateshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->state; ?>
</td>
<?php } ?>
<?php if($row->country && $result->countryshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->country; ?>
</td>
<?php } ?>
<?php if($row->email && $result->emailshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->email; ?>
</td>
<?php } ?>
</tr>
<tr>
<?php if($row->website && $result->websiteshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo '<a href="'.$row->website.'" target="_blank">'.$row->website.'</a>'; ?>
</td>
<?php } ?>
<?php if($row->date && $result->dateshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->date; ?>
</td>
<?php } ?>
<?php if($row->category && $result->categoryshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->category; ?>
</td>
<?php } ?>
</tr>
</table>
</td>
<td width="15%" height="63" align="center" valign="top">
<?php if($row->category && $result->pictureshow=='1'){ ?>
<img src="/administrator/components/com_jtestimonials/images/gallery/<?php if($row->imagelocation){ echo $row->imagelocation; } else{ echo 'default_user_icon.jpg'; } ?>" width="60" height="60" border="0" />
<?php } ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- Silver Template Code End Here -->
<?php } ?>
<?php if($row->viewtemplate=='3'){ ?>
<!-- Black Template Code Start Here -->
<div id="editcell">
<table border="0" cellpadding="0" cellspacing="0" width="80%" align="center">
<tr>
<td width="100%" height="2" class="black_topbar"></td>
</tr>
<tr>
<td width="100%" height="150" valign="top" class="black_mainwrapper">
<?php
if($result->testimoniallength!=0){
$main_text= mb_substr($row->testimonial, 0, $result->testimoniallength, 'UTF-8');
echo $main_text;
}
else{
echo $row->testimonial;
}
?>
</td>
</tr>
<tr>
<td width="100%" height="5" class="black_bottombar">
<div id="black_bottomarrow"></div>
</td>
</tr>
<tr>
<td width="100%" height="80" class="black_info" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td width="100%" height="15"></td>
</tr>
<tr>
<td width="100%" height="63">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td width="85%" height="63" valign="top" class="blackfooter_text">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<?php if($row->name && $result->nameshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->name; ?>
</td>
<?php } ?>
<?php if($row->company && $result->companyshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->company; ?>
</td>
<?php } ?>
<?php if($row->city && $result->cityshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->city; ?>
</td>
<?php } ?>
</tr>
<tr>
<?php if($row->state && $result->stateshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->state; ?>
</td>
<?php } ?>
<?php if($row->country && $result->countryshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->country; ?>
</td>
<?php } ?>
<?php if($row->email && $result->emailshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->email; ?>
</td>
<?php } ?>
</tr>
<tr>
<?php if($row->website && $result->websiteshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo '<a href="'.$row->website.'" target="_blank">'.$row->website.'</a>'; ?>
</td>
<?php } ?>
<?php if($row->date && $result->dateshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->date; ?>
</td>
<?php } ?>
<?php if($row->category && $result->categoryshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->category; ?>
</td>
<?php } ?>
</tr>
</table>
</td>
<td width="15%" height="63" align="center" valign="top">
<?php if($row->category && $result->pictureshow=='1'){ ?>
<img src="/administrator/components/com_jtestimonials/images/gallery/<?php if($row->imagelocation){ echo $row->imagelocation; } else{ echo 'default_user_icon.jpg'; } ?>" width="60" height="60" border="0" />
<?php } ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- Black Template Code End Here -->
<?php } ?>
<?php if($row->viewtemplate=='4'){ ?>
<!-- Light Green Template Code Start Here -->
<div id="editcell">
<table border="0" cellpadding="0" cellspacing="0" width="80%" align="center">
<tr>
<td width="100%" height="2" class="lightgreen_topbar"></td>
</tr>
<tr>
<td width="100%" height="150" valign="top" class="lightgreen_mainwrapper">
<?php
if($result->testimoniallength!=0){
$main_text= mb_substr($row->testimonial, 0, $result->testimoniallength, 'UTF-8');
echo $main_text;
}
else{
echo $row->testimonial;
}
?>
</td>
</tr>
<tr>
<td width="100%" height="5" class="lightgreen_bottombar">
<div id="lightgreen_bottomarrow"></div>
</td>
</tr>
<tr>
<td width="100%" height="80" class="lightgreen_info" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td width="100%" height="15"></td>
</tr>
<tr>
<td width="100%" height="63">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td width="85%" height="63" valign="top" class="lightgreenfooter_text">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<?php if($row->name && $result->nameshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->name; ?>
</td>
<?php } ?>
<?php if($row->company && $result->companyshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->company; ?>
</td>
<?php } ?>
<?php if($row->city && $result->cityshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->city; ?>
</td>
<?php } ?>
</tr>
<tr>
<?php if($row->state && $result->stateshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->state; ?>
</td>
<?php } ?>
<?php if($row->country && $result->countryshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->country; ?>
</td>
<?php } ?>
<?php if($row->email && $result->emailshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->email; ?>
</td>
<?php } ?>
</tr>
<tr>
<?php if($row->website && $result->websiteshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo '<a href="'.$row->website.'" target="_blank">'.$row->website.'</a>'; ?>
</td>
<?php } ?>
<?php if($row->date && $result->dateshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->date; ?>
</td>
<?php } ?>
<?php if($row->category && $result->categoryshow=='1'){ ?>
<td width="33%" height="21" valign="top">
<?php echo $row->category; ?>
</td>
<?php } ?>
</tr>
</table>
</td>
<td width="15%" height="63" align="center" valign="top">
<?php if($row->category && $result->pictureshow=='1'){ ?>
<img src="/administrator/components/com_jtestimonials/images/gallery/<?php if($row->imagelocation){ echo $row->imagelocation; } else{ echo 'default_user_icon.jpg'; } ?>" width="60" height="60" border="0" />
<?php } ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- Light Green Template Code End Here -->
<?php } ?>
<?php
$k = 1 - $k;
}
?>
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tfoot>
<td colspan="12" align="center" bgcolor="#F3F3F3">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tfoot>
</table>
<input type="hidden" name="controller" value="jtestimonials" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
</form>
<?php
if ( $this->params->get( 'add_new_record')==1 )
{ ?>
<?php
$user =& JFactory::getUser();
if($user->id)
{
?>
<div class="panel">
<div id="slide-form">
<form action="<?php echo JRoute::_($this->slink);?>" method="post" name="addjtestimonialsform" id="floatingCleared" enctype="multipart/form-data">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td width="50%" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td width="35%" height="30" valign="middle">Name:</td>
<td width="65%" height="30" valign="middle"><input type="text" class="text_area" name="name" id="name" size="32" maxlength="250" value=""></td>
</tr>
<tr>
<td width="35%" height="30" valign="middle">Company:</td>
<td width="65%" height="30" valign="middle"><input type="text" class="text_area" name="company" id="company" size="32" maxlength="250" value=""></td>
</tr>
<tr>
<td width="35%" height="30" valign="middle">Position:</td>
<td width="65%" height="30" valign="middle"><input type="text" class="text_area" name="position" id="position" size="32" maxlength="250" value=""></td>
</tr>
<tr>
<td width="35%" height="30" valign="middle">City:</td>
<td width="65%" height="30" valign="middle"><input type="text" class="text_area" name="city" id="city" size="32" maxlength="250" value=""></td>
</tr>
<tr>
<td width="35%" height="30" valign="middle">State:</td>
<td width="65%" height="30" valign="middle"><input type="text" class="text_area" name="state" id="state" size="32" maxlength="20" value=""></td>
</tr>
<tr>
<td width="35%" height="30" valign="middle">Country:</td>
<td width="65%" height="30" valign="middle">
<select name="country" id="country" style="width: 178px;">
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antarctica">Antarctica</option>
<option value="Antigua and Barbuda">Antigua and Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bosnia and Herzegowina">Bosnia and Herzegowina</option>
<option value="Botswana">Botswana</option>
<option value="Bouvet Island">Bouvet Island</option>
<option value="Brazil">Brazil</option>
<option value="British Indian Ocean Territory">British Indian Ocean Territory</option>
<option value="Brunei Darussalam">Brunei Darussalam</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina Faso">Burkina Faso</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Cayman Islands">Cayman Islands</option>
<option value="Central African Republic">Central African Republic</option>
<option value="Chad">Chad</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Christmas Island">Christmas Island</option>
<option value="Cocos (Keeling) Islands">Cocos (Keeling) Islands</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Cook Islands">Cook Islands</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Cote D'Ivoire">Cote D'Ivoire</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="East Timor">East Timor</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Falkland Islands (Malvinas)">Falkland Islands (Malvinas)</option>
<option value="Faroe Islands">Faroe Islands</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="France, Metropolitan">France, Metropolitan</option>
<option value="French Guiana">French Guiana</option>
<option value="French Polynesia">French Polynesia</option>
<option value="French Southern Territories">French Southern Territories</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Gibraltar">Gibraltar</option>
<option value="Greece">Greece</option>
<option value="Greenland">Greenland</option>
<option value="Grenada">Grenada</option>
<option value="Guadeloupe">Guadeloupe</option>
<option value="Guam">Guam</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guinea-bissau">Guinea-bissau</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Heard and Mc Donald Islands">Heard and Mc Donald Islands</option>
<option value="Honduras">Honduras</option>
<option value="Hong Kong">Hong Kong</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran (Islamic Republic of)">Iran (Islamic Republic of)</option>
<option value="Iraq">Iraq</option>
<option value="Ireland">Ireland</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea">Korea</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libyan Arab Jamahiriya">Libyan Arab Jamahiriya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macau">Macau</option>
<option value="Macedonia">Macedonia</option>
<option value="Madagascar">Madagascar</option>
<option value="Malawi">Malawi</option>
<option value="Malaysia">Malaysia</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Martinique">Martinique</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mayotte">Mayotte</option>
<option value="Mexico">Mexico</option>
<option value="Micronesia, Federated States of">Micronesia, Federated States of</option>
<option value="Moldova, Republic of">Moldova, Republic of</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montserrat">Montserrat</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar">Myanmar</option>
<option value="Namibia">Namibia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherlands">Netherlands</option>
<option value="Netherlands Antilles">Netherlands Antilles</option>
<option value="New Caledonia">New Caledonia</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Niue">Niue</option>
<option value="Norfolk Island">Norfolk Island</option>
<option value="Northern Mariana Islands">Northern Mariana Islands</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau">Palau</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Philippines">Philippines</option>
<option value="Pitcairn">Pitcairn</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Qatar">Qatar</option>
<option value="Reunion">Reunion</option>
<option value="Romania">Romania</option>
<option value="Russian Federation">Russian Federation</option>
<option value="Rwanda">Rwanda</option>
<option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option>
<option value="Saint Lucia">Saint Lucia</option>
<option value="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option>
<option value="Samoa">Samoa</option>
<option value="San Marino">San Marino</option>
<option value="Sao Tome and Principe">Sao Tome and Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia (Slovak Republic)">Slovakia (Slovak Republic)</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="South Georgia">South Georgia</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="St. Helena">St. Helena</option>
<option value="St. Pierre and Miquelon">St. Pierre and Miquelon</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Svalbard and Jan Mayen Islands">Svalbard and Jan Mayen Islands</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syrian Arab Republic">Syrian Arab Republic</option>
<option value="Taiwan">Taiwan</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania, United Republic of">Tanzania, United Republic of</option>
<option value="Thailand">Thailand</option>
<option value="Togo">Togo</option>
<option value="Tokelau">Tokelau</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad and Tobago">Trinidad and Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Turks and Caicos Islands">Turks and Caicos Islands</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Emirates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States">United States</option>
<option value="United States Minor Outlying Islands">United States Minor Outlying Islands</option>
<option value="Uruguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Vatican City State (Holy See)">Vatican City State (Holy See)</option>
<option value="Venezuela">Venezuela</option>
<option value="Viet Nam">Viet Nam</option>
<option value="Virgin Islands (British)">Virgin Islands (British)</option>
<option value="Virgin Islands (U.S.)">Virgin Islands (U.S.)</option>
<option value="Wallis and Futuna Islands">Wallis and Futuna Islands</option>
<option value="Western Sahara">Western Sahara</option>
<option value="Yemen">Yemen</option>
<option value="Yugoslavia">Yugoslavia</option>
<option value="Zaire">Zaire</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select></td>
</tr>
</table>
</td>
<td width="50%" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td width="35%" height="30" valign="middle">E-mail:</td>
<td width="65%" height="30" valign="middle"><input type="text" class="text_area" name="email" id="email" size="32" maxlength="250" value=""></td>
</tr>
<tr>
<td width="35%" height="30" valign="middle">Website:</td>
<td width="65%" height="30" valign="middle"><input type="text" class="text_area" name="website" id="website" size="32" maxlength="250" value=""></td>
</tr>
<tr>
<td width="35%" height="30" valign="middle">Date:</td>
<td width="65%" height="30" valign="middle">
<input type="text" class="dateinputbox" name="date" id="date" value="" size="32" maxlength="19">
<script language="JavaScript">
new tcal ({
// form name
'formname': 'addjtestimonialsform',
// input name
'controlname': 'date'
});
</script>
</td>
</tr>
<tr>
<td width="35%" height="30" valign="middle">Category:</td>
<td width="65%" height="30" valign="middle">
<?php
$db =& JFactory::getDBO();
$query = "SELECT title,id FROM #__jtestimonials_category";
$db->setQuery($query);
$row_category = $db->loadObjectList();
?>
<select name="category" id="category" class="inputbox" size="1">
<option value="" selected="selected">- Select a Category -</option>
<?php
foreach($row_category as $rwcat){
echo '<option value="'.$rwcat->id.'">'.$rwcat->title.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td width="35%" height="30" valign="middle">Template:</td>
<td width="65%" height="30" valign="middle">
<select name="viewtemplate" id="viewtemplate" class="inputbox" size="1" onchange="preview_templates()">
<option value="">- Select a Template -</option>
<option value="1">Default</option>
<option value="2">Silver</option>
<option value="3">Black</option>
<option value="4">Light Green</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%" height="40" valign="middle" colspan="2">
<table border="0" cellpadding="0" cellspacing="0" width="90%" align="center">
<tr>
<td width="20%">
Image:
</td>
<td width="80%">
<input type="file" size="77" name="imagelocation" id="imagelocation">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%" align="center" colspan="2">
<div class="heading">Testimonial</div>
<div><textarea id="testimonial" name="testimonial" cols="44" rows="9" class="mce_editable"></textarea></div>
</td>
</tr>
<tr>
<td width="100%" colspan="2" align="center" height="30">
<input type="button" onclick="checkform();" value="Submit" name="submitbtn">
</td>
</tr>
</table>
<input type="hidden" name="task" value="save" />
<input type="hidden" name="published" value="1" />
<input type="hidden" name="controller" value="jtestimonials_detail" />
</form>
</div>
</div>
<?php
}
else
{
?>
<div class="panel" style="color: #ffffff;font-weight: bold;">
<?php echo JText::_('Please Login To Add New Testimonial.'); ?>
</div>
<?php
}
?>
<a class="trigger" href="#">New Testimonials</a>
<?php
}
?>

This will show you front-end view. Now when user will fill-up the form and press submit button then it will call controller, so let's open controller file:

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.controller' );

class jtestimonials_detailController extends JController
{

function __construct( $default = array())
{
parent::__construct( $default );
$this->registerTask( 'add' , 'edit' );
}
function edit()
{
JRequest::setVar( 'view', 'jtestimonials_detail' );
JRequest::setVar( 'layout', 'form' );
JRequest::setVar( 'hidemainmenu', 1);

parent::display();

$model = $this->getModel('jtestimonials_detail');
$model->checkout();
}

function save()
{

$post = JRequest::get('post');
$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
$post['id'] = $cid[0];
$model = $this->getModel('jtestimonials_detail');
$post['testimonial'] = JRequest::getVar('testimonial', '', 'post', 'string', JREQUEST_ALLOWRAW);
/* File Upload Command Start Here */
if($post['id']=='0'){
$db =& JFactory::getDBO();
$query="SELECT MAX(id) as id FROM #__jtestimonials_lists";
$db->setQuery($query);
$result = @$db->loadObject();
$postid=$result->id+1;
}

$filename = basename($_FILES['imagelocation']['name']);
if($filename){
$ext = substr($filename, strrpos($filename, '.') + 1);
if (($ext=="jpg")||($ext=="gif")||($ext=="png")||($ext=="bmp") && ($_FILES["imagelocation"]["size"] < 2000000)) {
$_FILES['imagelocation']['name']=$postid.".$ext";
$target = JPATH_BASE.'/administrator/components/com_jtestimonials/images/gallery/';
$target = $target . basename( $_FILES['imagelocation']['name']) ;
if(move_uploaded_file($_FILES['imagelocation']['tmp_name'], $target)){
$post['imagelocation']=$_FILES['imagelocation']['name'];
}
}
else{
JError::raiseWarning( 100, 'Only jpg, gif, png and bmp allowed to upload whos file size is 2MB or Smaller.' );
$this->setRedirect( 'index.php',$msg );
return false;
}
}
/* File Upload Command End Here */

if ($model->store($post)) {
$msg = JText::_( 'New Entry Has Been Submitted. Waiting For Approval.' );
} else {
$msg = JText::_( 'Error In New Entry.' );
}
$model->checkin();
$link = $_SERVER['HTTP_REFERER'];
$this->setRedirect( $link,$msg );
}

}
?>

Now this is the main controller which upload image then save the data into database. Now this controller call model to save the data. So let's open model file for this action.

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.model');


class jtestimonials_detailModeljtestimonials_detail extends JModel
{
var $_id = null;
var $_data = null;
var $_table_prefix = null;

function __construct()
{
parent::__construct();

$this->_table_prefix = '#__jtestimonials_';
$array = JRequest::getVar('cid', 0, '', 'array');
$this->setId((int)$array[0]);

}

function setId($id)
{
$this->_id = $id;
$this->_data = null;
}


function &getData()
{
if ($this->_loadData())
{}
else $this->_initData();

return $this->_data;
}

function checkin()
{
if ($this->_id)
{
$jtestimonials_detail = & $this->getTable();
if(! $jtestimonials_detail->checkin($this->_id)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
}
return false;
}
function checkout($uid = null)
{
if ($this->_id)
{
if (is_null($uid)) {
$user =& JFactory::getUser();
$uid = $user->get('id');
}
// Lets get to it and checkout the thing...
$jtestimonials_detail = & $this->getTable();


if(!$jtestimonials_detail->checkout($uid, $this->_id)) {
$this->setError($this->_db->getErrorMsg());
return false;
}

return true;
}
return false;
}

function _loadData()
{
if (empty($this->_data))
{
$query = 'SELECT * FROM '.$this->_table_prefix.'lists AS h'.
' WHERE h.id = '. $this->_id;
$this->_db->setQuery($query);
$this->_data = $this->_db->loadObject();
return (boolean) $this->_data;
}
return true;
}

function _initData()
{
if (empty($this->_data))
{
$detail = new stdClass();
$detail->id = 0;
$detail->name = null;
$detail->company = null;
$detail->position = null;
$detail->city = null;
$detail->state = null;
$detail->country = null;
$detail->email = null;
$detail->website = null;
$detail->date = null;
$detail->category = null;
$detail->testimonial = null;
$detail->imagelocation = null;
$detail->viewtemplate = 0;
$detail->checked_out = 0;
$detail->published = 0;
$detail->ordering = 0;
$detail->archived = 0;
$detail->approved = 0;
$detail->params = null;
$this->_data = $detail;
return (boolean) $this->_data;
}
return true;
}


function store($data)
{
$row =& $this->getTable();

if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}

if (!$row->id) {
$where = 'id = ' . $row->id ;
$row->ordering = $row->getNextOrder ( $where );
}

if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}

if (!$row->store()) {
$this->setError($this->_db->getErrorMsg());
return false;
}

return true;
}
}

?>

Now once we pass data to model , it then pass to table to finally store the data. so let's see table code for this:

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.model');

class Tablejtestimonials_detail extends JTable
{
var $id = null;
var $name = null;
var $company = null;
var $position = null;
var $city = null;
var $state = null;
var $country = null;
var $email = null;
var $website = null;
var $date = null;
var $category = null;
var $testimonial = null;
var $imagelocation = null;
var $viewtemplate = null;
var $checked_out = null;
var $published = null;
var $ordering = null;
var $archived = null;
var $approved = null;
var $params = null;

function Tablejtestimonials_detail(& $db) {
$this->_table_prefix = '#__jtestimonials_';
parent::__construct($this->_table_prefix.'lists', 'id', $db);
}


function bind($array, $ignore = '')
{
if (key_exists( 'params', $array ) && is_array( $array['params'] )) {
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = $registry->toString();
}

return parent::bind($array, $ignore);
}

function check()
{

if (trim($this->name) == '') {
$this->_error = JText::_('Must Have A Name.');
return false;
}

$query = 'SELECT id FROM '.$this->_table_prefix.'lists WHERE id = ' . $this->id;
$this->_db->setQuery($query);

$xid = intval($this->_db->loadResult());
return true;
}
}
?>

Finally this file will store the data into database. This is the basic function of front-end. This way you can make as many as you need view, controller, model and table.

Download Source Code

Add comment


Security code
Refresh