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

Need to know code file where URL/Link parsing is done

Discussion in 'XenForo Development Discussions' started by gginni, Apr 22, 2013.

  1. gginni

    gginni Active Member


    My website is affiliate website so I want to convert all the URLs posted by user to affiliate urls.

    For eg... when user will post URL www.xenforo.com then while rendering I want to render it as


    Text in bold I want to add during rendering... I did the same in mybb by changing one function where URL parsing was done but for xenforo I'm not able to find the file name

    Or alternatively I can achieve the same using javascript on body load where I will get all the anchor tags and then append required url ... But instead of javascript solution I will prefer directly changing the file where URL parsing is done

    Please let me know the file name

  2. Jeremy

    Jeremy Well-Known Member


    You'll want to extend and overwrite renderTagUrl to accomplish adding to it. Best bet would be this:

    public function renderTagUrl(array $tag, array $rendererStates)
    $original parent::renderTagUrl($tag$rendererStates);
    SneakyDave likes this.
  3. gginni

    gginni Active Member

    Well I still need some time to learn the tutorial for creating listeners and all... I would love changing the xenforo direct file where this parsing is being done... where is this renderTagUrl function which I need to extend?? I will directly change in the file
  4. Jeremy

    Jeremy Well-Known Member

    XenForo_BbCode_Formatter_Base in library/XenForo/BbCode/Formatter/Base.php. The guide I linked you to (written by me) takes you through the steps to build this properly using listeners and such.
    gginni likes this.
  5. gginni

    gginni Active Member

    Great thanks for telling the file name bro :).. I have done the required changes by changing below line:-

    return '<a href="http://mydomain.com/links?' . htmlspecialchars($url) . '"' . $target . $class . $noFollow . '>' . $text . '</a>';
    And yeah bro I saw that tutorial is written by you but now see changing above line took me just 5 seconds :p... And creating listeners and all will take atleast half an hour of me as I'm newbie... will read the detailed tutorial on weekend and after that will start using the method which u guys use :)

    Thanks once again :)

    This question can be marked as resolved now :)
  6. Jeremy

    Jeremy Well-Known Member

    You can skip most of the tutorial (past creating the listener and the extending class) and past in the above function I gave you. Should be roughly ~10-15min.
    gginni likes this.
  7. gginni

    gginni Active Member

    I have already bookmarked the tutorial link shared by you and on coming weekend first thing to do will be creating one simple add-on :) :)

    I don't get much time for development.. Had to sought lot of things by users in the website... Actually I'm ASP.NET, C# developer and just learning PHP from past 1 year or u can say learning PHP from the day I started using mybb forum in my website... Mybb guys have not used any framework so PHP code written by them is straight forward and pretty simple but here in xenforo, time is required to understand the basic framework etc... Will surely start analyzing xenforo code and start creating add-ons on coming weekend :)

    Thanks once again :)

Share This Page