Typo3 extension views in different windows - fluid

I currently startet a new extension. For this one, it would be very useful to have not all backend views in the same window.
Does anybody known, how to redirecct a view to a different window or open a different view in a different window.
It easy to redirect to another view, but haven't found a way to open it in another window.
I guess, it gives a way, because the extension-builder can be opend in another window.
Thanks for any kind of help!

You can do this using PHP_OS constant in your controller file. like below.
in your controller file.
/**
* action list
*
* #return void
*/
public function listAction()
{
$systemOs = PHP_OS;
$this->view->assign('systemOs', $systemOs);
}
Now, use this variables in your fluid template. List.html like below
<f:if condition="{systemOs} != '' ">
<f:then>
<f:if condition="{systemOs} == 'Linux' ">
<f:then>
Your layout here
</f:then>
</f:if>
<f:if condition="{systemOs} == 'Window' ">
<f:then>
Your layout here
</f:then>
</f:if>
</f:then>
</f:if>

Related

Add bullets in magnific popup gallery

I have added magnific popup gallery in my web page, everything works great. Just I want to know, is there any possibility add bullets in popup gallery below image in .mfp-bottom-bar.
The gallery example on Magnific's demo/homepage shows at least one way to achieve this, by feeding some markup into the return value of a function in the titleSrc option in the image option of the popup. In that example (from the page's source):
$('.popup-gallery').magnificPopup({
...
image: {
...
titleSrc: function(item) {
return item.el.attr('title') + '<small>by Marsel Van Oosten</small>';
}
}
});
The above case appends a <small> element to the current link's title attribute value/text, but you could presumably return some other <ul><li>...</li></ul> markup, or use jQuery to grab some existing <ul> in the markup (if relative to the current item, then presumably using item.el to help locate it).

How to switch to another XML layout after click on button?

I would like to have one kotlin file with the logic and I would like to allow users to switch between two different XLM layouts (logic of program is still the same, but layout of buttons shall be changed when clicking on button).
I simply add setContentView function to setOnClickListener for this button in order to load activity_main_second_layout.xml layout.
PS. activity_main_second_layout.xml is almost the same like activity_main.xml, I only changed the position of elements (not the names of elements)
button_switch_to_the_second_design.setOnClickListener {
setContentView(R.layout.activity_main_second_layout);
}
When clicking on the button, voala, the layout really changes to the second one.
BUT the functionality of the program is not working any more, the logic disappear. It seems that I need to resume running of the program somehow to make the code working again without interuption including loss of variables.
There is a lot of ways to do that.
In my opinion you should not try to change layout in runtime - it's possible, but you have to override setContentView and rebind all views and all listeners (or do it in other method, which will be called after changing the layout).
So... Sth like this:
fun sth() {
setContentView(R.layout.activity_main_second_layout)
rebindLayout(R.layout.activity_main_second_layout)
}
fun rebindLayout(#LayoutRes layoutId: Int) {
when (layoutId) {
R.layout.activity_main_first_layout -> { /* rebind views here */ }
R.layout.activity_main_second_layout -> { /* rebind views here */ }
}
}
The other's, better I think is to create independent fragments and change fragment via fragmentManager.
Others approches - ViewAnimator, ViewSwitcher.

Controllers sharing parts: How to include a controller's output from within another controller's view in Prestashop >= 1.5?

