Advertisement
desis123

JOOMLA IMPORTANT

Aug 16th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. Redirecting
  2. +++++++++++++
  3. $app = JFactory::getApplication();
  4.  
  5. $app->enqueueMessage('Redirect to another page was successful',
  6.  
  7. 'success');
  8. $app->redirect(JRoute::_('index.php'));
  9.  
  10.  
  11.  
  12. 2.
  13. $app = JFactory::getApplication();
  14. $link = 'http://www.minitek.gr/';
  15. $msg = 'You have been redirected to Minitek.gr';
  16. $app->redirect($link, $msg, $msgType='message');
  17. ============================================================
  18. Check User Logged in
  19. ++++++++++++++++++++++
  20.  
  21. $user = JFactory::getUser(); // Get the user object
  22. $app = JFactory::getApplication(); // Get the application
  23.  
  24. if ($user->id != 0)
  25. {
  26. // you are logged in
  27. }
  28. else
  29. {
  30. // Redirect the user
  31. $app->redirect(JRoute::_('index.php?
  32.  
  33. option=com_users&view=login'));
  34. }
  35.  
  36.  
  37. method 2
  38. ++++++++++++++++++
  39.  
  40. $user = JFactory::getUser();
  41.  
  42. return (!$user->get('guest')) ? 'logout' : 'login';
  43.  
  44. ====================================================================
  45.  
  46. Joomla accessing configuration
  47. ++++++++++++++++++++++++++++++++++++++
  48. $config = JFactory::getConfig();
  49. $fromname = $config->get('fromname');
  50.  
  51. =======================================================
  52. accessing database
  53. $db = JFactory::getDbo();
  54.  
  55.  
  56. $query = "SELECT * FROM `#__database_table_name` as whatever WHERE id = '$queryfid' ";
  57. $this->database->setQuery($query);
  58. $result = $this->database->loadObject();
  59. if (!$result)
  60.  
  61.  
  62.  
  63. TO INSERT
  64.  
  65. $Query = "INSERT INTO `#__database_table_name` (field1,field2) VALUES ('".$value1."','".$value2."')";
  66. $db->setQuery($Query);
  67. $db->query();
  68. setQuery does not execute Query, to execute, after that write $db->query();
  69. =========================================================
  70.  
  71. get current url joomla with query string
  72. ++++++++++++++++++++++++++++++++++++++++++++++++++++
  73. $uri = JUri::getInstance();
  74. echo $uri->toString();
  75.  
  76.  
  77.  
  78.  
  79. ============================================================
  80. JOOMLA SESSION
  81. +++++++++++++++++++++++++
  82. https://docs.joomla.org/How_to_access_session_variables_set_by_an_external_script
  83.  
  84.  
  85. ==================================================================
  86. USING COMPOSER INSIDE JOOMLA WITHOUT USING CORE JOOMLA COMPOSER
  87.  
  88. https://joomla.stackexchange.com/questions/16815/how-to-add-a-composer-package-without-modifying-the-core-composer-json-file
  89.  
  90. ====================================================================
  91. LOAD JOOMLA FROM EXTERNAL SCRIPT
  92.  
  93. https://www.minitek.gr/blog/how-to-load-the-joomla-framework-inside-an-external-file
  94.  
  95. define( '_JEXEC', 1 );
  96. define( '_VALID_MOS', 1 );
  97. define( 'JPATH_BASE', realpath(dirname(__FILE__)));
  98. define( 'DS', DIRECTORY_SEPARATOR );
  99. require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
  100. require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
  101. $mainframe = JFactory::getApplication('site');
  102. $mainframe->initialise();
  103. ++++++++++++++++++++++++++++++++++
  104. ======================================================================
  105. Access plugin params anywhere in joomla
  106. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  107. // Get plugin 'my_plugin' of plugin type 'my_plugin_type'
  108. $plugin = JPluginHelper::getPlugin('my_plugin_type', 'my_plugin');
  109.  
  110. // Check if plugin is enabled
  111. if ($plugin)
  112. {
  113. // Get plugin params
  114. $pluginParams = new JRegistry($plugin->params);
  115.  
  116. $param1 = $pluginParams->get('param1');
  117. $param2 = $pluginParams->get('param2');
  118. $param3 = $pluginParams->get('param3');
  119. }
  120. ==========================================================
  121. CALL MODULE INSIDE COMPONENT
  122. ++++++++++++++++++++++++++++++++++++++++++++++++++++
  123. jimport('joomla.application.module.helper'); //check its called or not
  124. $modules = JModuleHelper::getModules('header'); // header is module position
  125. foreach($modules as $module)
  126. {
  127. echo JModuleHelper::renderModule($module);
  128. }
  129.  
  130. also templateDetails.xml for position
  131.  
  132. ===============================================================
  133. Ajax in Joomla module
  134. https://stackoverflow.com/questions/13446333/putting-ajax-in-a-joomla-module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement