I have a content type called Cars, and a content type called Prices. They are node referenced. The Prices content type has a decimal cck field for the price called field_price. So you can create a new Prices node that will have the price for the car. There are multiple Prices nodes for each Car node. In views, how would I be able to show the lowest and highest prices for the car. For instance, it would say, Prices for this car range from $10,568 to $18,259.

  • 2
    Why do you create the price as a content type instead of using a CCK field that allows multiple values to hold the price? – googletorp Jun 27 '11 at 9:12
  • For price comparison shopping. It is actually a little more complicated than I explained. Each Price node for a certain car is put into a view and attached to a car node. It has the sellers name, the price, and the sellers link to that car. – Joe Jun 27 '11 at 19:48

There may be a more fancy-pants way to do this, but I would take the view template, extract the car type, and do a manual MIN() MAX() query to fetch these values.

  • Can I stick the MIN() MAX() query right in a views-field.tpl? – Joe Jun 28 '11 at 21:25
  • You'd want it on the page template, not the field, right? I mean, the answer is yes, put it in the appropriate template. Or rather, write the function in a module somewhere and call it in the template. – Entendu Jun 30 '11 at 18:47
  • But if this is a view, it needs to go in a field tpl to be added to the view. Printing it in the page tpl would just print it arbitrarily on the page. Am I correct? – Joe Jun 30 '11 at 18:52
  • It really depends on how your view is structured. If the view is a list of the members of one type of automobile, then you wouldn't want a count on each field. If the view is a list of types, you /would/ want the count on each field. Make sense? I'd just put it generally: add the code to the appropriate tpl ;) – Entendu Jun 30 '11 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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