Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

How to use Joomla features through AJAX file

Submitted by on November 19, 2009 – 6:01 amNo Comment

AJAX is very popular now. So if you have a Joomla-based site, you can meet a problem of how to add AJAX there. This article will describe how to use features of Joomla 1.5 directly through AJAX file and will provide the code for this.

Of course, you can use AJAX in index.php file, but this can cause a lot of problems. Therefore I advise you to work directly with AJAX file and use all Joomla features there.

So, open AJAX file and make initialization of the required classes, variables and libraries:

<?php

global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_lang, $database, $mosConfig_mailfrom, $mosConfig_fromname;

require_once (‘configuration.php’);

define ( ‘_JEXEC’, 1 );

define ( ‘JPATH_BASE’, dirname ( __FILE__ ) );

define ( ‘DS’, DIRECTORY_SEPARATOR );

require_once (JPATH_BASE . DS . ‘includes’ . DS . ‘defines.php’);

require_once (JPATH_BASE . DS . ‘includes’ . DS . ‘framework.php’);

$mainframe = & JFactory::getApplication ( ‘site’ );

$mainframe->initialise ();

JPluginHelper::importPlugin ( ‘system’ );

$mainframe->triggerEvent ( ‘onBeforeStart’ );

$lang = & JFactory::getLanguage ();

$mosConfig_lang = $GLOBALS [‘mosConfig_lang’] = strtolower ( $lang->getBackwardLang () );

$mosConfig_live_site = str_replace ( ‘/administrator/components/com_virtuemart’, ”, JURI::base () );

$mosConfig_absolute_path = JPATH_BASE;

if (file_exists ( $mosConfig_absolute_path . ‘/language/’ . $mosConfig_lang . ‘.php’ )) {

require_once ($mosConfig_absolute_path . ‘/language/’ . $mosConfig_lang . ‘.php’);

} elseif (file_exists ( $mosConfig_absolute_path . ‘/language/english.php’ )) {

require_once ($mosConfig_absolute_path . ‘/language/english.php’);

}

When done, save the file. All regular Joomla features will be used in this file then. Thus you don’t need to create the unnecessary code because you already have access to the whole site through the AJAX file.

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.