i have a module called 'elite' which render articles and another module called 'inet'.
Inet->controllerX need to get the HTML only from an article(elite->article->actionView).
so my question is:
should i call elite->article->actionView from another module or use components and inheritance and how?
Thank you!
You can easily render a view in any module, just need view path.
return $this->render('#app/modules/elite/views/name_controller/name_view');
You must replace the name of the controller and the name of the view.
Related
I am making a module, that suposed to use templates from my custom theme.
The problem is that I don't understand the function Module::display(), it gets two arguments "file" and "template", what is the file? What is it for?
If I do this:
public function hookDisplayHome{
return $this->display(__FILE__, '../../templates/my_custom_theme/mb_templates/aboutus.tpl');
}
It displays error "Not found template file" in module "my_module". Of course if I change the template path to one of the templates of my module, then it works. But I need to access theme's template, not my module's.
With this I have also another additional question. Is there any documentation on Prestashop's functions? I really tried to analyse the function $this -> display() but couldn't find any place where is described what are the arguments of this function etc. There is Prestashop documentation https://devdocs.prestashop.com but it is very general, and has no description of the functions.
I've checked the class Module.php, the function has no comments :(
What is the official way when you want to check what the function does, returns, and what parameters accepts? It has to be somewhere, right?
So for those who also struggle with this problem, based on this answer https://stackoverflow.com/a/53576139/2796533
The easiest solution seems to be using module's template in $this -> display() and then in that template include the theme's template:
{include file='../../../themes/my_custom_theme/mb_templates/aboutus.tpl'}
I need a hook that I can't find in the documentation, but logically it should exist.
In my module, I need to add some html in category page (or search results page) after the tile with the products but before pagination.
Which hook is best to use?
There is no default hook for your goal, but you can create your own one and use it within your module. The inconvenience is that you will be able to use it only in modified themes or you will need to add it manually to all new ones. To create the desirable hook you need to put
{hook h='displayYourHook' info=$someData}
in the top of your_theme/templates/catalog/_partials/products-top.tpl
and then just use it like a default hook within your module
public function hookDisplayYourHook($params)
{
// $params can be some information. ID of category for example
do all necessary stuff here
}
and also do not forget to register your hook during the module installation
public function install()
{
....
&& $this->registerHook('addproduct')
....
}
Also, I presume that you use prestashop 1.7.* if not - some code can be different
What is the best way to reuse code between controller and command?
I have some use where the very same logic should be executed inside controller and in command as well. What is the best approach to share code? To create a component and the call this component methods from controller and command?
Create a class (model, service, etc), and use that in the different areas.
Within the config/main.php or config/console.php there is an import section:
'import' => array(
'application.models.*',
'application.components.*',
You can add your class anywhere really, as long as its location is referenced within the import section in the config, as that is how Yii1 autoloads files.
I have a helper method called current_user in my Application Controller (used with Authlogic).
Spec for views using that helper fail (but the view is working when i use the browser)
ActionView::Template::Error: undefined local variable or method 'current_user' for #<#<Class:0x0000000229b060>:0x00000002004248>
I use rspec 2.6.0.
Anyone had the same problem? Please advice. Thanks
You can stub out the method on view.
view.stub(:current_user).and_return(user)
This will also work in helper specs.
Controller-defined helper methods are not included in the helper object.
http://relishapp.com/rspec/rspec-rails/dir/helper-specs/helper-spec
Check out this one: http://apidock.com/rails/ActionController/Helpers/ClassMethods/helper_method.
You can define helper inside the ApplicationController, and use it across the controllers AND views.
check right documentation for specs view
https://www.relishapp.com/rspec/rspec-rails/v/2-14/docs/view-specs/view-spec#passing-view-spec-that-stubs-a-helper-method
I'm very new to Joomla. I have a question about components/modules.
I'm doing the development of a site for a firm and they provided me with custom news releases component that's supposed to show on the home page. From what I've seen, I can call modules to a page with "" based on their position.
Do I do the same sort of thing to get this component to display? Can anyone help me out please. Let me know if I'm not being clear.
EDIT: I figured out that I have to add this as a menu item, but this makes it into it's own page. I want this just as a module on the right of the home page. What do I need to do to achieve this?
Thank you
if this is a component than you won't be able to display it in a module position. You will have to write a new module to do that or use some modules which wrap around other types of content. See here, maybe this plugin will fit.
If this is a component you can also use the Component Loader extension to load the component output in a module position.
http://extensions.joomla.org/extensions/core-enhancements/embed-a-include/10721