Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Redirecting
- +++++++++++++
- $app = JFactory::getApplication();
- $app->enqueueMessage('Redirect to another page was successful',
- 'success');
- $app->redirect(JRoute::_('index.php'));
- 2.
- $app = JFactory::getApplication();
- $link = 'http://www.minitek.gr/';
- $msg = 'You have been redirected to Minitek.gr';
- $app->redirect($link, $msg, $msgType='message');
- ============================================================
- Check User Logged in
- ++++++++++++++++++++++
- $user = JFactory::getUser(); // Get the user object
- $app = JFactory::getApplication(); // Get the application
- if ($user->id != 0)
- {
- // you are logged in
- }
- else
- {
- // Redirect the user
- $app->redirect(JRoute::_('index.php?
- option=com_users&view=login'));
- }
- method 2
- ++++++++++++++++++
- $user = JFactory::getUser();
- return (!$user->get('guest')) ? 'logout' : 'login';
- ====================================================================
- Joomla accessing configuration
- ++++++++++++++++++++++++++++++++++++++
- $config = JFactory::getConfig();
- $fromname = $config->get('fromname');
- =======================================================
- accessing database
- $db = JFactory::getDbo();
- $query = "SELECT * FROM `#__database_table_name` as whatever WHERE id = '$queryfid' ";
- $this->database->setQuery($query);
- $result = $this->database->loadObject();
- if (!$result)
- TO INSERT
- $Query = "INSERT INTO `#__database_table_name` (field1,field2) VALUES ('".$value1."','".$value2."')";
- $db->setQuery($Query);
- $db->query();
- setQuery does not execute Query, to execute, after that write $db->query();
- =========================================================
- get current url joomla with query string
- ++++++++++++++++++++++++++++++++++++++++++++++++++++
- $uri = JUri::getInstance();
- echo $uri->toString();
- ============================================================
- JOOMLA SESSION
- +++++++++++++++++++++++++
- https://docs.joomla.org/How_to_access_session_variables_set_by_an_external_script
- ==================================================================
- USING COMPOSER INSIDE JOOMLA WITHOUT USING CORE JOOMLA COMPOSER
- https://joomla.stackexchange.com/questions/16815/how-to-add-a-composer-package-without-modifying-the-core-composer-json-file
- ====================================================================
- LOAD JOOMLA FROM EXTERNAL SCRIPT
- https://www.minitek.gr/blog/how-to-load-the-joomla-framework-inside-an-external-file
- define( '_JEXEC', 1 );
- define( '_VALID_MOS', 1 );
- define( 'JPATH_BASE', realpath(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();
- ++++++++++++++++++++++++++++++++++
- ======================================================================
- Access plugin params anywhere in joomla
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- // Get plugin 'my_plugin' of plugin type 'my_plugin_type'
- $plugin = JPluginHelper::getPlugin('my_plugin_type', 'my_plugin');
- // Check if plugin is enabled
- if ($plugin)
- {
- // Get plugin params
- $pluginParams = new JRegistry($plugin->params);
- $param1 = $pluginParams->get('param1');
- $param2 = $pluginParams->get('param2');
- $param3 = $pluginParams->get('param3');
- }
- ==========================================================
- CALL MODULE INSIDE COMPONENT
- ++++++++++++++++++++++++++++++++++++++++++++++++++++
- jimport('joomla.application.module.helper'); //check its called or not
- $modules = JModuleHelper::getModules('header'); // header is module position
- foreach($modules as $module)
- {
- echo JModuleHelper::renderModule($module);
- }
- also templateDetails.xml for position
- ===============================================================
- Ajax in Joomla module
- https://stackoverflow.com/questions/13446333/putting-ajax-in-a-joomla-module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement