Having a hell of a time trying to get this to work. Using the "Getlocations search by city" menu (block) with the "Getlocations by city" view. However, the specific city data is not being pulled -- all results are being pulled.
Have even tried modifying/appending it thusly:
/getlocations_by_city/% for paths
USE CASE:
Building dynamic views, as menu tabs.
Each tab will display only nodes of a certain content type, for that city
Tried, among other things, setting:
A. validation with content type in Getlocations Fields: City contextual filter,
B. with no-value setting to "Display 'no results'",
C. adding a Node:ID relationship.
I also tried creating a custom Content view, using the Getlocations Fields: City and Getlocations Fields: Node ID relationship. In none of the cases is the specific city data being pulled.
Would like to know if anyone else has had success with this pre-packaged view, or custom one to work with the "menu".
I have done this successfully with Taxonomy Term page (and taxonomy menu), but in doing so, it interrupts that default behavior for term pages where I don't want the tabbed page displays.
Comments
Comment #1
hutch commentedFirst of all what I would suggest is that you revert the 'Getlocations by city' view back to its original state, clone it, disable the original and continue with the clone.
If you want to filter on content type you can do that under Filter criteria, on 'Getlocations Fields: Field name'.
Put the machine name of getlocations_fields in there. For instance I have a content type where I have added getlocations_fields with the machine name 'field_address'.
You can also do this with 'Content: Type' but that will make your query more complicated.
The Getlocations Blocks module provides a block with a dropdown with a list of all the cities found in the getlocations_fields table. This list is not restricted by content type or field name, although I might add this feature when I can find the time (or someone provides a patch). Getlocations Blocks is not a menu and does not provide that facility. You would probably have to write a module to do that.
Alternately you could create a new view that makes a list in a block. I have just tried that, very easy, create a new view with 'show: Getlocations', remove 'glid' from the field list, add 'Getlocations Fields: City' to the field list in Master, remove the label, go to rewrite results and select 'Rewrite the output of this field', add [city] to the textarea, select 'Output this field as a link' and set 'getlocations_by_city/[city]' as the path. Then add a block, test, save and enable the block.
You can achieve the same result by selecting 'show Content' and selecting the content type you want when you first set up the view, more complex but it should work.
Of course the above is not a 'real' menu but it can be made to look like one.
The path 'getlocations_by_city' on its own does show all the locations by default, as you have discovered you can change that to suit your needs.
Comment #2
greta_drupal commentedThank you for the quick response. But, a bit baffled by the suggestions.
If you want to filter on content type you can do that under Filter criteria, on 'Getlocations Fields: Field name'. Put the machine name of getlocations_fields in there. For instance I have a content type where I have added getlocations_fields with the machine name 'field_address'.
You can also do this with 'Content: Type' but that will make your query more complicated.
I cannot use regular Filter for City because this is a dynamic view -- one View to work for all cities. The value of that filter will depend on which link was clicked in the "menu" block, passed by the URL. In any case, isn't the point of using arguments (contextual filters) to pull a smaller result set? I don't want to pull tens of thousands of results for 133 cities, I want to pull all results for 1 city -- depending on the "menu" item clicked.
Filtering by content type for the content-type-specific Views tabs isn't the problem. I can do that with regular Filters, after narrow to the correct city, since that value is known. Although, I'd prefer to use an argument for it, if (as I understand) it pulls a smaller result set. [Guess the performance questions is what is more efficient: more complex sql statement with smaller result set, or simple SQL statement with mother-of-all result set.]
Alternately you could create a new view that makes a list in a block. ...select 'Rewrite the output of this field', add [city] to the textarea, select 'Output this field as a link' and set 'getlocations_by_city/[city]' as the path.
Huh?? This is exactly what that included block already does. Creates a link to that path. (Works just as a menu, such as Taxonomy Menu, does.)
You can achieve the same result by selecting 'show Content' and selecting the content type you want when you first set up the view, more complex but it should work.
As noted, I have tried building a content view. That is the view type that I need. I would like to have a geo map for each city+tab too. But, for now, just trying to display a listing of all nodes for city.
Comment #3
greta_drupal commentedBTW, I did clone the getlocations_by_city view before customizing.
As for the original getlocations_by_city view, created by module's code, it doesn't work as is. Why not change the view path to
/getlocations_by_city/%so that it works with the search_by_city block straight away. An out-of-the-box solution -- same as Taxonomy Term view.In my case, I need it to do more. But, would be nice to have the included view useable.
Comment #4
hutch commentedI have installed getlocations_blocks on at least half a dozen occasions and it has worked in conjunction with 'Getlocations by city' view without any editing at all. I tried adding '/%' to the path in the view and it makes no difference unless you enter nothing in which case you get page not found instead of everything. I prefer the latter, You can tweak the settings in Contextual Filters to deal with that, a more elegant solution.
You can also show more than one city, for instance you can add 'getlocations_by_city/new' to your URL and you will get all the locations in all the towns starting with 'new' (FWIW)
getlocations_blocks uses jQuery to pick out the selection from the dropdown and redirect to the page, perhaps there is a javascript problem preventing getlocations_blocks.js from building a proper URL.
Comment #5
greta_drupal commentedAppreciate your responding, Hutch!
I have just tried a complete overhaul of my CONTENT view. Using a few variations of argument & relationships -- with and without a relationship; required relationship and not; and pulling out the Content:Type argument (putting that in regular Filters). Latest attempt:
Views is getting the city name because the argument is populated in the title and breadcrumb override. But, it isn't pulling any data at all. Just cannot figure out why.
* I keep deleting the taxonomy term relationship, but after save it reappears. I am assuming it is because I have the Location Taxonomize module on. (???)
I have attached my view, in case you (or anyone else) is feeling generous to have a look.
Comment #6
greta_drupal commentedThe page displays for "Food & Drink" and "Overview" are the most accurate for settings. The others are placeholders, but I think that I have synced all my changes to those too.
BTW: This works fine in test with a city filter with manual city entry. It fails with the dynamic argument approach. Also, this same view with argument taxonomy term (normal vocab for city) works also; that is not ideal b/c it screws the auto behavior for all other taxonomy terms -- and requires a redundant field on form for selecting applicable city.
Comment #7
hutch commented