0

In my page (basic page content type) I have the following code in the body field

<h3 class="blue-txt">Heading</h3>

In my custom themes page.tpl.php I have

<?php print render($page['content']); ?>

However the rendered content replaces the h3 with a p and stripes my class for some reason and I need it to render the code that I saved.

<p>header</p>

However, if I use the following then it will print correctly:

<?php print field_get_items('node', $node, 'body')[0]['value']; ?>

If I use that then when I navigate to any of the default pages, mainly the admin login I get an error as $node is not defined. I added a conditional to check that $node was defined to prevent the error. After that the error wasn't displayed but since $node was supposed to contain the content, no content is displayed.

What am I doing wrong here? I just need my page to print out the body without deciding it should edit my code for me and I don't understand why $page['content'] is butchering my code.

  • After looking at the array values for $page['content'] it looks like what is being displayed is the safe_value instead of the value. How can I tell drupal to use the value instead? – Eric Farley Jan 7 '15 at 1:16
  • 1
    Ok, as you are using the body field I am assuming you are using a WYSIWYG, which one? The WYSIWYG module? You should not have to tinker with the tpl to get h3s to display. What are your allowed tags in Configuration > Content Authoring > WYSIWYG Profiles > Your_Profile? – sareed Jan 7 '15 at 1:41
  • I am using CKEditor for my wysiwyg. – Eric Farley Jan 7 '15 at 16:17
  • I don't think ckeditor is the issue. In the editor my tags are being displayed correctly, I've already allowed the necessary tags in ckeditors filters. I just need to figure out how to render the value instead of the safe value – Eric Farley Jan 7 '15 at 16:38
1

Try going to admin/config/content/formats/html where 'html' is your WYSIWYG profile and check your filter processing order.

Mine:

Insert view filter
Convert Media tags to markup
CKEditor Link Filter
Convert URLs into links
Correct faulty and chopped off HTML
Limit allowed HTML tags

If I put 'Limit allowed HTML tags' at the top I get similar issues to what you are describing.

EDIT: The order did not actually cause the issue for me. I had just forgotten to add <h3> to the allowed list.

0

Did you check the options under Structure > Content Types > Basic page > Manage Display > Body field (format column).

  • The manage display format for body is "Default" – Eric Farley Jan 6 '15 at 20:40

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.