Tuesday, January 19, 2016

CodeIgniter Remove index.php By .htaccess

Steps To Remove index.php using .htaccess:-

Step:-1  Open the file config.php located in application/config path.  Find and Replace the below code in config.php  file.

//  Find the below code

$config['index_page'] = "index.php"

//  Remove index.php

$config['index_page'] = ""

Step:-2  Go to your CodeIgniter folder and create .htaccess  file.


 Path:

Your_website_folder/
application/
assets/
system/
user_guide/
.htaccess <--------- this file
index.php
license.txt

Step:-3  Write below code in .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Step:-4  In some cases the default setting for uri_protocol does not work properly. To solve this issue just open the file config.php located in application/config and then find and replace the code as:

//  Find the below code

$config['uri_protocol'] = "AUTO"

//  Replace it as

$config['uri_protocol'] = "REQUEST_URI" 

Thursday, January 14, 2016

Repeatable Form Field for Joomla

Joomla 3.2 added a nice feature introducing repeatable standard form field. Now it’s easy to add repeat fields just defined from the standard xml file of any joomla extensions. For each repeat box you can add multiple fields (joomla standard form fields ), means you can add fields under fields !

Now we will go more technical but will try our best to write it for new joomla developer.


<field name="list_templates" type="Repeatable" icon="list" description="PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_DESC"
label="PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_LABEL">
<fieldset hidden="true" name="list_templates_modal" repeat="true">
<field name="logoFile1" class="" type="media" default="" label="TPL_PROTOSTAR_LOGO_LABEL" description="TPL_PROTOSTAR_LOGO_DESC" />
</fieldset>
</field>

How to use two models in one view - Joomla 3


Sometimes you may wish to reuse a certain function that resides in a model outside of your current scope. This helps you save time and reduce duplication. This can be achieved easily by adding the following codes.

Assuming you are trying to call a model "Categories" (/components/com_mycomponent/models/categories.php) belonging to com_mycomponent (this can be called from either within or outside of the com_mycomponent):

jimport('joomla.application.component.model');
JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_mycomponent/models');
$categoriesModel = JModelLegacy::getInstance( 'Categories', 'MyComponentModel' );
$categoriesModel->getCategories();
<?php
JLoader::import('joomla.application.component.model');
// file name, full path
JLoader::import( 'product', JPATH_ADMINISTRATOR . DS . 'components' .
 DS . 'com_virtuemart' . DS . 'models' );

$productModel = JModel::getInstance( 'Product', 'VirtueMartModel' );
?>