Sunday, August 29, 2010

add custom field to com_google

Suppose that u need to add extra field call "Phone number" on your contact us page. Follow the steps bellow.

1.Open
components ->com_google->views->google->tmpl->default.php - on the front end

see the line no 302 and add






code to default.php file

2. Java Script validation
see function comGoogleFrmValidate(comfrm) on default.php file

and add to following code



user_tp_val= document.comGoogleForm.user_tp;
if(my_name.value == '')
{
errorStr += "Add Tp no\n";
user_tp_val.style.borderColor = "#FF0000";

}




3. Open controller.php file
components->com_google->controller.php

4.see the line 29
and modify the 'function sendMail() '

$user_tp= JRequest::getVar( 'user_tp', 0, '', 'text' );

And aslo update

$body = "From ".$friendEmail."\n".$messText."\n".$user_tp."\n";


if not clear ple comment

Saturday, August 28, 2010

joomla add edit delete record lesson 5

Ok today i am going to explain three tasks. Add / edit or delete records from joomla admin panel. we discussed about 'form' on last lesson. To do the management of above three task, use following files

1.com_lanka1->views->lanka1->tmpl->form.php
2.com_lanka1->views->lanka1->view.html.php
3.com_lanka1->controllers->lanka.php
4.com_lanka1->models->lanka1.php
5.com_lanka1->tables->lanka1.php



let's review on by one

1.com_lanka1->views->lanka1->tmpl->form.php



<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php
/**
* Lanka Map default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/
?>

<form action="index.php" method="post" name="adminForm" id="adminForm">
<div class="col100">
<fieldset class="adminform">
<legend><?php echo JText::_( 'Details' ); ?></legend>

<table class="admintable">

<tr>
<td width="100" align="right" class="key">
<label for="greeting">
<?php echo JText::_( 'Your name'); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="your_name" id="your_name" size="32" maxlength="250" value="<?php echo $this->Lanka->your_name;?>" />
</td>
</tr>
<tr>
<td width="100" align="right" class="key">
<label for="greeting">
<?php echo JText::_( 'Your email'); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="your_email" id="your_email" size="32" maxlength="250" value="<?php echo $this->Lanka->your_email;?>" />
</td>
</tr>
<tr>
<td width="100" align="right" class="key">
<label for="greeting">
<?php echo JText::_( 'Your TP'); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="your_tp" id="your_tp" size="32" maxlength="250" value="<?php echo $this->Lanka->your_tp;?>" />
</td>
</tr>
</table>
</fieldset>
</div>
<div class="clr"></div>

<input type="hidden" name="option" value="com_lanka1" />
<input type="hidden" name="id" value="<?php echo $this->Lanka->id; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="lanka" />
</form>







2.com_lanka1->views->lanka1->view.html.php



<?php
/**
* Lanka1 default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view' );

/**
* tp View
*
* @package Joomla.Tutorials
* @subpackage Components
*/

class Lanka1sViewLanka1 extends JView
{
/**
* display method of Hello view
* @return void
**/
function display($tpl = null)
{
//get the tp
$Lanka =& $this->get('Data');

$isNew = ($Lanka->id < 1);

$text = $isNew ? JText::_( 'New' ) : JText::_( 'Edit' );
JToolBarHelper::title( JText::_( 'Lanka1 ' ).': <small><small>[ ' . $text.' ]</small></small>' );
JToolBarHelper::save();
if ($isNew) {
JToolBarHelper::cancel();
} else {
// for existing items the button is renamed `close`
JToolBarHelper::cancel( 'cancel', 'Close' );
}

$this->assignRef('Lanka', $Lanka);

parent::display($tpl);
}
}





3.com_lanka1->controllers->lanka.php




