Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
3 Jul 2007 at 03:36 UTC
Updated:
11 Oct 2007 at 00:21 UTC
Currently, the Theme Wizard requires you to modify source files. This request is to change Views so that the Theme Wizard can create themes that are stored in and processed from the database, eliminating the need to modify source files.
Modifying source files (often AKA "customizations" in the IT world) reduce agility because they make upgrades more difficult: the source code customizations have to be reapplied to newer versions. Not only does that require a lot of manual file manipulation, but it could require rethinking the customization if the program works differently in the new version.
Comments
Comment #1
merlinofchaos commentedUhh. Theme functions and theme templates and the like are fundamental Drupal customizations. I will absolutely not invent my own system of storing stuff in the database for that purpose.
As someone who builds sites professionally, I actually think storing stuff like this in the database is actually far worse than creating theme functions and templates. You still have code, but now the code is hard to find and hard to apply revision control to. I'm sorry to say but this request is a terrible idea.
BTW, you don't have to modify 'source files' to do theming customizations. You modify your theme. Many, many, many things in Drupal require theming customization. If you're not using a customized theme, I'd find that very odd.
Comment #2
aren cambre commentedI think this is a reasonable request.
Many products in the real world work this way, including many of the .Net Framework's databound WebControl objects DataTable, DataList, et al. They all have an ItemTemplate field where you can insert arbitrary tags and special tags that represent data objects. Using something like that, Views would use that pseudocode to deliver the final rendered content.
For example, if my view had the fields firstName, lastName, salutation, and city, right now I am pretty much limited to displaying full nodes or a grid of data. But with something like an ItemTemplate, I could instead type the following into a field:
<li>Hello, <!salutation> <!lastName>! You live in <!city>.</li>Of course, there would need to be a couple of additional fields like HeaderTemplate and FooterTemplae. In this case, I would have the following in HeaderTemplate:
<ul>...and this would be in FooterTemplate:
</ul>Additionally, it would be great to have an AlternatingItemTemplate field. With this, the content would be rendered in this order:
HeaderTemplate
ItemTemplate
AlternatingItemTemplate
ItemTemplate
AlternatingItemTemplate
...
FooterTemplate
In AlternatingItemTemplate, I might insert the following html:
<li style="background:silver">Hello, <!salutation> <!lastName>! You live in <!city>.</li>Think about this. It isn't rocket science and it will make your module much more usable and customizable to the masses while increasing its usefulness for power users.
Furthermore, it gets us out of having to customize PHP code (which is a terrible idea if it can be avoided). Once Drupal gets a critical mass of templates, it is likely that template users will need to do zero modification to templates. Furthermore, getting us away from modifying templates will make it easier to swap in other templates or upgrade to newer templates at will.
As for version control, there will usually be so little code in each of the fields that revision control will hardly matter.
Comment #3
merlinofchaos commentedDon't be retarded.
Theme functions are designed to be templates. They are exactly what you're asking for, except they happen to be PHP Templates. You can use another theme engine (such as Smarty).
In any case:
THIS IS HOW DRUPAL WORKS. If you disagree, you're using the WRONG content management system. Period. This is NOT a Views problem.
No, NO, NO. This topic is *C*L*O*S*E*D*.
When I close an issue, I fucking close an issue.
Comment #4
merlinofchaos commentedOh, and just to add, you asked me to write a templating system.
Drupal has a perfectly good templating system. I will not write a new something that the CMS already supports. That's why the "retarded" comment. It's like being dissatisfied with the size of the wheel and suggesting I build a new one.
At that point, why use Drupal at all? Turn Views into its own CMS entirely.
Comment #5
aren cambre commentedAll I am asking for is a way to make views output content in a custom format without requiring a multi-step process involving source code edits. I am not asking for The Views CMS.
Comment #6
aren cambre commentedBTW, this is NOT a templating system. This is merely a request to divert some rendering logic to code that takes its cues from up to four fields on the view setup page. It's not rocket science provided you're familiar with the Drupal API and PHP.
Comment #7
michaelfavia commentedAren, Earl has stated his case and doesnt agree with your request. If you disagree youre always free to code it yourself and submit a patch. If after such a review it turns out to be a good idea im sure earl will reconsider. But from my cursory glance over your arguments i dont see much value in reinventing the wheel either. Good luck, -mf
Comment #8
merlinofchaos commentedFYI:
<li style="background:silver">Hello, <!salutation> <!lastName>! You live in <!city>.</li>Exactly how is that not a templating system?
Also, I have to say, for something that's not rocket science, what you want to do is surprisingly hard and lots of work. But hey, if you want it badly enough, I know you'll be able to write the patch.
Comment #9
dfletcher commented#1 - perhaps the contemplate module is appropriate for what you want? You'd have to switch to "teaser" or "full node" type views, but it does let you keep all your modifications in the database, which seems important to you.
#2 - if you do attempt to patch, I'd advise not reinventing the macro system (a reinvention inside a reinvention - heh) but instead look at Jeff Eaton's lovely token module, which might make that part simpler.
Just throwing in my 2 pennies now - why do you think it is bad to modify files for theming? I write a whole custom theme every time I make a site - so that's somehow wrong? If it's Drupal core files you're talking about modifying, then yeah, avoid it - Drupal gives you many ways to change things without modifying core or contrib modules. But that should not be some blanket rule saying "never touch any file".
Good luck.
--dfletcher
Comment #10
dfletcher commentedSo sorry the renaming was accidental!