Forums / Contribution-Writing Guidelines / New to modding ZC- best practices?

New to modding ZC- best practices?

Locked

Started by bassface on 20 Nov 2009, 8:24 PM · Views: 3,539

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
20 Nov 2009, 8:24 PM
#1
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

New to modding ZC- best practices?

I am new to modding for Zen Cart, but have experience modding for phpbb3.

My Zen Cart mod will need to perform extra actions using the info from the form fields when a new user registers (create_account.php) and when a user changes their account info (I've created a new module/pages/*mymod *folder and a tpl_mymod_default.php for this part).

For the action that happens on new user registration will I need to modify the core files or can I create a separate file somewhere that can be loaded between create_account and create_account_success?

21 Nov 2009, 7:21 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: New to modding ZC- best practices?

Depending on what you're ultimately trying to do, you can probably hook into an existing notifier, and have an observer class do the custom work you require in the background. Related documentation: http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#Observer_Class

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

21 Nov 2009, 9:36 PM
#3
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: New to modding ZC- best practices?

Thank you for the info and that link! That looks very promising for what I'm trying to do.

3 Dec 2009, 10:01 PM
#4
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: New to modding ZC- best practices?

Just read the observer stuff. It's way over my head, I guess, cuz it makes no sense to me at all. Oh well...

4 Dec 2009, 2:43 PM
#5
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: New to modding ZC- best practices?

And there weren't any notifiers before the attributes get 'built', which is what I would need to modify. I'll just try hacking the code. :frusty:

4 Dec 2009, 3:36 PM
#6
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,940
Plugin Contributions:
3

Re: New to modding ZC- best practices?

Hi,

It depends on exactly what you are trying to achieve.

If you want to manipulate the Form data, before it gets saved to the database then look for

NOTIFY_MODULE_START_CREATE_ACCOUNT

This notifier at the top of the Create Account page so you would have to check if a form submit had occurred

e.g.

if (isset($_POST['action']) && ($_POST['action'] == 'process'))

alternatively there are a couple of other notifiers that occur when the database has been updated

i.e.
NOTIFY_MODULE_CREATE_ACCOUNT_ADDED_CUSTOMER_RECORD
NOTIFY_MODULE_CREATE_ACCOUNT_ADDED_ADDRESS_BOOK_RECORD

and you could intercept these, and update the database based on what ever your mod needs.

or you could intercept that notifier on the create account success page,

As I said, it very much depends on what exactly your mod is trying to achieve.

4 Dec 2009, 4:34 PM
#7
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: New to modding ZC- best practices?

Thanks wilt. I actually confused myself - I have 2 mods I'd like to attempt,
one that deals with newsletter subscription actions: specifically to use the Constant Contact API to handle newsletter subscriptions,
and one that can make certain product's attributes required and use mootools.js for attractive form validation during the 'add to cart' shopping process.

I have the constant contact newsletter thing working, but I did so by editing core files. I was hoping to use the notifier/observer system instead as I'd like to be able to release my mods to the community.

The mootools.js form validation requires that each form element (in this case the product attributes) that will pass through validation, have to have the <input> or <select> tags modified to add 'class="validate[blahblah];"' as well as some javascript code blocks.

But the fact is I don't understand the notifier/observer or the autoloading thing well enough to use them at this time. Is there a 'Hello world' level tutorial out there for using notifiers, as the examples given in the wiki were not helpful to me.

5 Dec 2009, 1:04 AM
#8
bassface avatar

bassface

New Zenner

Join Date:
Jan 2005
Location:
Aurora, CO USA
Posts:
71
Plugin Contributions:
1

Re: New to modding ZC- best practices?

OK, I just read through the Observer class wiki bit again, and I'm not ready to give up yet! I believe I can get the Observer class to work for my Constant contact integration idea.

Not sure about using it for modifying the product attribute form html code, as I don't see a notifier that 'hooks' in at the product attribute area. I may have to modify the zen_draw_something function and maybe add a field or two to the db. :cool: