call plugin in joomla component - plugins

How can i call joomla 'Simple Picture Slideshow' plugin in any joomla component. Have any solution?
Thanks

Best way to call content plugins in Joomla! 1.5 and above is just use:
$text = JHTML::_('content.prepare', $text);
http://docs.joomla.org/Triggering_content_plugins_in_your_extension

You can call any event of plugin which is defined in that plugin.
$dispatcher = JDispatcher::getInstance();
$data = array($argu1, $argu2); // any number of arguments you want
return $dispatcher->trigger($eventName, $data);

In Joomla, plugins are not called in the typical sense, they are triggered by various events. The plugin listens for the particular event that triggers it. In this case, you would need to look and see what even Simple Picture Slideshow listens for, then add that trigger to your component. The only way to guarantee that a plugin will be triggered all the time is have it listen for one of the global system events, these happen regardless of the code in the component, they happen at the framework level. If a plugin is triggered by a non-global event, then you would need to either change the plugin or add the event to every component you want using the plugin.
Global system event reference - http://docs.joomla.org/Reference:System_Events_for_Plugin_System
Plugin reference - http://docs.joomla.org/Plugin

This question is specifically for Content plugin of joomla.
You can trigger any plugin event in your component.
Here is an example to trigger content plugin onPrepareContent event.
$content = new stdClass;
$content->text = 'Your content body with proper tag or
content wich you want to replace.
For example: {loadmodule mod_login}';
$atricle = array();
JPluginHelper::importPlugin('content');
$dispatcher = JDispatcher::getInstance();
JDispatcher::getInstance()->trigger(
'onPrepareContent',
array(
&$content,
&$atricle,
null
)
);
Or if you want to trigger only specific plugin for your component, then you can use,
JPluginHelper::importPlugin('content', 'loadmodule');
Second argument is name of the plugin which you want to use.
Similarly, you can call user plugin event in your component.
JPluginHelper::importPlugin('user', 'contactcreator');
JDispatcher::getInstance()->trigger(
'onUserAfterSave',
array(
$user,
$isnew,
$success,
$msg
)
);

Related

Extbase Hooks - execute code upon record creation

I want to create a standard typo3 extension but when I create a record (or modify it) I want to calculate something (in my case I want to call the Google Map API to get coordinates from a given address).
SO I search for a hook or something. Any idea?
One of my project example, may helps you for hook in backend when record has been changed.
In your extension file ext_localconf.php
// Hook for cancellation
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:femanager/class.tx_femanager_tcemainprocdm.php:tx_femanager_tcemainprocdm';
hook file class.tx_femanager_tcemainprocdm.php where you can execute
your script
class tx_femanager_tcemainprocdm{
function processDatamap_postProcessFieldArray ($status, $table, $id, &$fieldArray, &$reference){
// $status also called action like delete
// $table - table name of excute backend action
// $id - record UID
// $fieldArray - fields of your table
if($table = 'your_extension_table_name'){
// your script
}
}
}
Maybe this answer is useful to you.
Register your class as a data handling hook in your extension. This one "is called AFTER all commands of the commandmap" were executed. Maybe you need to look for a more appropriate one.
Then in your registered Hook i.e. 'typo3conf/ext/your_ext/Classes/Hooks/AfterCreate.php' do your calculation. Hope this sets you on the right track.
In my special case there was no need to calculate the coordinates when the record got saved. So I just used the listAction in the controller, check if coordinates are there and if not call the Google API (and send an email if the Google API does not give a coordinate back).
In another case where the new record comes from a frontend plugin and I had to do something with this data I used the createAction in the Controller. (I am not sure if the createAction is also called when the record is created from the backend.)

Autoscale text input with JEditable.js?

I've been looking for a script that combines the autoGrowInput with the JEditable but found none.
Use https://github.com/MartinF/jQuery.Autosize.Input initialized automatically via jEditable's event data:
jQuery(element).editable(save_fn, {
data: function(value,settings} {
var target = event.target;
window.setTimeout(function(){
jQuery(target).find('input').autosizeInput();
});
return value;
}
});
It's worth noting that this event (data) fires before the input element is actually created, hence the use of the timeout. There doesn't seem to be an event available at the present time for after the input has been created.
Actually I have created a plugin that does exactly that. You can check the demo and the documentation. I tried to make it very intuitive. It has ajax capabilities, using the RESTful philosophy. If you liked the animation effect on the autoGrowInput, it will be really easy to add it to the plugin just by changing the css file, using the transition property.
If I get people to like it, I may be able to improve and add more features to it. Hope it helps.

Joomla: Is there a module render plugin event?