<?php
/**
* Lanka1 default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/


// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
* Lanka1 Controller
*
* @package Joomla.component
* @subpackage Components
*/
class Lanka1sControllerLanka extends Lanka1sController
{
/**
* constructor (registers additional tasks to methods)
* @return void
*/
function __construct()
{
parent::__construct();

// Register Extra tasks
$this->registerTask( 'add' , 'edit' );
}

/**
* display the edit form
* @return void
*/
function edit()
{

JRequest::setVar( 'view', 'Lanka1' );
JRequest::setVar( 'layout', 'form' );
JRequest::setVar('hidemainmenu', 1);

parent::display();
}

/**
* save a record (and redirect to main page)
* @return void
*/
function save()
{
$model = $this->getModel('Lanka1');

if ($model->store($post)) {
$msg = JText::_( 'Lanka1 Saved!' );
} else {
$msg = JText::_( 'Error Saving Lanka1 ' );
}

// Check the table in so it can be edited.... we are done with it anyway
$link = 'index.php?option=com_Lanka1';
$this->setRedirect($link, $msg);
}

/**
* remove record(s)
* @return void
*/
function remove()
{
$model = $this->getModel('Lanka1');
if(!$model->delete()) {
$msg = JText::_( 'Error: One or More Lanka1 map Could not be Deleted' );
} else {
$msg = JText::_( ' Lanka1 Deleted' );
}

$this->setRedirect( 'index.php?option=com_Lanka1', $msg );
}

/**
* cancel editing a record
* @return void
*/
function cancel()
{
$msg = JText::_( 'Operation Cancelled' );
$this->setRedirect( 'index.php?option=com_Lanka1', $msg );
}
}




4.com_lanka1->models->lanka1.php



<?php
/**
* Lanka1 Map default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.model');


class Lanka1sModelLanka1 extends JModel
{
/**
* Constructor that retrieves the ID from the request
*
* @access public
* @return void
*/
function __construct()
{
parent::__construct();

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

/**
* Method to set the hello identifier
*
* @access public
* @param int Hello identifier
* @return void
*/
function setId($id)
{
// Set id and wipe data
$this->_id = $id;
$this->_data = null;
}

/**
* Method to get a hello
* @return object with data
*/
function &getData()
{


// Load the data
if (empty( $this->_data )) {
$query = ' SELECT * FROM #__contactus '.
' WHERE id = '.$this->_id;
$this->_db->setQuery( $query );
$this->_data = $this->_db->loadObject();
}

if (!$this->_data) {
$this->_data = new stdClass();
$this->_data->id = 0;
$this->_data->your_name = null;
$this->_data->your_email = null;
$this->_data->your_tp = null;


}

return $this->_data;
}

/**
* Method to store a record
*
* @access public
* @return boolean True on success
*/
function store()
{



$row =& $this->getTable();

$data = JRequest::get( 'post' );


// Bind the form fields to the hello table
if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}

// Make sure the hello record is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}

// Store the web link table to the database
if (!$row->store()) {
$this->setError( $row->getErrorMsg() );
return false;
}

return true;
}

/**
* Method to delete record(s)
*
* @access public
* @return boolean True on success
*/
function delete()
{
$cids = JRequest::getVar( 'cid', array(0), 'post', 'array' );

$row =& $this->getTable();

if (count( $cids )) {
foreach($cids as $cid) {
if (!$row->delete( $cid )) {
$this->setError( $row->getErrorMsg() );
return false;
}
}
}
return true;
}

}





5.com_lanka1->tables->lanka1.php




<?php
/**
* Google Map default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/


// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );


class TableLanka1 extends JTable
{
/**
* Primary Key
*
* @var int
*/
var $id = null;
var $your_name = null;
var $your_email = null;
var $your_tp = null;


/**
* Constructor
*
* @param object Database connector object
*/
function TableLanka1(& $db) {
parent::__construct('#__contactus', 'id', $db);
}
}

Tuesday, August 24, 2010

Easy to hack Joomla

Suppose your friends ask
Hi Machan [ = mate / buddy], Does it easy to hack Joomla? wt is your answer?. Actually your answer is yes. Today, I found hacking code of joomla web sites which can delete all the file and folder on joomla site. Do you know this hacking force to my web site and delete all the files and folders on today.

Normally I backup all the thing on daily basis. So The site has been successfully launch again within one hour. For the use of your awareness,  here is the link of that hanking code.



[ Machan = Mate/buddy ]


wAp

Sunday, July 25, 2010

Joomla com_google - Translation to PORTUGUESE, BRASIL

This is the translation file of PORTUGUESE, BRASIL on the com_google component. Translation done by, one of the person who interest about com_google component.
pt-BR.com_google.ini

Monday, July 5, 2010

com_google new release 2010 07 05

Today we release new version of com_google with following features

1. All front end text can handle from admin panel
2. Easy to manage front end appearance
3. Language friendly
4. Popup box of Google map consist with Image and brief details

Download link com_google


wAp

Sunday, July 4, 2010

Content of form.php joomla part 4

We already discussed the behaviours of controllers in the last tutorial. Now it is time to learn the syntax of ‘form.php’ and ‘view.html.php’.

form.php use for both data insert and edit.

Here is the sample code of form.php
com_lanka1->views->lanka1->tmpl->form.php




<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php
/**
* Lanka Map default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/
?>

<form action="index.php" method="post" name="adminForm" id="adminForm">
<div class="col100">
<fieldset class="adminform">
<legend><?php echo JText::_( 'Details' ); ?></legend>

<table class="admintable">

<tr>
<td width="100" align="right" class="key">
<label for="greeting">
<?php echo JText::_( 'Your name'); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="greeting" id="greeting" size="32" maxlength="250" value="<?php echo $this->lanka1->your_name;?>" />
</td>
</tr>
<tr>
<td width="100" align="right" class="key">
<label for="greeting">
<?php echo JText::_( 'Your email'); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="greeting" id="greeting" size="32" maxlength="250" value="<?php echo $this->lanka1->your_email;?>" />
</td>
</tr>
<tr>
<td width="100" align="right" class="key">
<label for="greeting">
<?php echo JText::_( 'Your TP'); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="greeting" id="greeting" size="32" maxlength="250" value="<?php echo $this->lanka1->your_tp;?>" />
</td>
</tr>
</table>
</fieldset>
</div>
<div class="clr"></div>

<input type="hidden" name="option" value="com_lanka1" />
<input type="hidden" name="id" value="<?php echo $this->lanka1->id; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="lanka" />
</form>






Not only form.php but also view.html.php is essential to success this stage
com_lanka1->views->lanka1->view.html.php




<?php
/**
* Lanka1 default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view' );

/**
* tp View
*
* @package Joomla.Tutorials
* @subpackage Components
*/

