Is it good to duplicate the opencart module? - module

Well I want to make a custom page in opencart admin panel to insert and delete some data from opencart database
For example :
Set an image slider on opencart home page and fetching images from database & for insertion of images, I want to create a custom page in opencart admin panel ??
So how can it be possible ??

You can duplicate any module and create other for your needs. Remember to duplicate and change the filename so the "new" extension can work properly.
Folder to consider for admin:
admin->controller->{type of module}->module's name
admin->model->(type of module)->module's name
admin->language->english (always)->(type of module)->module's name
optional:
admin->language->(other languages)->(type of module)->module's name

you may try,
1,Login as Admin-> systems -> design ->banners -> insert ->
YOUR BANNER NAME-> add banner ->
Title: YOUR TITLE
Image: YOUR IMAGE -> Save
2, Login as Admin-> extensions -> Modules ->Slideshow -> Edit -> add Module -> SELECT YOUR BANNER -> Save

Also when duplicating modules be aware that you may also need to change the existing class name to different one. For example when duplicating module flat rate you will also need to change in the controller /admin/controller/shipping/flat.php :
class ControllerShippingFlat extends Controller {
to something new like :
class ControllerShippingFlatDuplicate extends Controller {

It's posible, but in my opinion if you want to create a new "admin page" in your Opencart you can do it using vqmod.
so, you don't have to rewrite any core file.
you can donwload any free extension on the opencart website to take an example

You can simply duplicate some simple modules available in opencart admin panel like Welcome module or Banner or Slideshow module.
This method will help you to disable the module or change the position of content in future.
Duplicating opencart module tutorial : http://opencart.hostjars.com/blog/58

As a beginner it's better to duplicate an existing module and modifying it as per requirement. When you get the idea of how opencart modules work, you can build modules from scratch.

Yes, it is pretty safe and sound to duplicate a module in opencart and it is a bit logical with any of the cms as no one is going to create a module from scratch for a very little functionality like inserting some values to database.
As depicts you just want to insert some images links, so you can proceed with replicating the catalog / information functionality in opencart admin panel.
You just need to create a new table in database to store new modules data and fetching new module data in front end.

If you want to create a custom module or custom page for your store you can check below link. There is complete solutions for your question and describe very deeply.
Create custom module: http://www.php-dev-zone.com/2015/02/opencart-custom-module-development.html

Related

Prestashop - how to create a custom page?

Title says it all. I want to create a custom prestashop page, but I don't know how.
What I actually want to do: create a button that opens a custom page. I can't find anything useful in the internet so I came here to ask for help. Could someone explain me how to do that?
There are many ways to add a new page, it depending in your needs.
By a CMS page, you can add the content you need in the HTML editor, like the product description: http://doc.prestashop.com/display/PS16/CMS+-+Managing+Static+Content
By a front controller from a module: https://devdocs.prestashop.com/1.7/modules/concepts/controllers/front-controllers/
By creating a new page, here my explanation: Prestashop custom page with own template
The point 1 is the most easy way for a common user, the rest of the points require advanced knowledge.

Yii framework module layout issue

I am creating my first framework based project using YII framework. I have a main site and a module based backend to manage the site(CMS). First I used the same layout for both ends, but now I want two different layouts for front end and backend. I changed my module layout by adding a layouts folder to the module view file and I added “$controller->layout = 'main';” to the base module file of my module folder. Now the layout has been changed but when I logged in as a admin to the backend I cannot view any admin controller action, it means I am just a guest user. This issue is solved when I change my layout to the main site layout.
Please let me know if there is anything to do for this?
if the backend and frontend you created like module I think this will help:
$this->layoutPath = Yii::getPathOfAlias('(application.views.layouts or path/to/layouts)');
and in controllers of module just pasting layout name:
public $layout = 'login';

Show custom text at "My personal information" page through plugin

I want to show some custom text at "My personal information" page in customer's account using a plugin in Prestashop. I have no idea how to do this?
Any help is much appreciated!
It is not possible to do it by a plugin or module, because prestashop is not providing any HOOK for that page / place.
But you can do it by a little work out there. I am considering you are using prestashop 1.5 , so lets work with that.
1) First create a cms page at admin and note its id. Lets consider its id is 10.
2) Now open the file override/controllers/front/IdentityController.php . In this class file create a function like below.
public function initContent()
{
parent::initContent();
$identityCmsPage = new CMS(10, $this->context->language->id_lang);
$this->context->smarty->assign('identityCmsPage', $identityCmsPage);
}
Now after that, open file at your themes folder themes/your theme/indentity.tpl
and display that cms page contents like
{$identityCmsPage->content}
and you will have that cms page contents there.
Note: This code is not tested and may have errors. Please adjust accordingly if you got any.

