Hello people of this forum,
My topic will not be about asking help to solve a technical issue, but more about trying to understand how to be right while developing a Drupal site. And to be more narrow, how to chose what will be a custom module, or what will/could be handled by Views.
Let's take an example anybody could meet in his project. Let's figure out an eBay-like site with a content type "Products" (I'm actually NOT building an eBay like site, so no need to tell me an existing module could solve the whole problem, that's not the point ;). While we want to display a list of product, we may need to output data:
- from the node itself (node title, description, etc.)
- using a relationship to a user, to retrieve the email address of the user who posted the product, for instance
- or by "ad-hoc" computing, to display for instance the number of days the product will still be available (something like "product creation date" + "life time of the product" - "today's date"). Ok the example is a bit stupid here, but you may have to compute something out of the blue from a node field, and display it.
If we stay on this list view example, I see (at least) 4 ways to do it:
- using Views with fields + customfield
- using Views with fields + viewsApi
- using Views with Nodes + writing templates
- writing a separated custom module to do the whole business
Each approach has + and -, and there may even be other ways to do which I don't know. Even if I'm a developer, I don't like the last option, because it doesn't use all the advantages of already existing modules, and it's a pain to maintain (each developer on the project will do things his way). I'm not a big fan of Views with Nodes neither, as it multiplies templates. I like Views + fields + clean CSS, but it's more sporty as soon as we need computed fields...
Being new to Drupal (less than a year), I wanted to have a feedback of more experienced users, especially from those who try to avoid custom module development and who make a good use of Views.
Thanks by advance, and good luck for all your September-in-a-rush projects :).
Comments
From your last comment - I'm
From your last comment - I'm actually not who you most want to hear from! But personally, I almost never use Views, and I code pretty much everything into custom modules.
Views is actually an amazing module. It is a very well written piece of work, and not just the output but the admin interface as well. I am a big fan of the idea - but for me it's not what I want. I find that by writing my own modules, I can keep the code down to the minimum of what is necessary to output what I need. This takes away from some of the footprint of the module.
I have used Views in the past, and I will most likely use it in the future. It really is an amazing module, and has helped make Drupal the system it is. But I just generally prefer to write my own code.
Contact me to contract me for D7 -> D10/11 migrations.
Views is great, but I prefer
Views is great, but I prefer to use Views in conjunction with nodes, especially if we have CCK installed and is used for specific types of node articles. Also to quickly make blocks for specific data sets like nodes.
However, everything else, I prefer to use custom modules. It's fun to do, and you have more control, and less bloated views code. I suggest you don't use Views if you can just make a custom module, but if Views is already going to be activated/installed, then try to use Views because the code is already mostly loaded.
9/10 I use custom modules. Especially if it turns out to be amazing and I can give it a public-release, and upload to drupal, I wouldn't want to require dependencies for Views.
.
I think this page says it well: http://drupal.org/node/242311
FWIW, I use Views whenever I possibly can.
Michelle
Thanks for feedback
Hi guys and Michelle,
Thanks for your answers, indeed whatever is your preference, it's always good to hear opinion on such a critical choice :). The topic remains open for anybody who wants to give input.
Cheers,
DP.
I happen to be a developer
I happen to be a developer and I prefer to use views when possible. Custom code means something I have to support and is would not be as flexible as views. While I like views with fields it is limited when listing multiple types of content types. For that case I have been using the display suite. By adding a build mode which I use in the view, each content type can have its own layout while retaining the flexibility of fields.
Still a bit of a noob
I have been working with Drupal for little over a year now, and consider myself a bit of a newbie still, although I can write custom modules and more - there still seems to be a huge amount to learn and discover. Not only in the code and operation of Drupal, but very much like this thread, what is best to do and where.
I feel that every time I use views, unless it's for something very simple, the amount of time spent searching for how to mould views into exactly what I want could have been better spent in rolling my own and moving on to the next part of a project.
Regarding the comment made earlier about custom modules requiring maintenance by the original coder should any changes need to be made - I have to say that for 99.9% of my clients so far, I would be very uncomfortable giving them admin acces to views and allowing them to make changes themselves, so I end up with maintenance/changes landing on my lap still - but hey, it's all chargeable :o)
Always interested to discover how other Drupaler's prefer to work, and what is considered 'best practice' by different people. I would be grateful if any of you knew of any resources with this kind of discussion/collaboration, if you could point me in the right direction.
cheers
-Kris-
_
Other than "don't hack core or modules" everyone pretty much has their own best practices. I too prefer to use views and I find the time I spent learning views has more than made up for the time I would have spent custom coding the same functionality. Don't discount the fact that views have an upgrade path while any custom code you create will more than likely have to be manually updated for newer versions of drupal (for each manually created page). Upgrading views is as simple as installing the new version and running update.php-- and all views are updated at once.
Plus, there's all the views integrated modules as well as things like view caching. imo using views on anything but the simplest of sites (1 or 2 page brochure type) is a no-brainer.
Also, you can always store your views in code and disable the views ui-- and update the view that way (or use features).
For a great way to learn views, see the excellent screencast series over at nodeone.se.