1

I have a content type with body tag. I want to add content which has a repeating HTML mark-up.

Example:

<div class = "some-class">
<p>Main Content 1</p>
</div>
<div class = "some-class">
<p>Main Content 2</p>
</div>

This pattern repeats itself except for the text within the <p> tag. Right now I'm typing tons of repeating HTML code into the body of the content type. It would be helpful if I could just focus on the main content and not on the repeating mark-up which could save lots of time.

  1. Is there a way to surround fields with custom HTML tags, so that I can focus on the main content and not on the HTML mark-up?
  2. Is there a module that I can use to do the same?
6

There are a number of ways you can handle this. The three best that come to mind are:

  1. Use a theme hook template file to modify the output. You can do this at either the field level or the content type level.
  2. Use Display Suite to create a field template.
  3. Create a custom field formatter with Custom Formatters module. This plays nicely with display suite.

In your case Display Suite is probably overkill unless you wanted to use it for managing all your output. It’s an extremely powerful module that if implemented correctly allows you to not have to manipulate template files.

In either case I would suggest taking a good look at Display Suite as it really speeds up the theming process.

1

One way is using Display Suite.

You have to enable Display Suite Extras module coming with Display Suite, then you have to enable field wrappers in the DS Extra settings (admin/structure/ds/list/extras). After that you can go to "Manage display" of a content type and select "Expert" for a field.

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.