Unlike CCK fields, the node body field built doesn't have a wrapper div.

Please consider adding a wrapper

to ease template styling.

Thanks.

PS: I am attaching a module that does just this.

Comments

vm’s picture

a new feature would go toward 7.x and have to be backported to previous versions when wanting to make a change to core. That said, a patch should be supplied.

If the intent here is a contrib module, consider adding it to CVS to be distributed through drupal.org as it will get lost in the issue queue in a short period of time.

Gabriel R.’s picture

Hi VeryMisunderstood,

What you're saying is surely the right thing to do, but my previous experience with Dupal CVS was quite bad. My request for an account is still unanswered, 2 or years later. Traumatizing.

I am sure Google will take care of making the module pop up once in a while for those who need it.

AntiNSA’s picture

Please tell me how I can wrap a image used with the image field with the body text in drupal 6.6 ... its ver hard.

vm’s picture

css should be used to wrap text around an image. You will get better support on such a question in the forums. I've seen a few threads over the past few months with this question answered.

a google search reveals http://www.google.com/search?hl=en&q=W3C+using+css+to+wrap+text+around+a...

a drupal search reveals = http://drupal.org/search/node/text+wrapping

AntiNSA’s picture

Ive read 50 pages with the following search terms : inline, wrap, text, body, image assist, image field... I never tried wrapping...

But I understand how to do it with basic html and css. I cant find a specific example or guid to help me get my body text to wrap around the images. I have tried three ways...

Image attach, created an image field, and the one that adds a text link which says add image.

The one which adds a text link which says add image is cool, it wraps the body and enters the span code into the window for you (thinking about trying a wysiwyg next),,, The only problem with it is that it has problems with thickbox from what I can see, and when you publish to the front page it doesnot create small thumbnails.

The image field is great created with views, works with thickbox, however I cant get it to be wrapped by body, I can only get the image on top or on the bottom.

I cant get it to wrap with the teaser when published to the front.

The Same with the image attachment....

I could wrap any html if I just had the cold in front of me and the style sheet. It is so hard for me to understand where the correct code to css is and where is the reference style sheet....

Every fix I have tried I have either been unbale to locate the css in my version of drupal, or someone just writes the css to use but does tell me how to label it or where to exactly look for the label. I have been searching for hours. day and night.

christefano’s picture

Version: 5.x-dev » 7.x-dev

Ideally this would be in the node_prepare function in Drupal 7.x. If you can roll a patch, Gabriel Radic, please do provide one here. It will probably help you get a CVS account that much sooner.

Gabriel R.’s picture

Sorry, I'm still on Drupal 5.x here, and don't plant to upgrade my sites anytime soon. Also, I'm not very gifted with diff/patch/merge.

joachim’s picture

+1

But what CSS class to use?

joachim’s picture

StatusFileSize
new954 bytes

Apologies for a double post, just attached a patch and no sign of it :(

In antipation of bikeshed about the class name... ;)

joachim’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch failed testing.

Gabriel R.’s picture

class="node-body"

As clear as possible. Anything more is too much. Anything less risks confusion and confliscts with the node itself or the html body.

joachim’s picture

Status: Needs work » Needs review

I don't understand the bot's message -- I have just applied this patch to a fresh D7 CVS checkout and it works fine.

The last submitted patch failed testing.

joachim’s picture

Status: Needs review » Closed (duplicate)

This is obsolete on D7 as node body is a field, and hence gets a wrapping DIV with 'field-name-body' among others.

Gabriel R.’s picture

Status: Closed (duplicate) » Fixed

Cool, at last!

AntiNSA’s picture

Status: Fixed » Needs work

ANyone have a working patch? this is for 6.x? If the patch failed why is this marked as fixed?

Scott J’s picture

AntiNSA,
I think that they are saying that D6 cannot be updated until after D7 is released. You can easily do it yourself by editing modules/node/node.module and changing the two lines marked with + signs in wrap_node_body.patch at #9 above.

Or install the bodywrapper module above.
See also http://capellic.com/blog/theming-the-node-body-field

joachim’s picture

Status: Needs work » Closed (duplicate)

New features aren't being added to D6, only bugfixes -- resetting the status of this.

It's not a good idea at all to hack core as #18 suggests; but you can implement these changes in a custom module.

stefan81’s picture

hi, can this be done with a theme override as well?

stefan81’s picture

Hi, thanks for your efforts.

I used it for drupal 6.x this way:

  if ($teaser == FALSE) {
	$node->body = '<div class="node-body">' . check_markup($node->body, $node->format, FALSE) . '</div>';
  }
  else {
	$node->teaser = '<div class="node-body">' . check_markup($node->teaser, $node->format, FALSE) . '</div>';
  }

it works :)

do you know how this could be done as a theme override or at template.php?

davidwhthomas’s picture

StatusFileSize
new6.63 KB

I needed this body wrapper div functionality and found the small bodywrapper module was a reasonable solution.
Attached is a version for D6.
cheers,
DT

AntiNSA’s picture

I tried to install your module and it still s eems to fail to wrap such things as image enclosures and preview size video enclosures and such.. basically the teaser is failing to wrap...

davidwhthomas’s picture

It's designed to only wrap the node body field in a div, nothing more.
You might be able to wrap the teaser by adding:

	$node->content['teaser']['#value'] = '<div class="node-teaser-wrapper">'.$node->content['teaser']['#value'].'</div>';
AntiNSA’s picture

Where should I add this code too? Thanks!

davidwhthomas’s picture

Add it directly below the similar line in the module attached above.
DT

porg’s picture

@ Gabriel Radic: Thanks! Your module perfectly solved my support inquiry: $content holds node body as HTML elements in loose sequence not wrapped within DIV container (to easily separate ImageField DIV)

@ Gabriel Radic or other people with experience in module contribution: Could you publish this module into the official contributed section at http://drupal.org/project/* preferential under the already chosen name "bodywrapper"?

This would improve the situation for people who:
a) Search for a problem solution within the Drupal module section, and not through external search engines.
b) Me/others could easily/reliably post a Drupal internal link to related issues.
c) People which install through automated means such as Plugin Manager.

I already noted down about 5 related issues, and as soon as http://drupal.org/project/bodywrapper would become available, I would love to post into these threads (including my own support inquiry) to help the subscribed people and future troubleshooters.

Gabriel R.’s picture

I did try more than once to get CVS acces but my request was turned down by the code masters. Sorry.

porg’s picture

@ Gabriel Radic : Your user profile shows "I contributed Drupal modules" plus you have such an early Drupal member number, 3951! Hence I thought "This guy surely knows how to contribute modules, and can do it". So, as you do not have CVS access, what can we do, that your great "BodyWrapper" makes it into the contributed modules?

@ Anybody : Any other experienced person here to help out?

joachim’s picture

> I did try more than once to get CVS acces but my request was turned down by the code masters. Sorry.

Did you try with this module? If you want to submit or reopen your application and submit this module, I can review it.

Gabriel R.’s picture

Request mail sent.

joachim’s picture

You'll need to point me at the link to your application -- I'm just another peer reviewer, not an admin.

porg’s picture

Gabriel and Joachim: Nice to read about the progress! Thanks for your efforts!

Gabriel R.’s picture

It was an email request.

joachim’s picture

Yup. It will then create an issue on d.org for anyone to review.

akamaus’s picture

StatusFileSize
new6.19 KB

Original bodywrapper module didn't work for me because of syntax errors. I fixed them, deleted .svn directory and some junk files and attached the result. Tested on Drupal-6.20.

stolzenhain’s picture

I found a similar module to this here:
Body wrap filter