Showing posts with label Joomla. Show all posts
Showing posts with label Joomla. Show all posts

Tuesday, 18 July 2017

Uncaught ReferenceError: jQuery is not defined

Uncaught ReferenceError: jQuery is not defined
This is the most common JS error you got while using multiple jquery plugins in Joomla websie.
Following are main reasons for this error:
  • There is jQuery file being loaded in page.
    Check page source and confirm that jQuery is being loaded or not.
    Solution
    JHtml::_('jquery.framework');

    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 $.
  • There may be multiple jQuery files are being loaded in one page, and creating jQuery conflict.
    So, Make sure there will one jQuery loaded in one page.
    See Page source and remove extra loaded jQuery file(s).

Wednesday, 19 March 2014

How to store multiple jform fields under one field name in database in JSON formate

How to store multiple jform fields under one field name in database in JSON format.
For Instance,
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
you can use below code for it.

create all required fields in your view's xml file.
As per my example you have to create fields in
joomla/administrator/components/com_your_component/models/forms/plan.xml(your view's xml file)

After creating all required fields.
Overrides the store() function of JTable class in  below file and add following code in it.
joomla/administrator/components/com_your_component/table/plan.php(your view's table file)

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;
}

In this I have stored all the array value in "details" field of my table in database in JSON format.