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