1

I have created text fields for first name and last name (which i need as separate fields so i can sort by last name when needed) but the default markup is so cumbersome! they each are nested in 3 divs, and all I want to do is display as a typical manner, ie. Firstname Lastname

How can I strip out the default markup for these 2 fields only? creating a field override template doesn't seem like a good idea, or is it?

2

Several ways to skin this cat. You can use a custom tpl.php as suggested, or, you can also explore some contrib modules such as display suite or fences.

|improve this answer|||||
1

Yes that's the best idea--that is exactly what template overrides are for. Figure out a tight override for it. Something like field--first-name.tpl.php. In there keep just the mark up you want. Probably something like:

<div class='firstname'><?php echo $variables['first-name']; ?></div>

https://api.drupal.org/api/drupal/modules!field!theme!field.tpl.php/7

|improve this answer|||||

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.