On my d6 site I have a custom content type in CCK and I want to have a custom theme for all pages of that type. Pretty easy to set that up -- make a Zen subtheme and assign it to /type with the Page Theme module -- but I'm not sure how to grab different parts of the content.

For instance, my content type has about four different text fields and an image, and I'd like to position each of those fields around the page (and use ImageCache for the image) -- but I'm not sure how to get those. All I see is being able to grab $content to spit everything out on the page.

What's the best way to do this? Is there a way to just code in a few custom regions, have views that get the node title from the URL as an argument, and place those views blocks in their corresponding regions? Or can I do it in the code level with a custom theme?

Thanks all.

Comments

RowboTony’s picture

Hi, as with all things Drupaly - you can accomplish this several ways. It looks like you are comfortable working with modules and themes and just need some helpful pointers to get you started.

I think the fastest and most user-friendly way would be to install Display Suite for Drupal 6. This set of modules will allow you to point-and-click, and drag-and-drop different CCK fields to different regions within a page (see image below).

== Option #1 / Display Suite ==

- Download:
Display Suite 6.x-2.3 http://drupal.org/project/ds
Node Displays 6.x-2.9 http://drupal.org/project/nd
Node displays contributions 6.x-2.9 http://drupal.org/project/nd_contrib

- Enable these in the Display Suite section on the module page at www.yoursite.com/admin/build/modules
[*] Display suite
[*] Display suite UI
[*] Node Displays
[*] ND CCK

- After these modules have been enabled:
Go to www.yoursite.com/admin/build/ds/layout and select to Edit the layout within the custom content type you want to work with, such as Full node, Teaser, etc.

There you will find a configuration page which will allow you to drag-and-drop those custom CCK fields into whichever regions you want them to be rendered in, such as Left, Right, Middle, Sidebar, etc!

Image: Node Display field region placement config page http://drupal.org/node/520252
Only local images are allowed.

== Option #2 / Devel Themer ==

- If you really want to get into the nitty-gritty code level stuff then you'll want to watch these awesome videos by Johan Falk at NodeOne.se:

Seven steps to black belt in theming Drupal 6

http://dev.nodeone.se/node/620

I don't recall if Johan gets into devel_themer in that series or not, but the following will also help you pinpoint those fields and region variables you are looking for:

- Download and enable
Devel 6.x-1.26 http://drupal.org/project/devel
Devel Themer 6.x-1.x-dev http://drupal.org/project/devel_themer

http://blip.tv/moshe-weitzman/theme-developer-module-for-drupal-6-screen...

== Option #3 / Panels, CTools, Page Manager ==

You also mentioned something about views getting the node title from the URL as an argument, etc. If you want to go to that extent then look into Panels, CTools, and Page Manager. With these tools you can make variants with Page Manager, and use arguments that would read the [nid] from the url, etc. That's a powerful combination of modules that allow you to bend a Drupal site to the fullest extent of your imagination, but that's a deep rabbit hole to start going down within Drupal 6. I never touched Panels in D6, but I use it extensively in D7.

Have fun!
-- Tony

VTHokie89’s picture

Hi Tony,

Thanks for the incredibly helpful post. Display Suite does, indeed, seem to be incredibly user friendly.

However, it seems to be somewhat inflexible in that I'm having trouble making it work with my custom theme. Is there any way to expand the region options to include my own additions -- or, even better, pull data from the page.tpl.php file in my theme?

Thanks in advance!

RowboTony’s picture

