Page 2 of 9

Re: How to create/duplicate a module?

Posted: Tue Jan 19, 2010 3:54 am
by Qphoria
Perhaps you just answered your own question. See how they did it, and what files are involved. Then use that info to create your own.

Re: How to create/duplicate a module?

Posted: Fri Jan 22, 2010 6:26 am
by Miguelito
Well back to creating a new shipping method based on weight based shipping...

Done as Q has instructed in the start of this thread and got an error when trying to use the new one in the store:
Fatal error: Call to undefined method Cart::getPostipaketti() in /home/mikimpor/public_html/opencart/catalog/model/shipping/postipaketti.php on line 26

Checked that and changed the line back to:
$postipaketti = $this->cart->getWeight();

Then again tried and got an error:
Fatal error: Call to a member function format() on a non-object in /home/mikimpor/public_html/opencart/catalog/model/shipping/postipaketti.php on line 45

If someone could point me where the problem is...? (not a coder)

Re: How to create/duplicate a module?

Posted: Sat Jan 23, 2010 6:24 am
by Litriem
Qphoria,

Great post, I plan on putting together a module soon and this will definitely be my guide.

Re: How to create/duplicate a module?

Posted: Thu Feb 04, 2010 5:06 am
by Qphoria
Miguelito wrote:Well back to creating a new shipping method based on weight based shipping...

Done as Q has instructed in the start of this thread and got an error when trying to use the new one in the store:
Fatal error: Call to undefined method Cart::getPostipaketti() in /home/mikimpor/public_html/opencart/catalog/model/shipping/postipaketti.php on line 26

Checked that and changed the line back to:
$postipaketti = $this->cart->getWeight();

Then again tried and got an error:
Fatal error: Call to a member function format() on a non-object in /home/mikimpor/public_html/opencart/catalog/model/shipping/postipaketti.php on line 45

If someone could point me where the problem is...? (not a coder)
You are trying to format somewhere but probably didn't load the model first

Re: How to create/duplicate a module?

Posted: Mon Feb 08, 2010 2:53 am
by Miguelito
Hi Q! I resolved my case with the help of another shipping method so again "trial-mistake" process was the best :)

Re: How to create/duplicate a module?

Posted: Wed Feb 17, 2010 4:38 pm
by ibparn
Qphoria wrote:Ah ok.. so you are 90% there.
The last step is the database (model) stuff. Since information has its own model file

Clone the
admin/model/catalog/information.php
file to event.php as well. That is your missing link
This was some great info and I did what I think is exacty what was suggested, yet I'm having the same problem.
I cloned the file as suggested yet I'm still unable to access it via the admin screen.

Any other suggestions.

Re: How to create/duplicate a module?

Posted: Wed Mar 10, 2010 11:21 pm
by L0oney
Hi Everyone,

I am a webdesigner based in South Africa, with a basic understanding of php ;D
I am trying to create a payment gateway module for mygate.co.za, for SIM credit card processing. I was wondering which of the current modules would be best to use as a 'template' to create my module?

Any help will be greatly appreciately, thanks in advance O0

Re: How to create/duplicate a module?

Posted: Tue Mar 23, 2010 9:42 pm
by Chris P Duck
Just been reading through this and considering making a module to list categories on the home page in a similar way to the products listed, i.e. show the category name/image and a link.

It seems odd to have to duplicate and edit seven files just to do this as it is literally a case of pulling a few records from the categories table?!

Re: How to create/duplicate a module?

Posted: Tue Mar 23, 2010 9:56 pm
by Qphoria
Chris P Duck wrote:Just been reading through this and considering making a module to list categories on the home page in a similar way to the products listed, i.e. show the category name/image and a link.
This was done as a mod already here: http://forum.opencart.com/viewtopic.php ... ome#p56071
It seems odd to have to duplicate and edit seven files just to do this as it is literally a case of pulling a few records from the categories table?!
The major con of MVC is the tedious file structure. That is compounded by having separate catalog and admin trees. But the pros will usually outweigh the cons.

Re: How to create/duplicate a module?

Posted: Tue Mar 23, 2010 10:49 pm
by Chris P Duck
Thanks for the advice. The module which I downloaded which was specific to Opencart 1.4.4 doesn't seem to work though.

Initially it was having trouble loading $this->load->helper('image'); which should be $this->load->model('tool/image');

Now it's showing a different error:
Fatal error: Call to a member function http() on a non-object

I got this from the Contributions section, http://www.opencart.com/index.php?route ... ion_id=177

I assume these things have been tested since it's explained in terms of just unzipping and replacing files?

Re: How to create/duplicate a module?

Posted: Wed Mar 24, 2010 12:00 am
by Qphoria
Well you can't assume "1.4.x" means it works with anything higher than 1.4.0
Those 2 things you mentioned were changes that were made in 1.4.1

See here for information on porting modules from 1.4.0 to 1.4.4
http://forum.opencart.com/viewtopic.php?f=22&t=12474

Re: How to create/duplicate a module?

Posted: Fri Mar 26, 2010 11:54 pm
by yeuxbleus
Hi,

I did this trick with weight.php the shipping module for weight based shipping. I have renamed all weight to weight_insurance (i want one seperate shipping for normal shipping and one for garanteed/insured shipping). Though somehow in Admin Home - Shipping after Install of the module, when I try to Edit, the screen is empty, no error, just empty.

