Simple Machines Community Forum

SMF Development => Feature Requests => Applied or Declined Requests => Topic started by: wintstar on November 07, 2021, 02:07:42 PM

Title: Hook for linktree v2.1
Post by: wintstar on November 07, 2021, 02:07:42 PM
Would it be possible with Relase 2.1 to add a hook for linktree in Sources/Load.php.

https://github.com/SimpleMachines/SMF2.1/blob/release-2.1/Sources/Load.php#L1230-L1242

This would be useful for mods like portal, article, blog, CMS.

The hook could be used to avoid changes for mods in the Load.php file.

<operation>
<search position="replace"><![CDATA[ // Start the linktree off empty..
$context['linktree'] = array();]]></search>
<add><![CDATA[ // Start the linktree off empty..not quite, have to insert forum
$context['linktree'] = array(array('url' => $scripturl . '?action=forum', 'name' => $txt['example_forum']));]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[ // Build up the linktree.
$context['linktree'] = array_merge(
$context['linktree'],
array(array(
'url' => $scripturl . '#c' . $board_info['cat']['id'],
'name' => $board_info['cat']['name']
)),]]></search>
<add><![CDATA[ // Build up the linktree (adding for example blog, cms, articles, portal forum index)
$context['linktree'] = array_merge(
$context['linktree'],
array(array(
'url' => $scripturl . '?action=forum#c' . $board_info['cat']['id'],
'name' => $board_info['cat']['name']
)),]]></add>
</operation>
Title: Re: Hook for linktree v2.1
Post by: Sesquipedalian on November 07, 2021, 03:28:35 PM
Since the linktree is just a $context variable, you can already access it using any integration hook at all. So if you want to change it in certain situations, choose a hook that is relevant to that situation. If you want to change it in every situation, choose a hook such as 'integrate_buffer' so that you can make your changes just before the template output begins.