In a joomla menu item page i placed same module instances multiple times(i duplicated in module manager).Now it's a severe requirement that some codes of my module have to be only one time in page.Because my module's each instance injects same code again and again. how to avoid it so that only some codes will appear in page only once when i have multiple module instances of my module in that same page? searching through web i found some unreliable ways -
1.Using session in module i track whether same module loading two or more times and restrict code injecting one time only
2.using a constant like this way -
if(!defined('MODULE_ALREADY_LOADED')){
//echo codes that you only want done once
//this will set the constant and now the other modules won't load/echo the code
define('MODULE_ALREADY_LOADED', true);
}
But not sure how much compatible the 2nd way is with joomla 2.5 as well as joomla 3 versions !.If there is a better error free way to do this then provide to me asap.