Joomla is an award-winning content management system (CMS), which enables you to build Web sites and powerful online applications. Many aspects, including its ease-of-use and extensibility, have made Joomla the most popular Web site software available. Best of all, Joomla is an open source solution that is freely available to everyone.
Joomla naming conventions, ajax, editor, datepicker, getVar, setVar, ajax, paging
List of topics which we will cover here
1) How to use ajax with Mootools.
2) How to use Calender in joomla
3) How to use Editor in joomla
4) Comman syntax which we will need.
5) Open lightbox in div/frame in joomla.
6) How to include js/css in joomla in header.
7) How to send email in joomla.
8) How to avoid confliction of mootools with jquery
1) How to use ajax in joomla
6) How to include js/css in header from template We can control the header from tmpl file or view.html.php This will include itself files in html header
Joomla naming conventions, ajax, editor, datepicker, getVar, setVar, ajax, paging
List of topics which we will cover here
1) How to use ajax with Mootools.
2) How to use Calender in joomla
3) How to use Editor in joomla
4) Comman syntax which we will need.
5) Open lightbox in div/frame in joomla.
6) How to include js/css in joomla in header.
7) How to send email in joomla.
8) How to avoid confliction of mootools with jquery
1) How to use ajax in joomla
<?php JHTML::_('behavior.mootools'); ?>2)How to use Calender following function will load automatically all the files/function which is required for calender following will create a calender
<script type="text/javascript">
function save_wedpro(id){
/*link of URL which will perform action*/
$link = 'index.php?option=com_search&task=save_wedpro&tmpl=ajax&id='+id;
/*$('updateid') This is div which we need to update*/
var myXHR = new Ajax(link, {update:$('updateid')});
myXHR.request();
}
<div id="updateid"></div>
<a href="javascript:void(0)" onClick="save_wedpro(100)">Update</a>
</script>
3) How to use editor following function will load automatically all the files/function which is required for editor
<?php
echo JHTML::_('calendar',$row->rota_date, 'name', 'id',$format = '%d-%m-%Y',array('class'=>'inputbox', 'size'=>'25', 'maxlength'=>'19')); ?>
You can also editor in other way It may be useful when you don't want to display the pagebreak,image,Readmore link below the editor By defaul it display all three button but if you dont't want then just declar in array array('image') means 'image' link will not be displayed
<?php echo editorArea( 'editor1', stripslashes($this->row->description) , 'description', '100%;', '600', '60', '50' ) ; ?>
4) Comman syntax for get the value 4 parameter */ 1 para=name of filed 2 para=default value means id not found (optional) 3 para=how will get the value get/post (optional) 4 para=type of field int,string (optional)
<?php
$editor = & JFactory::getEditor();
echo $editor->display( 'description', stripslashes($this->row->description) , '100%;', '550', '75', '20', array('image') ) ; ?>
for set the value of variable and you can also set the view,layout in view.html.php or in controller
<?php $id = JRequest::getVar('id', 0, 'get', 'int',); ?>
how to make object of model
<?php
JRequest::setVar('view', 'parties');
JRequest::setVar('layout', 'default'); ?>
<?php $model =& $this->getModel(); ?>get the login user details
<?php $my =& JFactory::getUser(); ?>make the database object
<?php $db =& JFactory::getDBO(); ?>instead of creating object of $my,$db you can user below also
<?php global $my,$database; ?>//get the layout of view
$layout = $this->getLayout();//to add the validation automatically on everypage you just need to declear below ths in view.html.php or tmpl file
<?phpApply class 'class="required"' to text box and 'form-validate' to the form as below
JHTML::_('behavior.formvalidation');
?>
<form class="form-validate">5) Lightbox in Div/Frame You can use lightbox on click event also you can set its demensions i.e. height,width you can view any url in lightbox
<input type="text" name="business_name" id="first_name" value="" class="inputbox required" maxlength="50" />
</form>
<?php JHTML::_( 'behavior.modal' ); ?>lightbox in frame
<script>
window.addEvent('domready', function() {
//below line is very imp for open lightbox
SqueezeBox.initialize({});
window.addEvent('load', function(){
});
});
</script>
<a class='modal' rel='{handler: "iframe", size: {x: 800, y: 410}}' id='modalWindowLink' href='index.php?option=com_guests&task=editparty&tmpl=component&id='>Open lightbox in frame</a>no frame just div only
<a class='modal' id='modalWindowLink' href='index.php?option=com_guests&task=editparty&tmpl=component&id='>lightbox</a>As i have passed "tmpl=component" in url this means that it will load only content section neither header,footer,left, right
6) How to include js/css in header from template We can control the header from tmpl file or view.html.php This will include itself files in html header
<?php//add js/css
$document = &JFactory::getDocument();
$document->addScript( '/media/system/js/sample.js' );7) Send email
$document->addStyleSheet ('/media/system/css/new_style.css');
//add meta tags
$document->setMetadata( 'keywords', $metaKeys );?>
<?php8) Conflict jquery with mootools Joomla by default use mootools but if any reason you need to use jquery alongwith mootools Then jquery will conflict with mootools because both use "$". to avoid this problem you should me make new new object of jquery by declaring below line
/* Last parameter has 1 means mail will send "html email" use 0 for "text email" */
JUtility::sendMail($mailfrom, $fromname, $email, $subject, $message,1);
?>
Now you should use jq instead of "$" for jquery;
<script type="text/javascript">
jq = jQuery.noConflict();
</script>
9) How to set the joomla errros Message
$areas=JRequest::getVar("areas",'',"post");------------------------------------------------------------------------- 1) Ajax with Mootools 2) Ajax with Prototype(JQuery) 3) Access Configuration file 4) Paging in 1.5 <?php 1)
//if area is empty then give a error msg in red color
if(empty($areas))
{
JError::raiseWarning('', JText::_( 'Please select atleast one service Area'));
//url to which u want to send
$mainframe->redirect('index.php?option=com_user&task=edit&step=5');
}
/* ajax replace element text */
window.addEvent('domready', function() {
/* ajax alert */
$('ajax-alert').addEvent('click', function(event) {
//prevent the page from changing
event.stop();
//make the ajax call
var req = new Request({
method: 'get',
url: $('ajax-alert').get('href'),
data: { 'do' : '1' },
onRequest: function() { alert('Request made. Please wait...'); },
onComplete: function(response) { alert('Response: ' + response); }
}).send();
});
2)Call an ajax and update div
$('ajax-replace').addEvent('click', function(event) {
//prevent the page from changing
event.stop();
//make the ajax call, replace text
var req = new Request.HTML({
method: 'get',
url: $('ajax-replace').get('href'),
data: { 'do' : '1' },
onRequest: function() { alert('Request made. Please wait...'); },
update: $('message-here'),
onComplete: function(response) { alert('Request completed successfully.'); $('message-here').setStyle('background','#fffea1');
}
}).send();
});
<script type="text/javascript" src="/templates/system/js/prototype.js"></script><?php
link = '<?php echo JRoute::_('index.php?option=com_guests&task=deleteparty&tmpl=ajax&id='); ?>' + id;
if(confirm('Are you sure to delete this task?')){
}
new Ajax.Updater('updatedID',link);
3)create object of config
$obj=new JConfig();4) Paging in Joomla
print_r($obj);
$limitstart=JRequest::getVar('limitstart',null,'request','int');
$limit=JRequest::getVar('limit',null,'request','int');
$query="";
$db->setQuery($query);
$total = $db->getNumRows();
jimport('joomla.html.pagination');
$pagination = new JPagination( $total, $limitstart, $limit );
$db->setQuery( $query, $pagination->limitstart, $pagination->limit );
$results = $db->loadObjectList();
echo $this->pagination->getPagesLinks();
Joomla is designed to be easy to install and set up even if you're not an advanced user. Many Web hosting services offer a single-click install, getting your new site up and running in just a few minutes.
Since Joomla is so easy to use, as a Web designer or developer, you can quickly build sites for your clients. Then, with a minimal amount of instruction, you can empower your clients to easily manage their own sites themselves.
0 Comment:
Post a Comment