Display a form in prestashop

I would like to show a form in prestashop module and would like to store that value in database. How is it possible?? Is there any prestashop expert ??
You may use custom HTML block and add your form code inside that. And off course have to use a hook to show up that HTML block in the site.
There are lots of free Custom HTML block modules available.
You should take a look at all the modules available in the modules/ directory.
If you want to display a form in the back and/or the front office, you'll have to override different methods of the Module class, and you'll have to use the different hooks available..
Best regards,
Try this free module :
https://www.prestashop.com/forums/topic/391966-megablock-16-module-gratuit/
With this one you can add HTML in some hooks from back-office.
Everything is stored in database.
You should use Helpers and Tools class (Helpers show forms and Tools::getValues() does what it says...)
In MegaBlock there is also TinyMCE available. Have a look, this module is really useful ;-)
you can develop a module by using hooks based on the hooks used the form will be displayed in that position in prestashop while using hooks you need to assign a tpl file in that tpl file you can write the codings to display a form
And also you can develop a module with a separate controller and you can assign a tpl for that controller.

How can I display Joomla modules within a component?

I have a component with several categories of games and I want to display a different banner depending on the category. I need the banner (and link) to be customizable so it's not simply a case of showing categoryX.jpg or whatever.
I saw this Joomla help page on another question, but it only seems to display a module type, not one specific module. I'd like to use various mod_custom modules and display the one appropriate to the category (I can store each module's ID if necessary).
Any ideas?
This can be done in a 2 step process:
Use the "Load module into article" plugin to allow yourself to access the module using a plugin call like:
{module [*mod_id*]} // where *mod_id* is the module id
Now that you can call a plugin to put your module anywhere, you now need to go to the view code of your/a component you wish to add the module to and add this code:
echo JHTML::_('content.prepare', '{module [*mod_id*]}');
Please see this link - http://www.alltogetherasawhole.org/group/developers/forum/topics/running-joomla-content-plugins - regarding point number 2. I was trying to do the same thing and I found it didn't work, and the reason for this was a comment you can find on the page link above:
"I noticed that some plugin actually expect option=com_content for them to process onPrepareContent properly, so you might actually want to "fool" them by callin JRequet::setVar and restoring the correct values after the trigger."
If you would like to show module within PHP code then use this code, it's worked for me :
<?php echo JHTML::_('content.prepare', '{loadposition position-2}'); ?>
If you want to show module inside html content then just put this code where you want to show module.
{loadposition position-2}
It loads all modules which are assigned to position-2.
You can also use the Joomla Module Renderer
$doc = JFactory::getDocument();
$renderer = $doc->loadRenderer('modules');
$position = 'custom_position_name';
$options = array('style' => 'raw');
echo $renderer->render($position, $options, null);
Just a heads up, Along with being assigned the module position, that module also has to be set to "Display on All pages".
Joomla has this functionality built in. You can use the {loadposition XX} command within your content items. You can specify custom module positions that do not appear in your template to insure that you have the correct module in the correct article.
http://docs.joomla.org/How_do_you_put_a_module_inside_an_article%3F
You could create a new module?
If each category appears in the querystring (catid=X) then you could take a similar approach to https://support.pillwax.com/open-source/doku.php?id=joomla:header_image.
Alternatively, that link might actually do it for you.