class Lanka1sViewLanka1 extends JView
{
/**
* display method of Hello view
* @return void
**/
function display($tpl = null)
{
//get the tp
$Lanka1 =& $this->get('Data');
$isNew = ($Lanka1->id < text =" $isNew">[ ' . $text.' ]' );
JToolBarHelper::save();
if ($isNew) {
JToolBarHelper::cancel();
} else {
// for existing items the button is renamed `close`
JToolBarHelper::cancel( 'cancel', 'Close' );
}

$this->assignRef('Lanka1', $Lanka1);

parent::display($tpl);
}
}


once you click edit/new button, It will go to following page



join with next

wAp

Enable spam checking - com_google joomla

How do you enable the spam checking on your com_google component?

Steps
1. Log to joomla admin panel
2. Load com_google component
3. Select contact us link
4. Click Edit button
3. Select "Yes" from "Do you need to add SPAM checking:" drop down menu
4. Save it

Ple see the following img
3. Now see the contact us page

Why I cannot see the captcha image?
The support of Hosting server for the GID Images will affect to load captcha image in proper way. So it's essential to enable GID extension on your web server


wAp



Friday, July 2, 2010

Add new record to table Joomla component part 3

Lesson part 2, used to Describe only displaying information from table. But do you know how to add recodes to table? Answer is Nop.

Ok let's see how to insert data to table. Can u see there is button called "New"? Admin panel will popup html form once you click "New" button. What are the place and which are the file we used in here?

1.First Change
open - com_lanka1->views->lanka1s->tmpl->default.php

can u see there is code like,


<input type="hidden" name="controller" value="lanka1"/>



In above code, ple change "lanka" instead of" lanka1" where value of controller

2.Add new controller
add new folder "controllers" to your component folder[com_lanka1]
make new file "lanka.php"
com_lanka1->controllers->lanka.php





<?php
/**
* Lanka1 default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/


// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
* Lanka1 Controller
*
* @package Joomla.component
* @subpackage Components
*/
class Lanka1sControllerLanka extends Lanka1sController
{
/**
* constructor (registers additional tasks to methods)
* @return void
*/
function __construct()
{
parent::__construct();

// Register Extra tasks
$this->registerTask( 'add' , 'edit' );
}

/**
* display the edit form
* @return void
*/
function edit()
{

JRequest::setVar( 'view', 'Lanka1' );
JRequest::setVar( 'layout', 'form' );
JRequest::setVar('hidemainmenu', 1);

parent::display();
}

/**
* save a record (and redirect to main page)
* @return void
*/
function save()
{
$model = $this->getModel('Lanka1');

if ($model->store($post)) {
$msg = JText::_( 'Lanka1 map Saved!' );
} else {
$msg = JText::_( 'Error Saving Lanka1 ' );
}

// Check the table in so it can be edited.... we are done with it anyway
$link = 'index.php?option=com_Lanka1';
$this->setRedirect($link, $msg);
}

/**
* remove record(s)
* @return void
*/
function remove()
{
$model = $this->getModel('Lanka1');
if(!$model->delete()) {
$msg = JText::_( 'Error: One or More Lanka1 map Could not be Deleted' );
} else {
$msg = JText::_( ' Lanka1 map(s) Deleted' );
}

$this->setRedirect( 'index.php?option=com_Lanka1', $msg );
}

/**
* cancel editing a record
* @return void
*/
function cancel()
{
$msg = JText::_( 'Operation Cancelled' );
$this->setRedirect( 'index.php?option=com_Lanka1', $msg );
}
}

Can u see wt are the code of function edit()
  1. JRequest::setVar( 'view', 'Lanka1' ); call Lanka1 folder under view folder
  2. JRequest::setVar( 'layout', 'form' ); call form.php
  3. JRequest::setVar('hidemainmenu', 1); hide main manu

Next lesson will explain about form.php

wAp

Thursday, July 1, 2010

Edit Color and Font on com_google

[download 3d google map from com_google]

Ple open default.php file from component folder

components->com_google->views->google->tmpl->default.php file

see line 241 to 260,





<table border="0" cellpadding="4" cellspacing="5">
<tr>
<td valign="top">
<div align="left">
<p><strong><?php echo $conArr[0]->greeting; ?></strong></p>
<p><?php echo nl2br($conArr[0]->mapAddress); ?></p>
<p><label id="contact_emailmsg" for="contact_email">
<?php echo JText::_( 'GOOGLE_CON_TP' );?>
</label>: <?php echo $conArr[0]->mapTp; ?></p>
<p><label id="contact_emailmsg" for="contact_email">
<?php echo JText::_( 'GOOGLE_CON_PHONE' );?>
</label>: <?php echo $conArr[0]->mapPhone; ?></p>
<p><label id="contact_emailmsg" for="contact_email">
<?php echo JText::_( 'GOOGLE_CON_FAX' );?>
</label>: <?php echo $conArr[0]->mapFax; ?></p>
<p><label id="contact_emailmsg" for="contact_email">
<?php echo JText::_( 'GOOGLE_CON_YOUR_EMAIL' );?>
</label>:<a href="mailto:<?php echo $conArr[0]->mapEmail; ?>"> <?php echo $conArr[0]->mapEmail; ?></a></p>
</div>
</td>
<td>




you can style above part as per your web page css

wAp

Advance joomla component with table connection part 2

After completing Part 1, your administration panel will appear as follows:




This part is used to describe data which is loaded from tables. As you already understand, modules are used to load table information. This part use to describe data loading from tables. You already know, modules used to load table information. In here we use two modules

administrator->components->com_lanka1->models->lanka1.php

Use these four functions:
  • setId()
  • getData()
  • store()
  • delete()

<?php
/**
* Lanka1 default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.model');


class Lanka1sModelLanka1 extends JModel
{
/**
* Constructor that retrieves the ID from the request
*
* @access public
* @return void
*/
function __construct()
{
parent::__construct();

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

/**
* Method to set the hello identifier
*
* @access public
* @param int Hello identifier
* @return void
*/
function setId($id)
{
// Set id and wipe data
$this->_id = $id;
$this->_data = null;
}

/**
* Method to get a hello
* @return object with data
*/
function &getData()
{


// Load the data
if (empty( $this->_data )) {
$query = ' SELECT * FROM #__contactus '.
' WHERE id = '.$this->_id;
$this->_db->setQuery( $query );
$this->_data = $this->_db->loadObject();
}
if (!$this->_data) {
$this->_data = new stdClass();
$this->_data->id = 0;
$this->_data->your_name = null;
$this->_data->your_email = null;
$this->_data->your_tp = null;


}
return $this->_data;
}

/**
* Method to store a record
*
* @access public
* @return boolean True on success
*/
function store()
{



$row =& $this->getTable();

$data = JRequest::get( 'post' );

// Bind the form fields to the hello table
if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}

// Make sure the hello record is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}

// Store the web link table to the database
if (!$row->store()) {
$this->setError( $row->getErrorMsg() );
return false;
}

return true;
}

/**
* Method to delete record(s)
*
* @access public
* @return boolean True on success
*/
function delete()
{
$cids = JRequest::getVar( 'cid', array(0), 'post', 'array' );

$row =& $this->getTable();

if (count( $cids )) {
foreach($cids as $cid) {
if (!$row->delete( $cid )) {
$this->setError( $row->getErrorMsg() );
return false;
}
}
}
return true;
}

}






