1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 Link in CODE tags

Discussion in 'XenForo Questions and Support' started by Neso, Dec 6, 2013.

  1. Neso

    Neso Member

    Hi, how to allow linking in CODE tags, what xenforo file to change to allow this ...

    I think it is necessary to change her files, because I have done this one time before but I am unable to find now how and what was necessary to change.
    library/XenForo/BbCode/Formatter/BbCode

    If you somebody can point me what file is striping all tags from CODE tag.
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    You can allow links in code tag using the =rich option:
    Unless I'm missing what you are trying todo.
     
  3. Neso

    Neso Member

    Yes, this is what I wish, how do you enable this ?
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    [CODE=rich][/code]
     
  5. Neso

    Neso Member

    Tnx for this, but problem is also that I have meany posts with old
    Code:
    
    
    tags, and wish to allow links in them also.

    Can you tell me what file control tags premissions
     
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    There are no tag permissions in XenForo. You'll need to edit them if you wish to render links in old posts.
     
  7. Neso

    Neso Member

    I know that there is in xenForo but I have asked in core files. I do know that this is not recommended method but for now it will do. I just can not find in what files are related to code tags permissions and showing.
     
  8. cclaerhout

    cclaerhout Well-Known Member

    http://xenforo.com/community/resources/post-content-find-replace.1549/
    To check if correct:
    Search:
    Code:
    #(\[code)(\].*?\[/code\])#su
    Replace:
    Code:
    $1=rich$2
     
  9. Neso

    Neso Member

    Tnx for this, but problem is that I have over 1 000 000+ posts and I think at least 500 000+ have this CODE tags and most likely it would cause server problems.
     
  10. cclaerhout

    cclaerhout Well-Known Member

    Then modify the function "parseValidateTagCode" of this class "XenForo_BbCode_Formatter_Base". Test if returning true in any case fixes your problem.
     
  11. Neso

    Neso Member

    I managed to allow links in new posts but for old post it still not parse links, this is what I have done;

    In file: library/XenForo/BbCode/Formatter/BbCode/AutoLink.php I removed "code" from

    PHP:
     protected $_disableAutoLink = array('url''email''img''php''html''plain''media');
    and in /home/serbi826/public_html/library/XenForo/BbCode/Formatter/Base.php I removed:

    PHP:
    'parseCallback' => array($this'parseValidateTagCode'), 
    and this allowed posting links, and it show them OK, but for old links in CODE they are still not linked, I did try diffrent combination but it look like I am missing some function
     
  12. cclaerhout

    cclaerhout Well-Known Member

    The autolinking might be done when the post is saved or edited. So it's not done during the parsing, which explains why any methods might not work for what you attend to do.
     
  13. cclaerhout

    cclaerhout Well-Known Member

    @Neso
    May be not the best way, but you can try to add this code:
    PHP:
     $content XenForo_Helper_String::autoLinkPlainText($content);
    After:
    PHP:
    $content $this->renderSubTree($tag['children'], $rendererStates);
    In the renderTagCode function.
     
  14. Neso

    Neso Member

    This cause some problems with link parsing, but for now I have postponed this, it is important to me to work with new links ...

    There is one more problem with this, if you add some text (link title) inside CODE and use URL tag to link it it will just show link title in CODE but link will be lost ... can you maybe point me what function is related to this,
     

Share This Page