2

Is there any way to compare nodes of different types but with the same fields?

  • I have 2 content types: Flats to rent and Flats wanted

  • Both types have the sames fields: rooms and city

  • In a view I have a list of the Flats wanted and each one has a button: find flats

  • When you click the find flats button I need to show all the flats to rent that have the same values for: rooms and city than the clicked flat wanted

I already get it working by creating a View using $_GET variables in the url and arguments. But I need to use clean urls, then$_GET must go out.

Is there any way to do this in a cleaner way? I need to do it using View because I need to be able to apply bulk operations in the resulting list.

Maybe a module could do this??

Thanks

4
  • Please elaborate on $_GET and Clean URLs. Clean URLs does not affect what is available via $_GET. Clean URLs only affects how URLs generated by Drupal look like. The translation of a "clean" URL to a canonical one is done by the webserver and Drupal hardly ever notices that the user actually entered a "clean" URL.
    – Oswald
    Aug 23, 2011 at 11:00
  • by clean url I meant: passing just the id of the 'flat wanted' type node. Then after the View should look for coincidences in 'flats to rent' type nodes and list them.
    – chefnelone
    Aug 23, 2011 at 11:14
  • I guess you'll be better off with panels. Aug 23, 2011 at 12:20
  • @barraponto how would you do it?
    – chefnelone
    Aug 23, 2011 at 20:07

3 Answers 3

1

I would create a custom field handler. This gives you full PHP power about how the link of the "find flats" button will look like.

Writing your own handlers for views maybe looks difficult at the beginning. Once you understand it you will use it a lot. Here I found a how to about how to do that (it's for views 2). You'll find a lot of real world examples in all modules that do support views. Look for code like MYMODULE_views_handlers .

0

Just because you enabled clean_urls does not mean you cannot amend additional arguments. On the contrary, Drupal will intelligently pass your additional arguments directly to the View or to whatever module.

For example, these paths:

example.com/node/1/edit
example.com/node/1/edit/foo/bar

will both take you to the same place.

If your view is at the path 'flats' you could simply append arguments to the url:

example.com/flats/arg1/arg2/arg3

and Views can handle them just fine.

I wouldn't recommend panels.

1
  • I see your point but the two content types I need to compare have more than 50 field. Adding 50 arguments in a path will produce a ugly url. I´m now working in creating a module to compare nodes sharing the same fields. Why do you recommend me to use Panels?
    – chefnelone
    Nov 1, 2011 at 12:41
0

Try Node Compare. At the moment it is the most elegant and easy solution to compare nodes in Drupal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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