Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I think what I want is quite complex, but maybe someone can help me with some basics of it.

In d7 I have a content type and each node uses address field and via geocoder creates the geo data for that node. I use taxonomy terms here to categorize the node (eg: shop, restaurant, hotel, etc ..) and some nodes may have multiple categories added as they may be multiple types at the same time(one may be a restaurant as well as hotel).

I have created a taxonomy tree as such:

country -> city, eg:

england -> london
        -> manchester
        -> newcastle

Each city also has geo data attached to it. The country and city will be used in the url to filter the results based on a set proximity.

So, for example I could have this url

www.example.com/england/london/restaurant

which is equal to (for examples sake)

www.example.com/country/$2/$3

The country page is a static page that may list taxonomy terms (cities) for that country.

The next page up - selecting the city from the country page - does not yet display a view, but gives options for which category the node is in (this taxonomy term is attached to the node (Shop, Restaurant, etc ..))

Now I want to create a view that uses term $2 to set the location from which to start the proximity search from (the geo data is already added to the taxonomy field for cities and mustn't first get geocoded from the city name)

Then term $3 is the category which is attached to the node.

It then displays all the nodes from that category at a previously set distance (radius) away from the cities geo data. I presume I can either create an admin field where the distance can be set or simply hard code it in the module.

So, I am quite new to creating my own custom module and apart from field api I have not had much experience with other drupal api's - especially the views api.

Here is what I need to do - as far as I am aware:

Create a custom module - I don't think I can get around that - that:

1) gets the $2 and the attached geodata

2) creates a view for all nodes with taxonomy term $3 attached to it and filters them using proximity to only show nodes in a XX km radius from the geo point supplied by $2. This obviously includes converting lat/long to distances from the set point...

3) I want to be able to display a proximity slider so the radius value can be changed and the view refreshes.

I know this sounds like a massive job, but I thought that maybe I could do some of it directly in views and then maybe use some alter_hooks to add queries (for example to grab the geo data for $2)...

Can anyone help me with this, or give me some tips on how this can be done?

I just need some sort of strating point as I am totally new to this. I would also supply any code written back to the community and document my processes for others to follow.

Many thanks in advance.

share|improve this question

1 Answer 1

This is a broad question and becomes difficult to answer clearly. There are too many things to do and too many details to resolve. It looks a bit like you are trying to eat an elephant with too many missing teeth. I agree that you will need to create a custom module and by the description you gave, you will need knowledge of php for server side (pre display) and Javascript for client side action (after display). The first thing to do is get do some exploring in the structure of Drupal and how it operates. From my own experience I know that a couple months of exploration has made a tremendous difference in my ability to solve a problem like this. Do you have any programming experience? If not start with php basics. Then move on to Drupal.

There is an excellent video tutorial series at buildamodule.com. It charges for some of its content, but it covers a lot of ground. Building a module will require php/mysql expertise (book:Beginning PHP and SQL by W. Jason Gilmore), an understanding of Drupal operations (book: The Definitive Guide to Drupal 7 publisher:Apress) and a solid knowledge of the key modules (book: Drupal Building Blocks by Earl & Lynette Miles).

You'll know your ready when you find yourself looking forward to writing a custom module.

share|improve this answer
    
Hi Joe and thanks for your input! Yes, I have previous experience. I have recently written a field type module (my first ever: drupal.org/sandbox/tecjam/1320886) - for the same project - I have coded php (home taught) for the past 5-6 years on and off. I built my first drupal site with D5, but I didn't require many new functions for this - just a download counter / direct link checker / download script which was easily implemented. My main areas are theming / css3 and xhtml stuff and creating drupal themes from .psd files. I do have drupal books, but none delve into views in detail ... –  tecjam Nov 22 '11 at 14:50
    
I have also watched some talks from past drupal-cons on archive.org over the past few days, which have all been excellent helping me to understand some basics behind hooks and ['#ajax'] calls in D7. I agree that I am a bit stumped when it comes to geolocation and taxonomy / views modules, but plucking existing code apart - eg: openlayers proximity - has also helped a lot... but I just need a starting point for now and I am not sure what this is. But you are right, a bit more reading / learning and understanding is needed. –  tecjam Nov 22 '11 at 14:54
    
However, the reason I posted this here and groups.drupal.org/node/191253 is to get some side input as I have no one else I know I could ask about drupal or coding issues. Also, I am on a tight schedule and need to show some progress rather fast, so long nights / weekend lay ahead ... But I am sure it will all pay off eventually. I just wish I had done more research a lot earlier / kept at developing drupal over the years... But it's never too late =) –  tecjam Nov 22 '11 at 14:58
    
Sounds like you've got a good background to solve this! I can't help with location, but I can with views. For views I would recommend viewing "Taming the Beast" video series at Nodeone.se. Views is still likely to through a few curve balls especially with contextual filters and taxonomies. IF you search this site for both tags, you will find what a lot of answers for the suspected 'bugs' (so far the bugs have been me!) Or ask here. Great book = "Drupals Building Blocks" written by merlinofchaos. –  Ashlar Nov 22 '11 at 19:50
1  
Thanks for your input again. I will take a look at that book, although I have seen that it is written for D6, but there shouldn't be too many difference in the code to adapt it to D7. I guess my plan of action is to first write a function to analyse the url and grab the tid from it, then query the tax_geo field for that tid and return the geodata for that tax term. then i'll be a little further and can reevaluate where to go next... –  tecjam Nov 23 '11 at 9:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.