Forum

Thread tagged as: Problem, Field-Types

Disable wrapping P tags if there is only one paragraph or convert new lines to B...

Currently we have this HTML markup:

<h3 class="no-mobile">Admission Free, Open 7 days a week,<br>10am - 5pm. Closed 24 - 26 December</h3>

We don't want the users to be able to mess with the H3 (and it's class) so we turned it into

<h3 class="no-mobile"><?php perch_content('Admission heading'); ?></h3>

Trouble is what type of field to choose now. We need the field to be WYSIWYG (or at least linebreak-aware) and NOT wrapping content in P tags. I understand why text block does that, but is there a workaround?

Simon Jones

Simon Jones 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What's the purpose of the <br> ?

It's a narrow sidebar. And they need to have control over how are the words wrapped.

Drew McLellan

Drew McLellan 2638 points
Perch Support

How about using a pipe character?

Admission Free, Open 7 days a week | 10am - 5pm. Closed 24 - 26 December

and then:

<h3 class="no-mobile"><?php 
    echo str_replace('|', '<br>', perch_content('Admission heading', true)); 
?></h3>

Good enough. Thanks.