Results 1 to 10 of 10

Thread: Storing HTML code in Knowledge Base

  1. #1
    dsmithies is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    19

    Default Storing HTML code in Knowledge Base

    We want to use the knowledge base to store small pieces of HTML code, but whenever we try this the code does not display properly. It seems that any HTML we include is interpreted as the page is displayed in Detail View, instead of being simply displayed as text.

    Is there any way to display HTML plainly in the detail view of a Knowledge Base article? We are aware that we could attach the code in a separate text file, but to us this adds an unnecessary step.

    I appreciate your advice,
    Daniel Smithies

    Epoch Labs (Australia)
    daniel@epochlabs.com.au

    Ubuntu 8.04
    SugarCRM PRO 5.0.0d
    Apache 2.2.4
    PHP 5.2.3
    MySQL 5.0.45

  2. #2
    heta's Avatar
    heta is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Ahmedabad,India
    Posts
    214

    Lightbulb Re: Storing HTML code in Knowledge Base

    hi dsmithies,

    i would like to know 1 thing..

    like if u have written <b>dsmithies</b>

    then u want "<b>dsmithies</b>" this thing displayed in detailview same as u have written right?
    Best Regards
    ---------------------------------------
    Heta Shah - iNET PROCESS
    heta.shah@inetprocess.com
    http://www.inetprocess.co.in
    Projects :
    iNETDocs -Project of the month(Dec-2008)
    iNETGoogleMap

  3. #3
    dsmithies is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    19

    Default Re: Storing HTML code in Knowledge Base

    Hi Heta,

    Yes thats right. Instead of a line of bold text, I would like to see the code as I wrote it.

    Do you know how i could do this?

    Thanks for your help,
    Daniel Smithies

    Epoch Labs (Australia)
    daniel@epochlabs.com.au

    Ubuntu 8.04
    SugarCRM PRO 5.0.0d
    Apache 2.2.4
    PHP 5.2.3
    MySQL 5.0.45

  4. #4
    heta's Avatar
    heta is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Ahmedabad,India
    Posts
    214

    Smile Re: Storing HTML code in Knowledge Base

    hi dsmithies,

    try this,

    open page: modules/KBDocuments/DetailView.php

    search for "from_html"

    and remove this function for $article_body.

    and see the change..

    i hope this works..
    Best Regards
    ---------------------------------------
    Heta Shah - iNET PROCESS
    heta.shah@inetprocess.com
    http://www.inetprocess.co.in
    Projects :
    iNETDocs -Project of the month(Dec-2008)
    iNETGoogleMap

  5. #5
    dsmithies is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    19

    Default Re: Storing HTML code in Knowledge Base

    Hi Heta,

    Thanks alot for your suggestion. We made the change you suggested, and it did work, in a way.

    The following:

    Testing storage of html

    <b>This should not be bold</b>


    Was displayed as:

    <p>Testing storage of html</p><p> </p><p> </p><p><b> This should not be bold</b></p><p> </p>

    So it did work. The html code -was- displayed correctly, but the 'plain text' and paragraph breaks were displayed as well. Ideally we would like to retain formatting and layout of plain text, as well as the code being displayed as it is written. We generally want to use this to make notes for ourselves on snippets of code.

    Is there a way to make the page display exactly as it is written?

    Thanks again,
    Daniel Smithies

    Epoch Labs (Australia)
    daniel@epochlabs.com.au

    Ubuntu 8.04
    SugarCRM PRO 5.0.0d
    Apache 2.2.4
    PHP 5.2.3
    MySQL 5.0.45

  6. #6
    datasponge is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    San Jose, CA, USA
    Posts
    553

    Default Re: Storing HTML code in Knowledge Base

    You can always surround the full page with <PRE></PRE>

    I don't know how you're referencing the text in the first place, but you may be able to put these tags in the php where you reference the variable and that forces everything enclosed to be shown exactly as it was "PREFORMATTED".

    Phil

  7. #7
    dsmithies is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    19

    Default Re: Storing HTML code in Knowledge Base

    Thanks for the suggestion Phil.

    I tried to surround the entire knowledge base article text with <PRE></PRE> tags, but it didn't work either with unmodified Sugar or after Heta's suggested modification.

    I just want to make sure I am explaining myself properly. Below is an example of what i want to be able to display in a knowledge base article:


    This is how you display bold text:

    <b>This text is bold</b>

    This is how you display text in Italics:

    <i>This text is in Italics</i>

    etc etc
    We want to store small text explanations of a function etc that accompany the code.

    Thanks alot for your help,
    Daniel Smithies

    Epoch Labs (Australia)
    daniel@epochlabs.com.au

    Ubuntu 8.04
    SugarCRM PRO 5.0.0d
    Apache 2.2.4
    PHP 5.2.3
    MySQL 5.0.45

  8. #8
    datasponge is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    San Jose, CA, USA
    Posts
    553

    Default Re: Storing HTML code in Knowledge Base

    Oops!

    <pre> doesn't handlie this. Instead, in php you can try:

    <pre>
    <?
    print htmlspecialchars($code);
    ?>
    </pre>

    Obviously, replace $code with the variable you're using for your knowledge base pages.

    There's also the <xmp> tag, whiich works perfectly in browsers that support it, but it's deprecated, so you can't count on it.

    Phil

  9. #9
    dsmithies is offline Sugar Community Member
    Join Date
    Mar 2008
    Posts
    19

    Default Re: Storing HTML code in Knowledge Base

    Thanks again for the help Phil,

    I substituted <b>BOLD</b> for $code in your suggestion, and the following was displayed:


    print htmlspecialchars(BOLD);
    ?>
    I do appreciate your help with this, but it looks like i cant have the best of both worlds here, I'm going to keep trying any other ideas i come across, and ill post here again if i have any luck.

    Thanks again everyone for their help,
    Daniel Smithies

    Epoch Labs (Australia)
    daniel@epochlabs.com.au

    Ubuntu 8.04
    SugarCRM PRO 5.0.0d
    Apache 2.2.4
    PHP 5.2.3
    MySQL 5.0.45

  10. #10
    heta's Avatar
    heta is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Ahmedabad,India
    Posts
    214

    Default Re: Storing HTML code in Knowledge Base

    hi dsmithies,

    if you want the result exactly u have described here,

    i can give u suggestion but that is quite tuff & i dont think you will go for that

    even though i am providing the suggestion,

    you need to create your doc something like this if you want to give description like this,

    <b>This text is bold</b>

    write like this:::

    &lt; b &gt; This text is bold &lt; /b &gt;

    and add htmlspecialchars_decode function in detailview.php

    ("KBDOC_BODY",htmlspecialchars_decode(from_html($a rticle_body)));

    the output will be
    < b >This text is bold< / b >

    which is not right.

    but if you remove the spaces before "b" , the line does not remain editable.



    after all research... no result...

    if u find the solution let me know..
    Best Regards
    ---------------------------------------
    Heta Shah - iNET PROCESS
    heta.shah@inetprocess.com
    http://www.inetprocess.co.in
    Projects :
    iNETDocs -Project of the month(Dec-2008)
    iNETGoogleMap

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 2010-08-13, 06:44 AM
  2. Run multiple installs from single code base - can it be done?
    By gunner1095 in forum Installation and Upgrade Help
    Replies: 5
    Last Post: 2008-03-10, 04:38 PM
  3. Knowledge base
    By vesty in forum General Discussion
    Replies: 1
    Last Post: 2007-03-20, 02:54 PM
  4. where is the html code that creates the pages in sugarcrm
    By santosh.ghalsasi in forum General Discussion
    Replies: 2
    Last Post: 2007-03-03, 07:20 AM
  5. Support and Knowledge Base Question
    By bill75080 in forum General Discussion
    Replies: 1
    Last Post: 2005-09-15, 10:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •