Skip to main content
Topic: integrate_basic_url_replacement (Read 2251 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

integrate_basic_url_replacement

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?

Re: integrate_basic_url_replacement

Reply #1

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.
Success is not the result of spontaneous combustion, you must set yourself on fire!

Re: integrate_basic_url_replacement

Reply #2

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.

Re: integrate_basic_url_replacement

Reply #3

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. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: integrate_basic_url_replacement

Reply #4

I will have to find some other way to work the mod out. Thanks @emanuele.

Re: integrate_basic_url_replacement

Reply #5

I should really have a look at the code... but as usual I'd need days with 48 hours. LOL
Bugs creator.
Features destroyer.
Template killer.