tag:blogger.com,1999:blog-6759428492149386002024-02-07T00:19:18.127-08:00JoomlasticDeveloperCoding Tutorials for Joomla and PHP geek.Anonymoushttp://www.blogger.com/profile/14350611380873591430noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-675942849214938600.post-12925475453778188262017-07-18T23:37:00.001-07:002017-07-18T23:37:43.586-07:00Uncaught ReferenceError: jQuery is not defined<div dir="ltr" style="text-align: left;" trbidi="on">
Uncaught ReferenceError: jQuery is not defined<br />
This is the most common JS error you got while using multiple jquery plugins in Joomla websie.<br />
Following are main reasons for this error:
<ul>
<li>
There is jQuery file being loaded in page. <br/>
Check page source and confirm that jQuery is being loaded or not.<br/>
<b>Solution</b><br/>
<pre class="brush:php">JHtml::_('jquery.framework');</pre><br/>
This will load the jQuery version 1.11.1 library in no conflict mode. This means it is accessed via the jQuery namespace, not through $.
</li>
<li>
There may be multiple jQuery files are being loaded in one page, and creating jQuery conflict.<br/>
So, Make sure there will one jQuery loaded in one page.<br />
See Page source and remove extra loaded jQuery file(s).
</li>
</ul>
</div>
Anonymoushttp://www.blogger.com/profile/14350611380873591430noreply@blogger.com0India20.593684 78.962880000000041-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004tag:blogger.com,1999:blog-675942849214938600.post-75058459908922799562014-03-19T11:05:00.001-07:002014-07-15T06:09:56.447-07:00How to store multiple jform fields under one field name in database in JSON formate<div dir="ltr" style="text-align: left;" trbidi="on">
How to store multiple jform fields under one field name in database in JSON format.<br />
For Instance,<br />
if you want to store plan type(Forever, Fixed, Recurring...), plan price, Number of Recurring, Trial 1 time period, Trial 1 Price..etc information about plan into only one field name "details" into database, then<br />
you can use below code for it.<br />
<br />
create all required fields in your view's xml file.<br />
As per my example you have to create fields in<br />
joomla/administrator/components/com_your_component/models/forms/plan.xml(your view's xml file)<br />
<br />
After creating all required fields.<br />
Overrides the store() function of JTable class in below file and add following code in it.<br />
joomla/administrator/components/com_your_component/table/plan.php(your view's table file)<br />
<br />
<pre class="brush:php">public function store($updateNulls = false)
{
$input = JFactory::getApplication()->input;
$plandata = $input->post->get('jform', array(), array());
$details = array(
'type' => $plandata['type'],
'price' => $plandata['price'],
'expirationTime' => $plandata['expirationTime'],
'trial1price' => $plandata['trial1price'],
'trial1expirationTime' => $plandata['trial1expirationTime'],
'trial2price' => $plandata['trial2price'],
'trial2expirationTime' => $plandata['trial2expirationTime'],
'recurranceNumber' => $plandata['recurranceNumber']
);
$detailString = new JRegistry($details);
$this->details = $detailString->toString();
// Store the row
parent::store($updateNulls);
return true;
}
</pre>
<br />
In this I have stored all the array value in "details" field of my table in database in JSON format.<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/14350611380873591430noreply@blogger.com0tag:blogger.com,1999:blog-675942849214938600.post-63374063218877969492014-03-04T08:55:00.003-08:002014-06-28T08:57:49.921-07:00Create Search Tool in Joomla Component<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="line number1 index0 alt2" style="background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #333333; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 16px; height: auto !important; left: auto !important; line-height: 17.600000381469727px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;">
<br /></div>
<b>Create a search tool in Joomla component.</b><br />
<blockquote class="tr_bq">
<b>
create a file in administrator/component/com_your_component/models/forms/fileter_formname.xml</b><b>make sure that published and access field name is same as your database field name for this code only</b><b>.</b></blockquote>
If you are use different fields than their name are must same as your database field name.<br />
In this code I have used only published and access fields of my database.<br />
you can use as per your requirement.<br />
<b><br /></b>
<br />
<pre class="brush:xml"><?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
label="COM_YOUR_COMPONENT_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
>
<field
name="published"
type="status"
label="COM_YOUR_COMPONENT_FILTER_PUBLISHED"
description="COM_YOUR_COMPONENT_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value=>JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
onchange="this.form.submit();"
>
<option value=>JOPTION_SELECT_ACCESS</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_YOUR_COMPONENT_LIST_FULL_ORDERING"
description="COM_YOUR_COMPONENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="c.title ASC"
>
<option value=>JGLOBAL_SORT_BY</option>
<option value="c.published ASC">JSTATUS_ASC</option>
<option value="c.published DESC">JSTATUS_DESC</option>
<option value="c.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="c.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="c.access ASC">JGRID_HEADING_ACCESS_ASC</option>
<option value="c.access DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="c.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="c.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="inputbox input-mini"
default="25"
label="COM_YOUR_COMPONENT_LIST_LIMIT"
description="COM_YOUR_COMPONENT_LIST_LIMIT_DESC"
onchange="this.form.submit();"
>
</fields>
</form>
</pre>
add below code in <b>administrator/components/com_your_component/views/yourviewsfolder/tmpl/default.php</b><br />
<br />
<pre class="brush:php"><form action="<?php echo JRoute::_('index.php?option=com_your_component&view=yourviews'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<?php
/ Search tools bar
echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this));
?>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
</pre>
this code is creates search tool in your default view.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIHugCrXGAwWyYPXJG6ykSYf1e3D2dDvOiQJFL6A5HSmw5qcNqZ1QNU0Qw6S19uQVj4riridVs2OF7Gr5ggyFMTuaCKqfyb2tW9AwCHsD3uxuiQmNNtpnMjwbBDdIEhgyNi0mMwy-IGA/s1600/searchtool.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIHugCrXGAwWyYPXJG6ykSYf1e3D2dDvOiQJFL6A5HSmw5qcNqZ1QNU0Qw6S19uQVj4riridVs2OF7Gr5ggyFMTuaCKqfyb2tW9AwCHsD3uxuiQmNNtpnMjwbBDdIEhgyNi0mMwy-IGA/s1600/searchtool.png" height="46" width="640" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/14350611380873591430noreply@blogger.com1tag:blogger.com,1999:blog-675942849214938600.post-77712196657645990452014-03-01T20:16:00.003-08:002017-07-18T22:32:03.821-07:00Create Customize Filed in Joomla <div dir="ltr" style="text-align: left;" trbidi="on">
This code is used to create a customize field which is used to upload a image and display it while creating a new article or product in your component.<br />
It will display image when you edit any item from your component and you can upload other image.<br />
create a file in <b>administrator/components/com_your_component/models/filed/uploadimage.php</b><br />
<pre class="brush:php">/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
jimport('joomla.image.image');
/**
* Form Field class for the Joomla Framework.
*
* @since 0.0.6
*/
class JFormFieldUploadImage extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'UploadImage';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
$html = array();
$html[] = '<div class="button2-left">';
$html[] = '<input type="file" name="' . $this->name . '"/>';
$html[] = '</div>';
$html[] = '<div>';
$html[] = '<img src="' . JUri::root() . 'media/com_your_component/images/category/ ' . $this->value . '"/>';
$html[] = '<input type="hidden" value="' . $this->value . '" name="jform[hiddenimag e]"/>';
$html[] = '</div>';
return implode("\n", $html);
}
}
</pre>
<br />
create a file in<b> administrator/components/com_your_component/models/forms/uploadimage.xml</b><br />
<pre class="brush:xml"><?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field name="image"
default=""
type="UploadImage"
hide_none="1 "
label="COM_YOUR_COMPONENT_FIELD_PARAMS_IMAGE_LABEL"
description="COM_YOUR_COMPONENT_FIELD_PARAMS_IMAGE_DESC"
componentname="com_your_component"
/>
</fieldset>
</form>
</pre>
<div>
</div>
<div>
<br />
add <b>enctype="multipart/form-data"</b> attribute of the from in below file:<br />
<br />
<b>administrator/components/com_your_component/views/your_view/tmpl/edit.php</b><br />
In <b>administrator/component/com_your_component/models/your_model.php</b><br />
<b>write below code into save function</b><br />
<pre class="brush:php">$table = $this->getTable();
$input = JFactory::getApplication()->input;
$pk = (!empty($data['id'])) ? $data['id'] : (int) $this->getState($this->getName() . '.id');
$isNew = true;
$hiddenImage = array();
$hiddenImage = $input->post->get('jform', array(), array());
// Retrieve file details from uploaded file, sent from upload form
$file = $input->files->get('jform');
// Clean up filename to get rid of strange characters like spaces etc
$data['image'] = time() . '_' . JFile::makeSafe($file['image']['name']);
// Set up the source and destination of the file
$src = $file['image']['tmp_name'];
$dest = JPATH_SITE . '/media/com_your_component/images/category/' . $data['image'];
// First check if the file has the right extension, we need jpg only
if (!empty($file['image']['name']))
{
if (preg_match('/(.)+jpe*g|gif|png/i', $file['image']['name']))
{
if (!JFile::upload($src, $dest) )
{
$this->setError(JText::_('Invalid Image Type'));
return false;
}
else
{
unlink(JPATH_SITE . '/media/com_your_component/images/category/' . $hiddenImage['hiddenimage']);
}
}
}
elseif (!empty($hiddenImage['hiddenimage']))
{
$data['image'] = JFile::makeSafe($hiddenImage['hiddenimage']);
}
else
{
$this->setError(Jtext::_('Invalid Image Type Not upload condition..'));
return false;
}
</pre>
<br />
<div>
</div>
<b>
</b>
</div>
<div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/14350611380873591430noreply@blogger.com0