Switch Prestashop Language programmatically - prestashop

I have got a module, that uses displayTop hook for some actions. after that i would like to switch language to desired that exists in the system. I found a method Tools::switchLanguage but I can't figure out how to use it properly. any clues?

There is a module that already does that: blocklanguages. So you can either use this module or take a look at the code to see how it's done. It's pretty easy so you can implement that wherever you want.

Related

Showing Status-field as dropdown in Directus 7?

is there a way to make a Status-field display like an dropdown/select-box instead of radio-buttons? I have about 10 status' and I would like to display them as a dropdown instead.
I wasn't able to find anything about this in the documentation, did I miss something?
Thank you in advance!
Not the "core" status interface, but you can duplicate the code and create a custom one in a select instead. The new interface would go into the custom extensions directory in the API. Should be pretty straightforward.
https://docs.directus.io/extensions/interfaces.html

SilverStripe 3: Can a module extend mysite/code/Page.php?

Good afternoon,
I don't know if what I want to do is possible, so here goes.
I have a module that extends Page_Controller, but I want certain functions to be accessible via the site root.
Eg: getMyDataObjectList();
Currently, they only work if I go through the normal MVC routing structure.
I've found that when I place the function 'getMyDataObjectList' within '/mysite/code/Page.php' it works.The problem is, I don't want to place the code in there. I want it bundled with my Custom Module, but to work the same as though it was in 'mysite/code/Page.php'
[Example Scenario]
site root: http://[somesite].com
By default, the 'Page.ss' template loads.
I would like the theme developer to be able to call my module functions (API) within any template/Layout page, and have the result returned from the site root
Currently, this only works if I move the "API" functions to '/mysite/code/Page.php'
If the code is in my module, then data is only returned when you go to:
http://[somesite].com/[module_controller]
Can this be achieved? If so, how?
Thanks for your assistance.
[Update - Code Solution]
///>MyExtension.php
class MyExtension extends Extension{
public function getMyDataObjectList(){
return 'object list goes here!';
}
}//class
///>[Module] => _config.php
Object::add_extension('Page_Controller', 'MyExtension');
And as always, I do a (/dev/build?flush=1) just in case.
Thanks to: 'simon_w'
Yes, this is relatively straightforward. Simply, create an Extension subclass with your methods in them and then add that to Page_Controller. An Extension subclass is almost exactly the same as a DataExtension, they're just for classes other than DataObjects.

Dotnetnuke - How to insert a module inside another module?

I am writing a Tabs module in which I want to be able to display other modules like html, third-party modules etc. How do I achieve that? C# code please.
http://www.mandeeps.com/products/dotnetnuke-modules/live-tabs.aspx
This module is a tabs module that does just what you are looking to do.
I don't think it's the type of thing someone can just code up for you or copy and paste it in here. You could use this module, you could buy the source of this module or you could analyze the source of DNN and figure out what really makes a module render and reproduce that.

Howto create a filter bar?

I would like to create a filter bar like the one in the Mail app:
Do you have any suggestions on how I could do?
My application is targeted only at OS X 10.7+, so I'd really like to use the most modern method available.
Thanks.
MGScopeBar is an open source component that will mostly do what you want. The appearance is not exactly the same, but you could easily change that.
That is called FavoritesBarView in the Mail application. it looks like its source code exists in webkit source code.

JSLint, when using JS frameworks

I use the Dojo framework, which I load from an url.
How should I deal with the 'dojo' was used before it was defined errors, and the alike?
Yes, my feeling really get hurt, when running code through JSlint.
Perhaps you can put something like
/* globals dojo */
in the beggining of your file to tell JSLint that dojo exists?
I personaly use JSHint (a fork of JSLint that is less nitpicky) instead and one of the preconfigured options is support for Dojo.
Sounds like you need to put Dojo first in your JavaScript. The message suggests that you have an ordering problem.
Don't take it personally. You are not your code. Just make it better, learn something, and don't do it again.
If you scroll all the way down to the bottom there is a "predefined" textbox. Simply put in any of the variables you need into there (comma separated).