Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I strip HTML formatting in PL SQL block

752596Mar 25 2010 — edited Apr 9 2010
Hi all,

I don't know if anyone remembers when I was getting help for posting news previews: http://forums.oracle.com/forums/profile.jspa?editMode=true&userID=749593

I have a set of news posts and I've been just tried to use the HTML editor to create them. See a screenshot here: http://easycaptures.com/fs/uploaded/284/2295048167.jpg

With the HTML editor, it inserted a few HTML tags that preserve the formatting. http://easycaptures.com/fs/uploaded/284/2637106008.jpg That's the table with the data created by the HTML editor.

This is all fine and good, and exactly what I want. However when I try to preview the news posts on the administrator's front page, the link to view the entire post is broken.

http://easycaptures.com/fs/uploaded/284/2824513250.jpg

I found out it's because the same HTML tags generated by the HTML editor interfere with the reference tag in the PL/SQL block that creates the news posts.


Here is the PL/SQL block that I used (thanks Jari)
DECLARE
  l_count     INTEGER;
  l_cut_post  INTEGER;
BEGIN
  l_count := 0;
  l_cut_post := 75; -- Show only 50 first letters from post
  
  HTP.p ('<table class="news smallpost">');
  HTP.p ('<tr><td><img src="#WORKSPACE_IMAGES#005.png"/> <b>News Feed</b><br><br><hr></td></tr>');
  FOR c IN
  ( SELECT newscontent,timeposted, postid FROM "NEWSPOSTS"
  )
  LOOP
 
    IF MOD(l_count,2) = 0 THEN
      HTP.p('<tr class="post1">');
    ELSE
      HTP.p('<tr class="post2">');
    END IF;
 
    HTP.p('<td><h2>'|| TO_CHAR(c.timeposted, 'DD.MM.YYYY - HH12:MI:SS AM') ||'</h2>');
 
    IF LENGTH(c.newscontent ) > l_cut_post THEN
      HTP.p('<p>' || SUBSTR(c.newscontent, 1, l_cut_post) || ' ...</p>');
      HTP.p('<a href="f?p=&APP_ID.:7:&APP_SESSION.::NO::P7_POSTID:' || c.postid || '">Read entire post</a>');
    ELSE
      HTP.p('<p>' || c.newscontent || '</p>');
    END IF;
      
    HTP.p('</td></tr>');
    l_count := l_count + 1;
  END LOOP;
  HTP.p ('</table>');
END;
How do I stop the HTML tags in the preview from interfering with the link that says "See entire post"??
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 7 2010
Added on Mar 25 2010
2 comments
1,955 views