adding toolbar at backend of joomla component - joomla

i added this toolbar in my component
JToolBarHelper::addNew('dropdown.add');
when click on the new button by default this controller called.
contollers
dropdown.php
and in the dropdown file search for dropdownControllerdropdown class and call this class.
but i want to change this default behavior.how to make when user click on the add button componnent go to dropdown.php file and call helloworldControllerdropdown class instead of dropdownControllerdropdown class ???

In your dropdown php try to modify:
require_once('helloworld.php');
class DropdownControllerDropdown extends HelloWorldControllerDropdown
In this case when method add is called it will use HelloWorldControllerDropdown method add if it's not defined in DropdownControllerDropdown

Related

Using Spring Boot, Thymeleaf and Oracle: How to dynamically populate the submenus in a web site menu defined in a fragment?

I have a web site that consists of approximately 30 html thymeleaf templates. I have a home_navigation.html fragment that gets included in all templates as the header. This header defines a main navigational menu with popup submenus. The popup submenus under one of my main menus needs to be generated from my oracle database table.
Normally when passing data from a database into a Thymeleaf template I would put the code in the controller to call the java DAO and return a list of Link objects and then add that list in the controller to the model using .setAttribute. Then in the Thymeleaf template I would iterate through the "${List}" in a "th:each" outputting the "<a href..." for each Link object in the list. That is all fine and dandy.
I also can pass parameters into the fragment. So that isn't the problem BUT...
Since the main navigational menu is added as a header fragment into the beginning of every template then I would have to go into every defined controller and add code that would pull the list of Links and pass it into the template and then pass the list into the fragment from every page. that would be approximately 30 times!!!
How...using Spring Boot and Thymeleaf, does someone feed data into a fragment to populate a menu dynamically from a database that is then added as a header fragment into every page/template on the site?
Is there a way to create a controller for the fragment and somehow have every page call the controller for the fragment before the fragment contents are put into every page?
Thank you.
There are a number of ways to solve this problem depending on whether your menu can change while the user is logged in. If it can change then you can create a base controller class that has a method annotated with #ModelAttribute. All of your controllers would inherit from this base class. This method would obtain the menu items and add them to the model each time a page is requested. A simplistic example of such a class is:
#Component
public abstract class BaseController {
#Autowired
private AlphabetService alphabetService;
#ModelAttribute(name = "alphabet")
public List<String> getAlphabet() {
return alphabetService.getCharacters();
}
}
Your page would access them as normal
th:each="character : ${alphabet}"
You could also access the service directly in the page by doing something like
th:each="character: ${#alphabetService.getCharacters()}"
If the menu items do not change while the user is logged in then you could add #SessionAttributes("alphabet") at the class level to the above example and the service method would be called only once when the first page is displayed and cached in the session for future access.

How to create a New Page on Prestashop 1.7 Child Theme

I want to create a new page on my prestashop. I dont want to use the CMS to create the page, I need essentially a totally new page.
I have tried duplicating current .tpl's and renaming them - but I can never navigate to them - what is the url to access the new template?
E.g. say my site is www.xyz.com the "my account" template, sits under template/customer/my-account.tpl this my account page is normally accessed at xyz.com/my-account
I want a new but similar page - so I duplicate this template, rename it to my-account-new and change something in it, why can you not access the new template by change the URL to end with my-account-new - I just get a 404.
What am I missing?
Thanks
:)
you can add a new front controller in a custom module :
ModuleName/controllers/front/ControllerName.php
Then your new controller is a class that should be defined like :
Module::getInstanceByName('<ModuleName>');
class <ModuleName><ControllerName>ModuleFrontController extends ModuleFrontController
Then you add the method
public function initContent(){
parent::initContent();
$this->setTemplate('<templateFolder>/<templateName>');
}
You can now navigate to the template by going to index.php?fc=module&module=ModuleName&controller=ControllerName
So in this example replace every ModuleName with the name of your custom module and ControllerName with the name of your controller (for example MyCustomModule and MyCustomController).
The template will be in the your theme folder for example you can add customAddress in themes/ThemeName/templates/customer/customAddress.tpl
in which case the call to setTemplate would become :
$this->setTemplate('customer/customAddress');
I hope this helps.

Call another.js view from alloy.js titanium

have 1st view = index.js
2nd view = another.js
global file alloy.js
I have called the global class (alloy.js) method from index.js and now i want to move to another.js view but after httpRequest method finishes (which is declared and implemented in alloy.js).
---alloy.js---
Alloy.Global.httpMethod=function(){
//xml response is achieved, now from here i want to navigate to another.js view
}
---index.js---
Alloy.Global.httpMethod();
---another.js---
//some UI objects.
The first thing you want to do is create a controller, your another.js must be a Controller, it can be created by doing Right click on app and creating a new controller from there.
Once your controller is created, you can easily do what Phil said in the comment. i.e
Alloy.createController('another').getView().open();
This has to be placed in your onload function of HttpClient.
Hope it Helps.

How to get access to Current view model methods from Shell.js

I have a button in shell.html, on click of that button I need to post the current view model.
I can determine the current view model's Module Id, but how can I get a reference to it so that I can invoke its methods from Shell.js
For eg, if my current view model has a method called "SubmitApplication"
I would like to call or trigger this method from Shell.js on click of the button in Shell.html
Please help.
Thanks
Consider using Durandal's event system for cross module communication.
http://durandaljs.com/documentation/Leveraging-Publish-Subscribe.html
By default app has event capabilities included, which would allow you to do something along the following line:
shell.js
submitOnClick: function(){
app.trigger('application:submit', payload);
}
viewmodel
app.on('application:submit').then(function(payload){
//do something with payload
});

GWT Wrap Hyperlink

The GWT Class Anchor has the method Anchor.wrap() which allows me to wrap an already existing HTML element. The issue is Anchor doesn't keep track of AJAX history and as such I'm using Hyperlink class, but this one doesn't have the wrap() method.
Thus, what is the best way using gwt to make an existing html <a href> an Hyperlink if it doesn't have wrap()?
Please don't tell me implement the history behavior in Anchor click.
Hyperlink has a constructor that takes an Element as parameter. The catch is that this constructor is protected. A workaround would be to create a subclass to access the protected constructor, e.g.:
class MyHyperlink extends Hyperlink {
public MyHyperlink(Element element) {
super(element);
}
}
I did not actually try this, it's just an idea.

Resources