How to add a div to content section

johnlee80 - July 2, 2009 - 08:12

Hi, someone can point me in the right direction with adding a div to content.

My problem is, I want to just add a DIV to a post so that it splits into 2 sections.

For example:
By default, if I create content, such as a blog post, it has 1 DIV. So if I had an image and text, the text would flow over the image.

But I would like to have 2 DIVS, one for the image, the other for text. Like so..

---------------
| div 1 | div 2 |
---------------

I've tried looking for answers, but only came across this page http://www.kevinhankens.com/content/adding-containers-drupal-form-elements and didn't seem to help, I'm not at all familiar with PHP either.

I'm hoping that it's just a line or 2 of PHP code that I must enter either at page.tpl.php or node.tpl.php so that I can then use css to control the div.

Sincerely,
John

It seems that both image and

nirbhasa - July 2, 2009 - 09:44

It seems that both image and text will be entered from within the 'body' field in the edit form, yes? In this case, make sure your input filter is 'Full HTML' (or that 'Filtered HTML' includes div tags) and then put the div tags around both image and text.

However, if the image is to be entered from another field (for example using cck, or the image module), then these fields will have their own classes you can use for positioning, which can be identified using Firebug or looking at page source. This can be good if you want every blog post to have one image positioned in a particular way.

If you feel you need more control than that - your best bet (if your content type is called, blog, lets say) is to duplicate the node.tpl.php in your theme to node-blog.tpl.php: changes made here will apply to nodes of blog content type only. These files are a combination of HTML and bits of php to output the various bits of the site.

 
 

Drupal is a registered trademark of Dries Buytaert.