administrator->components->com_lanka1->models->lanka1s.php

Use these two functions:
  • _buildQuery()
  • getData()

<?php
/**
* Lanka1 default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.model' );


class Lanka1sModelLanka1s extends JModel
{

var $_data;


/**
* Returns the query
* @return string The query to be used to retrieve the rows from the database
*/
function _buildQuery()
{
$query = ' SELECT * '
. ' FROM #__contactus '
;

return $query;
}

/**
* Retrieves the hello data
* @return array Array of objects containing the data from the database
*/
function getData()
{
// Lets load the data if it doesn't already exist
if (empty( $this->_data ))
{
$query = $this->_buildQuery();
$this->_data = $this->_getList( $query );
}

return $this->_data;
}
}
Table information is displayed row by row once you add these two files to your component.

next lesson
wAp

Wednesday, June 30, 2010

Advance joomla component with table connection part 1

The following image shows the appearance of the admin panel of our component. Ok, let's try to load the table data [jos_contactUs] to here. For that we need to modify default.php form with the following code: -



com_lanka1->views->lanka1s->tmpl->default.php


<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php
/**
* Google Map default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/
?>
<form action="index.php" method="post" name="adminForm">
<div id="editcell">
<table class="adminlist">
<thead>
<tr>
<th width="5">
<?php echo JText::_( 'ID' ); ?>
</th>
<th width="20">
<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
</th>
<th>
<?php echo JText::_( 'Telephone List' ); ?>
</th>
</tr>
</thead>
<?php
$k = 0;
for ($i=0, $n=count( $this->items ); $i < $n; $i++) {
$row = &$this->items[$i];
$checked = JHTML::_('grid.id', $i, $row->id );
$link = JRoute::_( 'index.php?option=com_lanka1&controller=lanka1&task=edit&cid[]='. $row->id );
?>
<tr class="<?php echo "row$k"; ?>">
<td>
<?php echo $row->id; ?>
</td>
<td>
<?php echo $checked; ?>
</td>
<td>
<a href="<?php echo $link; ?>"><?php echo $row->your_name; ?></a>
</td>
</tr>
<?php
$k = 1 - $k;
}
?>
</table>
</div>

<input type="hidden" name="option" value="com_lanka1" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="lanka1" />
</form>





The last part of above code is very important, from the
<input type="hidden" name="option" value="">a1" />
to the
</form>






Note only default.php but also view.html.php is essential to success this stage

com_lanka1->views->lanka1s->view.html.php

<?php
/**
* Lanka1 default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view' );

/**
* lanka1 View
*
* @package Joomla.component
* @subpackage Components
*/
class Lanka1sViewLanka1s extends JView
{
/**
* lanka1 view display method
* @return void
**/
function display($tpl = null)
{
JToolBarHelper::title( JText::_( 'Lanka1' ), 'generic.png' );
JToolBarHelper::deleteList();
JToolBarHelper::editListX();
JToolBarHelper::addNewX();

// Get data from the model
$items = & $this->get( 'Data');

$this->assignRef('items', $items);

parent::display($tpl);
}
}




