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

gginni

Active member
Hi,

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

http://mydomain.com/links?www.xenforo.com

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

Thanks
 
http://xenforo.com/community/thread...b-code-in-xenforo-a-comprehensive-guide.6320/

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

PHP:
public function renderTagUrl(array $tag, array $rendererStates)
{
  $original = parent::renderTagUrl($tag, $rendererStates);
 
  return str_replace('href="', 'href="http://mydomain.com/links?', $original);
}


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
 
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
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.
 
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.

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

Code:
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 :)
 
Great thanks for telling the file name bro :).. I have done the required changes by changing below line:-

Code:
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 :)
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.
 
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.

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 :)
 
Top Bottom