Due to some caching issues, I need to explicitly bypass the cache, for a specific module, if certain URL parameters are present. The workaround I've arrived at is to hack the render() function in libraries/joomla/document/html/renderer/module.php, along the lines of:
function render( $module, $params = array(), $content = null )
{
// Existing code:
$mod_params = new JParameter( $module->params );
// My hack:
if ($module->module == 'mod_foo')
{
if (certain URL parameters are present)
{
$mod_params->set('cache', 0);
}
}
...
}
Of course, hacking the core joomla code is a terrible idea, one which I'd like to avoid if at all possible. So, is there an appropriate hook I can plugin to in order to achieve the same? I don't think I can do anything at the module level, since it won't even be inspected if the renderer has already decided to fetch it from cache.
To answer the first question no there isn't a module render event, here's the plugin doc's and the list of events in Joomla!
Turn off caching for your module.
See this article on The Art Of Joomla, additional articles you could look at:
Using Cache to Speed Up your code
JCache API

Typo3 eID, how to access config

I've just created an eID in Typo3. I can't figure out how to access the config data for my plugin from the Typo3 instance.
I've tried the code from the link but it doesn't want to work. I keep getting an exception "No TypoScript template found! " on the call " $TSFE->getConfigArray(); "
http://lists.typo3.org/pipermail/typo3-dev/2006-December/021392.html
Any ideas?
Thanks.
In eID mode, only a small part of the regular TYPO3 frontend is loaded. Unfortunately TypoScript is not loaded. To still access the TypoScript configuration you need manually load the components it needs to do so. Unfortunately this can be a bit of a pain in the butt. So in some cases it might be easier to just load a page containing a single plugin that doesn't contain anything else (without headers etc.).
If you do want to load the TypoScript templates yourself, you can try something like the following:
require_once(PATH_tslib.'class.tslib_fe.php');
require_once(PATH_t3lib.'class.t3lib_userauth.php' );
require_once(PATH_tslib.'class.tslib_feuserauth.php');
require_once(PATH_t3lib.'class.t3lib_cs.php');
require_once(PATH_tslib.'class.tslib_content.php') ;
require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
require_once(PATH_t3lib.'class.t3lib_page.php');
$TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');
$id = isset($HTTP_GET_VARS['id'])?$HTTP_GET_VARS['id']:0;
$GLOBALS['TSFE'] = new $TSFEclassName($TYPO3_CONF_VARS, $id, '0', 1, '','','','');
$GLOBALS['TSFE']->connectToMySQL();
$GLOBALS['TSFE']->initFEuser();
$GLOBALS['TSFE']->fetch_the_id();
$GLOBALS['TSFE']->getPageAndRootline();
$GLOBALS['TSFE']->initTemplate();
$GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site;
$GLOBALS['TSFE']->forceTemplateParsing = 1;
$GLOBALS['TSFE']->getConfigArray();
$cObj = t3lib_div::makeInstance('tslib_cObj');
This initializes the TSFE and cObj but is also used to load and parse the TypoScript templates. You might need to make some modifications to (probably kick some things out)
The code came from one of the comments on the following blog post: http://sebastiaandejonge.com/blog/articles/2010/september/21/bringing-ajax-to-your-frontend-plugins/
Good luck!

what plugin execute at first on zend framework?

i registered 2 plugin in my project on zend framework
the first one in application.ini
this is for change layout
resources.frontController.plugins.LayoutSet="App_Plugins_LayoutSet"
and second in the registred in the bootstrap
$fc= Zend_Controller_Front::getInstance();
$fc->registerPlugin(new App_Plugins_AccessCheck($this->_acl));
2 plugin work fine , i want to know what plugin execute at first ,
can we change prior's execute for these plugin?
Plugins are triggered in the same order they are registered. You can override this behavior by passing a "stack index" when registering Plugins.
The OO way:
$front->registerPlugin(new FooPlugin(), 1); // will trigger early
$front->registerPlugin(new BarPlugin(), 100); // will trigger late
The application.ini way:
resources.frontController.plugins.foo.class = "FooPlugin"
resources.frontController.plugins.foo.stackIndex = 1 // will trigger early
resources.frontController.plugins.bar.class = "BarPlugin"
resources.frontController.plugins.bar.stackIndex = 100 // will trigger late
Source: Zend Controller Plugins in ZF
The above answer is only partially correct. Yes, the plugins are triggered in the same order they are registered in but it also matters which event method a plugin uses. For instance, preDispatch() will be triggered before postDispatch() and so on.
See http://framework.zend.com/manual/en/zend.controller.plugins.html