This is first time we've used a module . On an MVC system, module is used to make a relationship between a table and a component.

In our example, we use two modules, lanka1.php and lanka1s.php as follows
com_lanka1->models->lanka1.php
com_lanka1->models->lanka1s.php

Click on the following link to go to the next lesson:

wAp


Friday, June 25, 2010

Advance joomla component with table connection

You already know basic concept of joomla component. From today, we can study advance level of example which cover table connection and proper management of admin panel. Before start this lesson, ple download previous "simple example joomla component". and install it.


Ok now we are ready to going forward with this lesson. have u any target? or have u any thing which need to apply joomla? Yes as a Example we can define our requirement as follows.

Target - telephone number storing system
Table attributes - Your name / Your Email / Your Tp
Sql -
CREATE TABLE `jos_contactUs` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`your_name` VARCHAR( 100 ) NOT NULL ,
`your_email` VARCHAR( 100 ) NOT NULL ,
`your_tp` VARCHAR( 10 ) NOT NULL
)
step 01
manually run above sql on your DB

join with next lesson

wAp


Tuesday, May 25, 2010

com_google manage mail from contact form joomla

currently there is no way to manage this from admin panel. All out going mail send through the info@xxxx.yyy address.

How ever u can follow following step to solve this issue

Steps
1.find components/com_google/controller.php - from fron end
2.see line no 46 - $from ="info@".$_SERVER['HTTP_HOST'];
3. change it as per your desire

$from ="info@mydesire.com";


if u have any ques ple comment here

new release can change 'from Email address'
http://extensions.joomla.org/extensions/contacts-and-feedback/contact-details/9264

wAp

Sunday, May 23, 2010

1 simple example joomla component

Already we have discussed about "How to make a Joomla component".

For that follows 5 stages as below

Download all above step as once component , "simple example joomla component "


There is simple variation on the "install.xml". Added new 4 line to it as below

lanka1.php
index.html
controller.php
views/lanka1s/view.html.php
views/lanka1s/tmpl/default.php


New install.xml file

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/component-install.dtd">
<install type="component" version="1.5.0">
<name>lanka1</name>
<!-- The following elements are optional and free of formatting conttraints -->
<creationDate>2009/10/24 </creationDate>
<author>wapnishantha</author>
<authorEmail>info@inetlanka.com</authorEmail>
<authorUrl>http://www.inetlanka.com</authorUrl>
<copyright>com_lanka1 2009</copyright>
<license>GNU/GPL</license>
<!-- The version string is recorded in the components table -->
<version>1.0.0</version>
<!-- The description is optional and defaults to the name -->
<description>
<![CDATA[
This component is a Flight System. <br />
]]>
</description>
<!-- Site Main File Copy Section -->
<files folder="site">

<filename>index.html</filename>

</files>


<administration>
<!-- Administration Menu Section -->
<menu>com_lanka</menu>
<!-- Administration Main File Copy Section -->
<!-- Note the folder attribute: This attribute describes the folder
to copy FROM in the package to install therefore files copied
in this section are copied from /admin/ in the package -->
<files folder="admin">
<!-- Site Main File Copy Section -->

<filename>lanka1.html</filename>
<filename>index.html</filename>
<filename>controller.html</filename>
<filename>views/lanka1s/view.html.php</filename>
<filename>views/lanka1s/tmpl/default.php</filename>



</files>

</administration>

</install>




wAp

Saturday, May 22, 2010

change com_google Thanks for you !

Do u know how to change the text[Thanks for you !] of com_google component?

yes it's very easy

there are 2 method

1. This is right way
find the "en-GB.com_google.ini" from

language->en-GB->en-GB.com_google.ini

And change "Thanks for you !" with ur desire ...........

2. Easy way to developers

find the file "controller.php" from

components->com_google->controller.php

go to line No 60 or find out this code "$msg = JText::_('GOOGLE_THANKS'); "

on there u can put any text instead of "GOOGLE_THANKS"


Enjoy with joomla .............

wAp

Layout "default" not found - joomla

last time we reach up to view stage. But there also we face 'Layout "default" not found' error.
let see to solve this


see our folder structure
administrator->components->com_lanka1->views->lanka1s->

On here u need to make a new folder call "tmpl" and also make new file "default.php"

then it show as follows
administrator->components->com_lanka1->views->lanka1s->tmpl->default.php

can u think wt are the codes need to store "default.php"?

yes see following code

No need any code to here to see our final out put ................ he he he





see the final out put............ and enjoy with it. First step is successfully finished



wAp

500 - An error has occurred - joomla

Do u remember last time error? if not ple go here

"View not found [name, type, prefix]: lanka1s,html,lanka1sView" wt is this? this say, there is not 'view' page on this component. So today we can lean about 'how to make a view pages'

MVC or module view component, Now we are in view stage, For this we need new folder to store template files or view pages.

Ple make a new folder call "views" under that", again make a new folder call "lanka1s" and "view.html.php" file on there

see our folder structure
administrator->components->com_lanka1->views->lanka1s->view.html.php

see the content of "view.html.php"






<?php

/**
* Lanka1 default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view' );

/**
* lanka1 View
*
* @package Joomla.component
* @subpackage Components
*/
class Lanka1sViewLanka1s extends JView
{
/**
* lanka1 view display method
* @return void
**/
function display($tpl = null)
{
JToolBarHelper::title( JText::_( 'Lanka1' ), 'generic.png' );
JToolBarHelper::deleteList();
JToolBarHelper::editListX();
JToolBarHelper::addNewX();




parent::display($tpl);
}
}




ooooop's he he ................ can u see there is another error


wt are the new things of this code
1.JToolBarHelper::title( JText::_( 'Lanka1' ), 'generic.png' );
this is use to set the TITLE of the page and can use existing image to take a handy look :D

2.JToolBarHelper::deleteList();
On this stage we do not need this but in future we need to delete items

3.JToolBarHelper::editListX();
On this stage we do not need this but in future we need to edit items

4. JToolBarHelper::addNewX()
On this stage we do not need this but in future we need to add items


ple connect with next lesson to solve above issue

wAp

Wednesday, April 28, 2010

failed to open stream - joomla

Following error occur on last time article. Now we try to solve this issue ...............
"
Warning: require_once(C:\AppServ\www\Joomla\administrator\components\com_lanka1\controller.php) [function.require-once]: failed to open stream: No such file or directory in C:\AppServ\www\Joomla\administrator\components\com_lanka1\lanka1.php on line 17

Fatal error: require_once() [function.require]: Failed opening required 'C:\AppServ\www\Joomla\administrator\components\com_lanka1\controller.php' (include_path='.;C:\php5\pear') in C:\AppServ\www\Joomla\administrator\components\com_lanka1\lanka1.php on line 17
"

Wt is this error? Yes this is arising due to MVC. Base on MVC structure, our component automatically find "controller.php" file. But at the moment it is not in our com_lanka1 folder.

we can use any name for this. But standard naming is important. see the code of "lanka1.php" can u see

"require_once( JPATH_COMPONENT.DS.'controller.php' );"

code on their? Mmm ... this is the reason arrising above file not found issue.

Following code show the simple syntax of controller.php file


<?php
/**
* Lanka1 default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.controller');

/**
* Lanka1 Component Controller
*
* @package Joomla.component
* @subpackage Components
*/
class Lanka1sController extends JController
{
/**
* Method to display the view
*
* @access public
*/
function display()
{
parent::display();
}
}



Can u guess the essential part of this code? Mmm ...........

yes it is "class Lanka1sController extends JController". Look wt is the text it use. "Lanka1sController" In this word, [ Did u remeber?our component name is com_lanka1 ]. Here we take it as lanka1s. must remember this "S" is very importent. And also our class extend to core joomla class through the "JController"

ok when after adding "controller.php" to our testing component [administrator ->components->com_lanka1->controller.php]. again visit following link, from joomla admin [ http://YOUR JOOMLA PATH/administrator/index.php?option=com_lanka1 ]



Is this the error? yes this is the error we face on this stage.

continue with next lesson

wAp

Saturday, April 24, 2010

Fixing "Component Not Found" - joomla

Ok last time we got following error

let see how to solve this issue. Issue say about "Component Not Found". That means there is no such a component on our code.

ple go folder structure
administrator ->components->com_lanka1

There is only 2 files [index.html / install.xml]. From now, we have to develop MVC structure base coding.

First File you need to add "com_lanka1" folder is "lanka1.php" And code show as follows



<?php
/**
* com_lanka default controller
*
* @package Joomla.component
* @subpackage Components
* @link http://inetlanka.com
* @license GNU/GPL
* @auth inetlanka web team - [ info@inetlanka.com / wapnishantha@gmail.com ]
*/

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Require the base controller

require_once( JPATH_COMPONENT.DS.'controller.php' );

// Require specific controller if requested
if($controller = JRequest::getWord('controller')) {
$path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';
if (file_exists($path)) {
require_once $path;
} else {
$controller = '';
}
}

// Create the controller
$classname = 'Lanka1sController'.$controller;
$controller = new $classname( );

// Perform the Request task
$controller->execute( JRequest::getVar( 'task' ) );

// Redirect if set by the controller
$controller->redirect();




then try to again brows
"http://YOUR JOOMLA PATH/administrator/index.php?option=com_lanka1"


It is must, showing above error on your web page. other wise there is another issue on ur code

next time we will fix this issue

wAp

Friday, February 26, 2010

make simple one

Ok, Lets see how to write simple component .....
XML file is the main config file. In here we can see very simple XML file.

ple download this
http://computerlanguage.inetlanka.com/sample/com_lanka1.zip



and install it.


ok let see what is on.....
XML - install.xml
XML file is very important because it consist with all images / files/ and settings. so u have to clear this first. Download com_lanka1.zip and extract it. their u can see install.xml file and some of code.
ok Now we can go line by line on XML file.



<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/component-install.dtd">
<install type="component" version="1.5.0">
<name>lanka1</name>
<!-- The following elements are optional and free of formatting conttraints -->
<creationDate>2009/10/24 </creationDate>
<author>iNetlanka</author>
<authorEmail>info@inetlanka.com</authorEmail>
<authorUrl>http://www.inetlanka.com</authorUrl>
<copyright>com_lanka1 2009</copyright>
<license>GNU/GPL</license>
<!-- The version string is recorded in the components table -->
<version>1.0.0</version>
<!-- The description is optional and defaults to the name -->
<description>
<![CDATA[
This component is a Flight System. <br />
]]>
</description>
<!-- Site Main File Copy Section -->
<files folder="site">

<filename>index.html</filename>

</files>


<administration>
<!-- Administration Menu Section -->
<menu>com_lanka</menu>
<!-- Administration Main File Copy Section -->
<!-- Note the folder attribute: This attribute describes the folder
to copy FROM in the package to install therefore files copied
in this section are copied from /admin/ in the package -->
<files folder="admin">
<!-- Site Main File Copy Section -->

<filename>index.html</filename>



</files>

</administration>

</install>




admin - this is folder which include all admin relevant files
site - this is folder which include all front end user relevant files


now ple go following link or use 'com_lanka' MENU under component category
http://YOUR WEB SITE NAME OR LOCAL HOST /administrator/index.php?option=com_lanka1

now u can see following img


Ohhh error!!!! why is this? do not worry we use trail and error fixing method ....

connect with next post
wAp

Saturday, January 9, 2010

what is MVC and Joomla

I am not going to say about history of joomla or how we reached up to MVC. I give my full effort to describe about 'how to write joomla component' base on MVC structure.

As first lesson,

1.what are the minimal requirement to develop component
admin folder
site folder
install.xml file

And these lesson going foreword on new method which explain each step from trial and error fixing method. so we can face actual issue which arise though the coding of component

join with next post ....

wAp