So, I've not worked with D6 very much, only the D7 version of Display Suite... seems that whole "custom region" thing doesn't work in DS for D6 :(. In fact, after further investigation in my sandbox it seems that DS D6 does not allow you access to your custom theme regions at all, it only gives you Header, Left, Right, Middle, Footer regions WITHIN the body, and doesn't really do anything that you couldn't do with CSS alone :( I've been too used to the D7 version of Display Suite - which is a paradigm shift compared to the D6 version and will allow you do to all sorts of fancy region to block stuffs in D7 only.

That said, try cck_blocks for D6 - http://drupal.org/project/cck_blocks if Display Suite isn't getting you where you need to go than you may as well disable it entirely. I played with cck_blocks in my sandbox before recommending it. cck_blocks will allow you to pull out any cck_field and place that field in a block in any region.

I created a Zen subtheme with a custom region footer_top, then I enabled cck_blocks for a cck_field_image following the instructions on the cck_blocks module page, except the instructions are for D7, so instead of going to the D7 paths you'll have to go to the D6 CCK paths such as mysite.com/admin/content/node-type/custom-content-type-1/fields/field_custom1 to get things setup. With no .tpl coding - just point-click, enable "Provide block for this field:" in the cck field configuration page, then your cck field will be available as a block. You can also chose to hide that cck field from the main body $content-> via CCK Display Fields [] Exclude checkbox. By hiding a field from the main body it will show up only in that sidebar block you configured.

Take a look and let me know if cck_blocks is more helpful for your needs than the previous Display Suite recommendation :/

-- Tony

VTHokie89’s picture

Thanks again, Tony, for the help. Funny note -- I actually installed Display Suite and it wreaked utter havoc on my site. Gave me database schema errors and took all of the content out of $content for each published node -- good thing I'm still building the site, because otherwise that could have really caused some serious problems.

I'd already heard of CCK Blocks through a mirror post of this on Reddit, but it's what I'm deciding to go with -- so thanks for the right direction. I do have one lingering problem, though --

If one of my cck fields is an image, how do I get imagecache to handle it before putting it in a block? Views w/ argument that just returns the image?

RowboTony’s picture

Hi, just want to be sure you know of and are using http://drupal.org/project/backup_migrate? If not you'll want to get familiar with it before borknig your site while testing modules, such as our little Display Suite excursion :). http://drupal.org/project/backup_migrate - learn it, use it, love it, break things, restore.

As for CCK image fields outputting with views, I have only built 2 D6 sites and neither used ImageCache (I've build 14 Drupal 7 sites in the past year however :). The D7 image processing crunches all of the images on initial upload and saves the files in the corresponding sub-directory such as:

sites/default/files/styles
                           /large
                           /medium
                           /thumbnail

I'm assuming, after reading this overview page - http://drupal.org/node/163561, that this is how ImageCache works? In which case you would just change the path in your view from sites/default/files/imagecache/default/images.jpg to sites/default/files/imagecache/thumbnail/image.jpg. If that is not the case then we'd have to do some Drupal imagecache views Googling to investigate further.

..... or, if your source images are all the same dimensions you can take the easy way and CSS resize those particular images. Of course resizing with CSS isn't the "best" textbook way to accomplish this, but in the real world sometimes you just have to get stuff done any which way you can to deliver the project :)

ErgunK’s picture

In addition to drupleg's suggestions; if there is no big differences between content types' layouts and if they can be handled with CSS...

Drupal(at least Drupal 7) adds the CSS class names of the content type to body class array(if you inspect this page's code, you can see "node-type-forum" class in body class array). This way you can use different CSS styles for different content types. For example: Consider you have a Apple and Orange content types. To style their titles, you can use this CSS targeting:

.apple h1{
color:#ADFF2F;
}

.orange h1{
color:#FFA500;
}

For blocks, you can define pages to show or don't show that block in that block's configuration page.


Mediasaur | http://www.mediasaur.com/en | http://twitter.com/mediasaur


Before asking for help, please read this http://slash7.com/2006/12/22/vampires/ and don't be a "Help Vampire". :)
mbarnhizer’s picture

As someone not at the level as the original poster i am looking for the best, or next step to take after creating my sub-theme with drush. Files in place, sub-theme loaded on localhost, but from there??? Or here????

I am thinking of trying to duplicate what i put together using my drupal garden account which gives me something to pick apart and learn from. The componants such as the HTML, CSS, ETC i would think would need to be similar. I have done pretty well learning knew things by taking apart a good example of what i want to learn. Having My Drupal Account as a guide for this first time going from A to Z with loaded CMS will help. My end goal is to have my own cms site, and your advice in your post tells me I am seeing three options to consider? to look at?

I have already started looking into panels, but if I could ask you which method would you recommend I take to go forward in my duplication project? The project My Drupal Garden I think has all of the different functions (Blog, Slides, etc) one might want (on a basic level), or find in their site. I purposly loaded the options to it's fullest to see and understand what an example with all the options will look like. For now it has plenty, and is what I think is a good starting point to take things from A to Z.

If we call having my sub-theme created and loaded on my localhost, My Drupal Account as my guide, and a whole lot to learn "A" what would "B" have me doing?

Thanks all for your time.