In the shop's customer section I would like to render the user account menu (which we can see by default when reaching /my-account URL) as a side column on some others controllers like the ones associated to "/my-adresses", "/identity" pages ..
I thought I would have to create another controller which purpose would be to gather menu infos and only render the menu <ul> list. Then I could override Controllers such as MyAccountController, IdentityController to include this former Ctrl and then render its content as part of the views of those two other controllers views.
So how one can load a specific controller from another in order to render shared views between pages ? Which is the right/clean way to do that ?
I heard about $this->getController() but I did not find any snippet or implementation of what I'd like to achieve. I new to Prestashop but even if the code seems clear, I don't get the point here.
Thank you !
After getting a bit deeper into sources, I ended up moving the menu (initially part of the MyAccountControllerCore alias my-account template) into a brand new Controller "MyAccountMenuController", in /override/controllers/front/.
<?php
// In /override/controllers/front/MyAccountMenuController.php
// The "exposer" controller
public function display()
{
// Do what ever you want to pass specific variables
if (! $this->template) {
throw new Exception(get_class($this) . '::display() : missing template.');
}
$this->context->smarty->display($this->template);
return true;
}
I am now able to import this menu by adding the following snippet inside the initContent() method of each controller that are part of the customer account section (this means that each of them must be overridden, for more info about overriding controllers, see documentation):
<?php
// In /override/controllers/front/MyAccountController.php
// The "consumer" controller
public function initContent() {
// ...
// Importing the customer area's menu
$menuController = $this->getController('MyAccountMenuController');
ob_start();
$menuController->run();
$this->context->smarty->assign('myAccountMenu', ob_get_clean());
}
I don't think the original purpose of getController method (located in ControllerCore class) was meant to include another controller output, at least in Prestashop 1.5. Still, to me this approach is far cleaner than duplicate views code.
If you have a better (cleaner) approach to implement such a mechanism, please let me know !
Any thoughts ?

Connecting Multiple NSMenuItems with Actions and State Variables

I'm not sure how to describe what I need but I'll give it a try, via an example :
Let's say we have a window and a sidebar, and want to toggle it (I mean the sidebar : on/off).
Now, let's also say that :
The user may toggle the sidebar via an item at the Main menu (e.g. Show Sidebar / Hide Sidebar)
The user may also toggle the sidebar via a button
And there is also another item, in some other menu, to do the very same thing (Show/Hide Sidebar)
What would be the most practical Cocoa-friendly approach to achieve that?
Of course, that means that, e.g. :
When somebody clicks the button, apart from the sidebar (showing or hiding), the menu items must now be showing the current status of the sidebar (e.g. "Show sidebar" must now turn to "Hide Sidebar" in all possible instances within menus, etc)
I hope you get the idea; it's definitely not something difficult; but I'm definitely confused on how I could use all of Cocoa's tricks to do it fast.
Thanks!
I'm assuming you have some controller object which implements an action -toggleSidebar:, and that both menus target the same controller. Also, in the controller, you keep an instance variable BOOL isSidebarShown.
Make your controller implement the NSUserInterfaceValidations protocol. Something like this:
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem
{
if (anItem.action == #selector(toggleSidebar:) && [anItem isKindOfClass:[NSMenuItem class]])
{
NSString* title = isSidebarShown ? #"Hide Sidebar" : #"Show Sidebar";
[(NSMenuItem*)anItem setTitle:title];
}
return YES; // either way, the menu item is enabled
}

OpenCart Breadcrumb in header.tpl

Can someone tell me how can I have the breadcrumb nav within the header.tpl and not in the product.tpl of opencart?
I've just had to figure this out for a new site we're building and I've come up with the following; use at your own risk (I'll report back if I run into any major problems, but I can't foresee any... famous last words)
Basically the breadcrumbs are built in the controllers and we need the resulting $breadcrumbs array in the header controller. Modify system/engine/controller.php as follows:
[...snip...]
protected function render() {
foreach ($this->children as $child) {
$this->data[basename($child)] = $this->getChild($child,array('parent_data'=>&$this->data));
}
[...snip...]
This will send all the data in the parent controller, before render() was called, to every controller/method of the $children. Then we just need to pick this up in the header controller as follows:
<?php
class ControllerCommonHeader extends Controller {
protected function index($args=array()) {
// parent data
$this->data['parent_data'] = $args['parent_data'];
[...snip...]
And we can access everything in the template with $parent_data['whatever']. In this case, $parent_data['breadcrumbs'] will be the array of breadcrumbs that I can loop over with the code I've removed from each page.tpl and added to my header.tpl.
Due to the way 1.5.X is coded, you'll need to rewrite every controller and add a method back to the document class to allow passing from the product controller to the header controller. Is there any particular reason you want to do so?
if all else fails just hack the css, something like
.breadcrumb {
margin-left: -270px;
margin-top: -65px;
}
will move the breadcrumb up and to the left.