My goal is to disable the module programmatically (for example during some observer event).
The earliest observer I found is controller_front_init_before.
So my module is listening to it, and then do the next:
Mage::getConfig()->getModuleConfig('IG_LightBox')->active=(string)'false';
But the selected module is still active on each page.
Also I tried this approach (the same but in different way):
Mage::getConfig()->getNode('modules/IG_LightBox')->active=(string)'false';
Also I tried to reinit config after all and to loadModules one more time, but both won't help.
Mage::getConfig()->loadModules(); // won't help
Mage::getConfig()->reinit(); // won't help
Is it possible to disable the module programmatically?
Update 1.
This solution perfectly works for the back-end. active=false really disables the module, but I need it for the front-end too. So I keep my search.
Update 2
There are 2 methods in the app/Mage.php, called init and initSpecified, which allows to run the Magento with the selected number of modules only. But those methods are not called in the default flow.
Update 3
There is an observer event we can use for activating or deactivating the payment modules on the fly. It's called payment_method_is_active. This code example makes the check money order payment method being not active:
public function payment_method_is_active(Varien_Event_Observer $observer)
{
if($observer->getMethodInstance()->getCode()=='checkmo')
{
$observer->getResult()->isAvailable=false;
}
}
I think it depends on which kind of module you want to disable. My article worked for the kind of module I wanted to disable, but that module double-checked if it was activated, while most modules don't do that.
Magento loads all module configuration at once. Its impossible to create a module that will listen to this process because the module would have not been loaded while the process takes place. This creates a paradox. Its impossible to prevent a module from loading using another module.
As a result the only options you are left with are:
Edit the core.
Use modules which are better designed and explicitly allow themselves to be disabled through a config option or method.
Edit/extend the module you want to disable so that you can disable its functionality during runtime.
Hope this helps.. let me know if I can help you find a way to disable the module you're dealing with.
Here is one solution I found.
Related
In my app when the app is resumed from a sleep, I'd like to
reload the page - or ideally, just update specific UI elements.
How can this be done?
Preferably in a platform independent way.
You want to hook into the onResume method in the application module which exposes the event when an app resumes from the background.
https://docs.nativescript.org/api-reference/modules/application.html#onresume
So in your app.js (the entry point of your application), import the module and add the onResume event handler and it can run everytime the app resumes. Now reloading a page will require a little more work. You'd have to use the frame module and find out the current page and do your work, but I'm guessing it can be done with a little effort using the approach mentioned.
UPDATE: based off your comment, you need the reloadPage() method from the ui/frame module. https://docs.nativescript.org/api-reference/modules/_ui_frame_.html#reloadpage
The correct method is reloadPage() in the Frame module (as contributed by #Brad) but the problem is that it's NOT an exposed api.
No problem - just copy/paste it and it works.
The problem is that it basically does a navigateTo() to the currentPage and that effects the navigation history. You have 2 choices - setting clearHistory to true and you lose all history (don't want that) or set clearHistory to false which creates a a duplicate of the current-page (don't want that either). There's also a backstackVisible option but that doesn't help in this scenario.
#Brad tells me that there's api that allows access to the navigation stack - haven't looked into it.
For my app - the user will be at the root page most of the time, so I decided to reload the page only if on the root page and then set clearHistory to true and that works for me.
Looking for a way to create links that will pre-filter the module manager to specific modules.
So far, filtering based to position is working okay for me:
option=com_modules&view=modules&filter_position=right
But I can't do the same for module type or anything else.
Does anyone one know, how could I use the various filter types of the module manager ?
Updating my question:
For example, which url make Module Manager to display only the Menu modules ?
I tried something like this, with no success:
option=com_modules&view=modules&filter_type=mod_menu
option=com_modules&view=modules&filter_type=menu
My current setup is Joomla 2.5, but it will be great to know the same for Joomla 3.x
I don't know that the core module manager has that capability.
Take a look at www.nonumber.nl extension Advanced Module Manager
One of the parameters it uses to determine whether to display, include or exclude a module is to look at the URL.
So what you would do is set the module to only display when your URL criteria were met.
Ok found it: The following are the filters for Module Manager in Joomla 2.5
filter_search,
filter_client_id,
filter_state,
filter_position,
filter_module,
filter_access,
filter_language
So, for filtering by module type in a url, it would look like:
option=com_modules&view=modules&filter_module=mod_menu
Hope this will help someone else who is looking for it.
I am running a php script using a cron job to run a uRapidFlow / RapidFlow import profile. Here is the documented code I found to help me do this.
I need to be able to run through the imported batch, row by row, and do some processing based on if the row was imported successfully or not. It would also be very convenient and useful to be able to send email notifications on failed imports in general as well. If anyone has any idea, or can point me in the right direction, I would be very grateful. I don't see any documentation for this online, so I am going through the module code and database trying to figure it out myself.
I am using Magento EE 1.12.0.2
The best bet, unless you modify the uRapidFlow extension (check license information before doing so). Would be to extend it and use a observed event.
Try the observer : catalog_product_import_finish_before Which is triggered after each product is imported. Bare in mind this solution would be triggered globably for any manual imports, so if you build a small extension, perhaps make it easy to toggle on and off.
More can be found on Magento's observers here : http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method
Note as you've not specified which version of Magento you are using, you'll have to check if that observer is supported in your version.
I would like to be able to build functionality for my application in a plugin style system for a couple reasons:
New projects can choose which plugins are necessary and not have code for functionality that's not needed
Other developers can build plugins for the system without needing too much knowledge of the core workings.
I'm not really sure how to go about implementing this. I would like to have a plugins folder to host these separately but I guess my questions are:
How do plugins interact with the core system?
How does the folder structure work? Would each hold the standard MVC structure: controllers, services, models, views, etc?
I guess if anyone has a tutorial or some documentation relating to this technique that would be helpful. I've done a bit of searching but it's all a little too closely related to the actual code they're working with instead of the concept and I hadn't found anything specifically related to nodejs.
I suggest an approach similar to what I've done on the uptime project (https://github.com/fzaninotto/uptime/blob/master/app.js#L46):
trigger application events in critical parts of your application
add a 'plugins' section in the applicaition configuration
each plugin name must be a package name. The plugin packages should return either a callback, or an object with an init() function.
either way, inject to the plugins the objects they will need to run (configuration, connections, etc) when calling init(), or executing the callback.
plugin modules register listeners to the application events and modify it
Benefits:
lightweight
rely on npm for dependencies
don't reivent the wheel
Create a plugin prototype for the base
functionality, and let the user define its plugin in a module. In the
module the user would inherit an object from the prototype, extend its
functionality, and then export a constructor which returns the plugin
object.
The main system loads all plugins by require("pluginname") and for
each calls the constructor.
I've built two custom modules for Joomla ("reservation" and "contact") which are working just fine, however time to time I have to upgrade them.
Is it possible to make them to share the same "helper.php" so I could keep code in one place? For example the post function is the same for these two modules. I want the "contact" module to use the "reservation" helper.php post function.
Thanks
You can simply include the reservation module helper inside the contact module and use it.
For example lets say that your modules are mod_reservation and mod_contact, in mod_contact.php you include the reservation helper file and use it like this:
require_once JPATH_SITE.DS."modules".DS."mod_reservation".DS."helper.php";
modReservationHelper::post();
Or you make a custom helper module,, which is needed in order for the other 2 to work. I dont know for sure but I thought you can check for other modules when installing a module. In that check you check for the helper module and if not present you give a error. You could also say that a certain module needs atleast version X.XX.XX of the helper module and if the version is too long also give an error in during the install of the module.