5

I'm working on converting an existing website to Drupal, and I'm looking for best practices for creating specialized styling on specific nodes. I have a page that looks like this (baconized for your viewing pleasure):

Special Styling with blockquotes and right-aligned image

Can someone advise me as to the best way to accomplish styling a node this way - specifically in a way where the content can be managed by the client?

I've had a few different ideas as to how to accomplish it, but I'm not sure which is best.

Write raw HTML as the content and add CSS in the template? - The downside with this is that I'd prefer my client not have to mess with raw HTML when managing the content, if at all possible.

Create a custom content type that has fields for each snippet which I can style within the theme? - This seems like a reasonable course of action, except that I'll be creating a one-off content type for a single node, and that seems less than optimal.

Do something with Views? - Views is always an option, but I don't know if it's the right one here. Would I create a separate node for the intro snippet, the 3 blockquotes, and the rest of the page, or something else? I'm not sure.

Do something with Panels? - I'm still figuring out how to use Panels, and it seems like a possibility here, but an overly complicated one. Additionally, how will the client manage it?

Any insight or advice here would be immensely helpful. Thank you!

1

If it is a page with unique structure and no other pages will have same structure, I usually do this by creating an empty page (not a node, just a page - an item in drupal menu system).

You can create a page in your module like so:

function YOUR_MODULE_menu() {
    $items = array();
    $items['your-page-url'] = array(
        'type' => MENU_NORMAL_ITEM,
        'title' => t('Page title'),
        'page callback' => 'your_callback_function_name',
        'access callback' => TRUE
    );
    return $items;
}

function your_callback_function_name() {
    return '';
}

the code above will provide an empty page. If you need custom page structure for this page you can always declare a template specifically for this page just put:

page--your-page-url.tpl.php

to your theme template folder.

Then you can create blocks for each piece of content and assign them to proper regions. Your users will be able to edit content through blocks edit while all styling and layout tags will be built into template file.

4
  • So would you suggest creating custom block regions in the template for the one page, then? – mWillis May 13 '12 at 15:40
  • that's one of the possible solutions. You can create new regions for blocks within your existing theme. You can create a new theme with its own set of regions and assign this theme only to this page using themekey module. And of course you can not to create new regions and just make use of css to align blocks properly within your content region. In my opinion the last option suits this task best. – Alex Petrov May 13 '12 at 15:49
  • What is the appropriate way to include blocks into the theme without using custom regions? – mWillis May 13 '12 at 20:11
  • the point is that you use the very same regions that the ones in your main theme, but you can layout them differently in your custom page--your-page-url.tpl.php file. At the very least you can put all the blocks to the one region and render that region somewhere on the page. Besides that you can of course print any block with the following code: $block = module_invoke('module_name', 'block', 'view', 0); print $block['content']; – Alex Petrov May 13 '12 at 21:15
0

In most simple case you can use CKEditor module and some css in your theme for blockquote tag inside node content. Also you can define your custom element style for CKEditor that will wrap disred text into tag with class or inline style. This way allow you to avoid metting your user with raw HTML. Panels and Views or blocks is good approach for small amounts of pages with complicated structure(for example), but not always it is appropriate way.

0
0

You might consider whether Skinr meets your needs. The idea is that you can apply extra CSS selectively, and your client can, too.

0
0

I like using views to output content, but this could be done in lots of ways. One way could be to create your columns as taxonomies and then in a newly created content type, create an existing term reference to the taxonomy. Then create the other content from fields and then once all your content is in the node, style it accordingly with CSS. A second way could be to use a combo of blocks and views. In this solution your could create a view of taxonomy terms that displays them as list items in a block, so you could specify what URL's to route your block to. After you have the columns as views you could create the bottom content as a block and the top content as view with a field for the body and a field for the image (from a referenced content type). You can always move your elements around on your page with a bit of CSS. Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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