Allowing a Block or node to choose its own display

r_honey - August 3, 2009 - 06:48

I come from a DotNetNuke(DNN) background, and I am just beginning into Drupal theming. I have a sample page ready in Html/CSS that I want to convert to a Drupal theme for a portal.

In DNN, a page or a container (consider a block to be equivalent to a container there, although there are differences), automatically inherits the theme selected for the portal (site). However, each container/page can select its own theme, if desired.

In the sample page I have prepared, I have 2-3 designs in which blocks can be rendered. So, my question is it is possible in Drupal to allow a node/block to pick up its own design (probably somewhere inside their configuration)?? Or do all blocks/pages are constrained to use the same design specified??

I am studying the Theme guide. At a glance, it seems like I can spcify a different template for each node (page/story/poll etc.). But what I am looking for is to specify alternative templates for a single node (say page) or block and have the block/page pick up the appropriate one in its configuration.

Down with DNN

i-sibbot - August 3, 2009 - 11:49

God job on deciding to change over to drupal. I've used DNN and personally thought it was very restrictive and poorly built.

This sounds like you need to create a block tpl.php file and name them accroding to the block name.

This might help, its all in the naming convension.

http://drupal.org/node/104319

i-sibbot, although I try to

r_honey - August 4, 2009 - 06:42

i-sibbot, although I try to avoid being dragged into any kind of platform comparisons (each has its strengths and weaknesses), but your remarks definitely require a reply.

I can provide you multiple instances of DNN's superiority over Drupal (the most glaring being its exceptionally excellent handling of modules). In Drupal, you can have only one instance of Forum module on a site. In DNN, you can have as many as you wish.
Similarly, there are areas where Drupal is a lot better.

Being a person who has turned DNN inside out (and looking to do the same for Drupal), I have personally assigned areas of application of both. DNN's flexibility (coming in major part from ASP.NET) is unmatched for data-centric portals, intranet management applications & the like.

However, DNN is too bulky & slow for regular internet Portals, especially if that is official website for your organization. Drupal is lightning fast compared to DNN for regular browsing.

Although, I can present more comparisons of superiority of both in their own terms, as I said there is no point in making them most-of-the time.

Anyways, thanx for the link. I am studying it. If anyone has more ideas related to my original issue of display, I would be all ears.

--
I always think tomorrow will have more time than today.
And every today seems to pass-by faster than yesterday.
http://www.rahulsingla.com

Typical DNN'er

i-sibbot - August 4, 2009 - 12:41

Your disclaimer is then immediately contradicted with your unasked for bumph. I to dislike unrequired comparison discussions so I'll be ending this particular strand of thread here.

Funnily enough, you type of response is quite uncanny to a lot dnn and .net developers I've dealt with through out my career. All I can say is that a rolling stone gathers no moss.

Oh, forgot to mention. Good luck with your endevours in drupal. I hope you suceed... and it's actually open source to. No money! Blimey!

...

Jeff Burnz - August 4, 2009 - 08:38

It depends on what you want to do with this on node, and how you want to be able to do it, which is not clear in your posts.

If you want to select from preset templates at node creation time you're out of luck unfortunately, something Plone has supported for years :) I spent ages one week trying to get selectable *node* templates to work using TinyMCE and prebuilt selectable layouts but it never worked that well and I ran into many issues.

If you just want to select a preset *style* for one node, well you're shit out luck again—doesn't that suck? Of course you can easily work around this, say for example doing this http://adaptivethemes.com/give-your-nodes-some-class

Blocks are a different story, there are at least 3 modules that can help you out here, Blockclass module, Blocktheme module and the newer Skinr module. The latter is able to style content types, view and panels also. I say *style* because none of the above modules will pull a template on your behalf.

The way to get around this is template suggestions, where you start using node-[nid] & block-[id] level suggestions, and its easy to add to the suggestions array specifying what ever conditions you want (within reason of course). Then the 2nd half of the equation is of course CSS...

Now, all that said I could be missing a module that allows you to select a particular template for a single node or block, but I haven't ever heard of one, but that would open up a brave new world for end users, and I still find this an unbelievable oversight in Drupal. I suppose one day I'll sponsor a module that does it, can't be that hard...

Thanx jmburnz. Firstly, you

r_honey - August 5, 2009 - 04:00

Thanx jmburnz. Firstly, you understood my problem perfectly. And secondly, for those module suggestions. I think Blocktheme module would do my task in the short term. A quick look at Skinr made me feel like it is more powerful, but also would require some time to get used to. However, Blocktheme is almost as simple as it could have got.

You said, none of these modules would pull a tmeplate on your behalf. On the contrary, I believe Blocktheme does exactly that. Creates multiple block tmeplates, and specify the one to choose in Admin interface.

--
I always think tomorrow will have more time than today.
And every today seems to pass-by faster than yesterday.
http://www.rahulsingla.com

Hmmm, if Blocktheme can do

Jeff Burnz - August 5, 2009 - 04:09

Hmmm, if Blocktheme can do that then wicked, I've certainly been missing something there! I tend to use custom template suggestions a lot or other theming methods so thats probably why I missed it :/

Cheers dude!

PS, just ignore the platform debates that go on here, they're so boring, best to just avoid the fundamentalists...

Hows the fence post.

i-sibbot - August 6, 2009 - 10:44

Boring indeed Hence my lack of uptake (should never have made a passing comment in the first place). I've used both and as r_honey said. Both have there uses.

Peace and Love to everyone.

jmburnz, I was able to

r_honey - August 16, 2009 - 07:54

jmburnz, I was able to successfully port my Html/CSS sample page into a Drupal theme with support for selectable Block templates with the help of BlockTheme module.

Now what I am looking to do is to replicate the same for any node, i.e. provide selectable Node templates to the Admin at node creation time. I also have the ideas flowing regarding how can I achieve this within the Drupal framework without any sort of hacking.

However, due to my still limited knowledge of the extensive Drupal API, and my workload, I dont think I would be able to accomplish this in a decent time within my constraints. So, if someone is interested in having an attempt at this, probably we can work together.

I basically have 2 ways in mind as to how to accomplish this:
1) Create a new Module say NodeTheme. Like the built-in Upload module that adds an upload file(s) link during Node editing, this Module would basically add a Drop-Down list of selectable Node templates that can be configured in the Module's Admin interface.

The real part of selecting the appropriate template at rendering time, could either be done by hooking into something (I dont know what) if Druapl allows where we can ask Drupal to load the appropriate template file (as done in BlockTheme).

If Drupal does not provide anything of this sort, then the theme itself would need to co-operate with the module. Inside node.tpl.php (I believe that's the file used to render the node), the theme would check the appropriate variable on the node specifying the template as set by the NodeTheme module, and use the appropriate template for rendering.

2) Again I am not sure if this is possible, but I think we can even avoid the NodeTheme module, and do it entirely in the theme itself. The theme can use the theme_form hook to add the drop-down list of pre-defined templates (to each node-editing form), and the rest (the actions during the rendering time) should remain the same.

Anyone thinks my ideas are feasible within the Drupal framework.

--
I always think tomorrow will have more time than today.
And every today seems to pass-by faster than yesterday.
http://www.rahulsingla.com

 
 

Drupal is a registered trademark of Dries Buytaert.