I must have overlooked something, but cannot guess what. Who knows?

Kind regards,
Maarten

Re: How to create/duplicate a module?

Posted: Fri Mar 26, 2010 11:57 pm
by Qphoria
Typically an empty screen is a rendering issue. But if you used the same version of the module from the version of the cart you are using you shouldn't have any rendering problems.

Be sure you have "Display errors" set to true in the settings -> Server tab

Re: How to create/duplicate a module?

Posted: Sat Apr 17, 2010 12:08 am
by oz_ak
Thanks to good information

Re: How to create/duplicate a module?

Posted: Tue Apr 20, 2010 8:39 am
by webstudent1
Well back to creating a new shipping method based on weight based shipping...

Find the 3 php page in admin area for 'weight' (language / model / template)
Change all the weight values from weight to yourshippingname (except the ones used to aquire cart weight)

On the user end (controller) they are Langange and Model (2 files)
Change your text again in language and in model change all the weight values from weight to yourshippingname (except the ones used to aquire cart weight)

Works 100%

WebStudent1

Re: How to create/duplicate a module?

Posted: Wed May 12, 2010 11:38 am
by maxisgsm
@webstudent1

Which version you duplicate weight based shipping ?? I'm trying to duplicate that weight based shipping into other weight shipping (different provider)

but the 3 php page that you said found on admin area ( langguage / model / template) inside the model folder, i cannot find weight php ...... but inside controller got one weight.php ......

Re: How to create/duplicate a module?

Posted: Wed May 12, 2010 11:49 am
by maxisgsm
In template file, which line should i change from weight to myshippingname ??

Code: Select all

<td><textarea name="weight_<?php echo $geo_zone['geo_zone_id']; ?>_rate" cols="40" rows="5"><?php echo ${'weight_' . $geo_zone['geo_zone_id'] . '_rate'}; ?></textarea></td>
            </tr>
            <tr>
              <td><?php echo $entry_status; ?></td>
              <td><select name="weight_<?php echo $geo_zone['geo_zone_id']; ?>_status">
                  <?php if (${'weight_' . $geo_zone['geo_zone_id'] . '_status'}) { ?>
should i change this weight into myshippingname ??

Re: How to create/duplicate a module?

Posted: Thu May 13, 2010 3:02 pm
by inspiredbyiris
Hi Q,

I duplicate a category module and it works very well, but i have a problem:

For ex:

i have two categories: Cat 1 and Cat 2

Cat 1

--- subCat 1
--- subCat 2

Cat 2

--- subCat 1
---subCat 2

when i click subCat 1 or subCat 2 in Cat 2, i got error: the page not found! Although i created successfully in admin page.

Just another question, how do i insert products into Cat 2? Which template do i have to edit?

Hope Q or someone else can help me to solve this problem?

Thanks very much!

Re: How to create/duplicate a module?

Posted: Thu May 13, 2010 7:49 pm
by channelcommerce
I'm also trying to create a new instance of the category module to run in header with modified controller code.

I followed the steps shown to create a duplicate module and it installs but when I edit and save the changes it is interfering with the original module, do I also need to change every variable name, and the admin model file?

If I don't need to change the controller is there a simple way to output the category data (just the <ul> data) in the header.tpl such as <?php echo $category; ?> but this just outputs Array? I do have the code in header.php to load modules in the header area.

Re: How to create/duplicate a module?

Posted: Thu May 13, 2010 10:53 pm
by inspiredbyiris
Hi channelcommerce,

According to my solution, i create three new tables (oc_category2, oc_category2_description,oc_category2_to_store). They look like oc_category, oc_category_description,oc_category_to_store. They are the same, just have different name.

copy category.php, category.tpl then rename them to category2. Notice: you must change all variables from category to category2, upload into those paths:

------------------------------------------------------------------------------------------------------------------
admin/controller/catalog/category2.php
FIND: admin/controller/common/header.php

Code: Select all

 [b]// Insert into header.php: [/b]
$this->data['text_category2'] = $this->language->get('text_category2');
$this->data['category2'] = HTTPS_SERVER . 'index.php?route=catalog/category2';
admin/controller/module/category2.php

admin/language/english/catalog/category2.php
FIND: admin/language/english/common/header.php

Code: Select all

 // Insert: $_['text_category2']          = 'Categories 2';
admin/language/english/module/category2.php

admin/language/vietnamese/catalog/category2.php
FIND: admin/language/vietnamese/common/header.php

Code: Select all

// Insert: $_['text_category2']          = 'Chuyên mục 2';
admin/language/vietnamese/module/category2.php

admin/model/catalog/category2.php

admin/view/template/catalog/category2_form.tpl
admin/view/template/catalog/category2_list.tpl
FIND: admin/view/template/common/header.tpl

Code: Select all

 [b]// Insert:[/b] <li><a href="<?php echo $category2; ?>"><?php echo $text_category2; ?></a></li>
admin/view/template/module/category2.tpl

catalog/controller/module/category2.php

catalog/language/english/module/category2.php
catalog/language/vietnamese/module/category2.php

catalog/model/catalog/category2.php

catalog/view/theme/YOURTEMPLATE/template/module/category2.tpl
--------------------------------------------------------------------------------------------------------------------

It runs quite well!

As you can see in my last post, i got a problem to show Cat2 in front page and how to add products to Cat2 :D. Anyone can suggest any solution? Thanks very much