Forums / Developer / Creating a Complex Stockist Database - Suggestions Needed

Creating a Complex Stockist Database - Suggestions Needed

Author Message

Nathan Kelly

Sunday 18 September 2005 9:29:18 pm

Hello all.

I need to create an area on my site in which stockists of my products can enter their contact and locale information. Once they have entered all of the required information it is sent for approval by a site editor/admin. If it is approved it then becomes searchable by the public in the "Find a Stockist" section or else it can be deleted.

On the public side the user should have two options to search by:-

Select Your Country: [Select Country][V]
Select Your State:   [Select State][V]
                     [Search]

On the "Add a Stockist" page there needs to be a number of options such as "Company Name", "Location", "Contact Phone Number", "logo" etc. etc.

A stockist must first select the country they are in via a standard select box, what I would like to do is set it up so that once they have selected the country the state select box is populated with the appropriate states for that country. from there on its pretty straight forward, they fill in all the blanks and submit their details for approval.

Likewise, the public page should have similar behaviour, select your country and the state select box is populated. Also if there are no stockists in a given country (ie if no one has added a stockist to Japan for example) then those countries should not be displayed in the select box as there would be no reason to attempt a search for stockists in a country that has no stockists listed.

As far as making templates to filter search results I dont think this will be a big issue, I'm sure I can do what is needed. When it comes to actually creating the country/state selector though I'm really not sure where to start or if I will be able to do it with the standard EzP datatypes.

I suppose my questions are; can Ez support the country/state selector that I need?

If so how would I set something like this up, would I need to create an extension, or is there an extension that has this type of functionality already?

Any Suggestions?

Cheers!

Pardon me while I burst into flames...

Nathan Kelly

Monday 19 September 2005 4:46:26 pm

Ok no suggestions, how about this...

I went looking for an auto-populate script to find out how it is done and I found one that uses javascript, only problem is it has some bugs and to get around them the author has found adding a whole heap of empty <option> tags to the HTML kills the bugs, however it also kills validation (Client requests valid XHTML strict).

I may be able to rework the script to be more compliant but is it possible to pass information from a template to the system?

I also found this http://ajax.zervaas.com.au/examples/CountryRegionCityJax/
And I wondered if something like this could be made into an extension? Unfortunately I have no idea how to make my own extension, maybe someone could give me a few pointers (if it is a doable thing)?

Cheers!

Pardon me while I burst into flames...

Lex 007

Tuesday 20 September 2005 2:12:01 am

Hi,

This is very doable. You should have two classes :
- Country class
- State class

The country class has an attribute of type object relation (see the contributions section for a better datatype). In this attribute, for each country you create, you assign the states that belong sto this country.

About AJAX stuff, check out the AJAX menu in the contribs section, this should give you some good hints.

Hope it helps.

Lex

Nathan Kelly

Tuesday 20 September 2005 4:38:51 pm

Hi Lex Thanks for your input, I have already looked at the ezcountry datatype in the contribs, this looks like what I need for the first part but I'm not 100% sure what you mean when it comes to the states...

Are you saying that for each country I need to create a states class?

Or do you mean I should create just one states class that contains all of the states for all of the countries?

Or do you mean I should create a states datatype?

If I need to create a class for each country I'm going to end up with a lot of bloat in setup/classes, so I assume you don't mean for that.

I was thinking about trying to extend the current country datatype to include the states but I haven't looked to deep into the datatype yet as I was hoping someone may have a better idea.

Certainly I'll look into your suggestions and thankyou for them, if you could just clarify this method with a little more detail that would be great.

Cheers!

Pardon me while I burst into flames...

Lex 007

Wednesday 21 September 2005 1:03:33 am

In my method you have to create one OBJECT for each state, not one CLASS for each state. Each state object is an instance of the same State class.

This should work "out of the box" with eZ, but for sure the cleanest way is to write a new datatype, which should take you much much longer time.

Lex

Nathan Kelly

Wednesday 21 September 2005 4:10:45 pm

Cheers Lex I'll give it a go and see what I can come up with, I think creating a datatype is the way to go, as you said it will be much cleaner.

Now I just need to figure out how to create a datatype...(I don't really know PHP at all so this should be fun).

Pardon me while I burst into flames...