ElkArte Community

Project Support => Support => Topic started by: ahrasis on December 20, 2014, 06:10:25 am

Title: integrate_basic_url_replacement
Post by: ahrasis on December 20, 2014, 06:10:25 am
I find this inside Subs.php and I think this could be a useful hook for my subforum case. Can I have some samples on how to use this effectively?
Title: Re: integrate_basic_url_replacement
Post by: IchBin on December 25, 2014, 07:55:52 pm
From what I can tell, all you have to do is to add your string that you want to search for in the $find array. Then add your corresponding string that you want to replace it with in the $replace array.

Something basic like this. Been a long time since I wrote PHP so I'm not sure if the array merge will work exactly as I'm thinking. But this is the basic idea. array_push() might be better than array_merge. I'll leave that up to the professionals here to correct me. lol
[php]
function addCustomReplaceUrl(&$find, &$replace) {
    array_merge(array('{custom_name}), $find);
    array_merge(array($scripturl . '?action=customurl'), $replace);
}[/php]

Assuming you have the hook set to call your method, this should add your custom find/replace to the integration hook.
Title: Re: integrate_basic_url_replacement
Post by: ahrasis on December 28, 2014, 01:31:13 am
Thank you @IchBin. I will play with this integration more. Basically, I wish to change $boardurl from what is defined in Settings.php to this $boardurl = $parts['scheme'] .'://'. $_SERVER['SERVER_NAME'] .(!empty($parts['port']) ? ':'. $parts['port'] : '') . (!empty($parts['path']) ? $parts['path'] : ''); if subforums mod is set.
Title: Re: integrate_basic_url_replacement
Post by: emanuele on December 28, 2014, 06:27:59 am
This function is intended to replace strings with urls in text. I don't think it's of any help in what you are doing. ;)
Title: Re: integrate_basic_url_replacement
Post by: ahrasis on January 05, 2015, 09:52:14 am
I will have to find some other way to work the mod out. Thanks @emanuele.
Title: Re: integrate_basic_url_replacement
Post by: emanuele on January 05, 2015, 11:56:10 am
I should really have a look at the code... but as usual I'd need days with 48 hours. LOL