0

I have been trying to research this issue for about a week now but not having much luck as some of the similar postings do not make too much sense to me. Either way, I appreciate any help and guidance on this!

I have a custom module that utilizes the CKeditor and submits HTML tags to the appropriate column in the database table. Example tags: <p></p><ul></ul><li></li>

I am using the views module to display results but instead of the HTML tags rendering, I am seeing: <p>This is a test:</p> <ul> <li>test 1</li> <li>test 2</li> <li>test 3</li> </ul>

When I inspect the browser I actually see:

&lt;p&gt;This is a test:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;test 1&lt;/li&gt;
    &lt;li&gt;test 2&lt;/li&gt;
    &lt;li&gt;test 3&lt;/li&gt;
&lt;/ul&gt;

What I want to see is:

This is a test:

  • test 1
  • test 2
  • test 3

0
0

Figured out a workaround.

With having the views_php module https://www.drupal.org/project/views_php , I went into the view I was working on and clicked "add" in the fields section.

I chose Global: PHP and the field that would be pulling my database (descr in this case).

For the field that would be pulling from my database (descr), I chose to "Exclude from Display" and in the Global:PHP field, I choose the available variable (which was $row->descr).

There are probably better ways to do this but after spending close to a week, this works for me.

2
  • See my answer. This functionality is already built in without having to use a Global PHP field, which should be avoided unless absolutely necessary.
    – Christia
    Oct 26 '17 at 22:30
  • Christia - I appreciate your feedback! I tried your below suggestion prior to posting to this board as I saw it in other how-to and forum postings but that didn’t seem to work. Just wondering, why should the Global PHP option be avoided? Thanks again for taking the time to post back and help me out!
    – Keith
    Oct 27 '17 at 23:19
0

You should define the HTML tags in the view using the style options for the field settings otherwise it will treat your tags like text, which is why you are seeing the text translations of those tags.

In this example, I wanted the field "category" to be formatted as a div with a certain class. See screenshot below: enter image description here

I am not sure what you mean but "appropriate column in the database" table. When using views, you don't really need to worry about how Drupal is writing to the database columns.

Notice that my format is "Unformatted List". You would want to change yours to HTML List: enter image description here

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.