I've already tried adding the {motd} and {petition} into an addnav inside village.php and it didn't work. What is PHP doing to the link that I can't replicate? Is there a part of the core code that forces the link to be called inside the addnav structure for security reasons?
This really depends on if you are going to have the {motd}, {mail}, etc as a header, or a navigation item. It seems like you are trying to make these pieces as a navigation item, instead of a header so I will answer accordingly. The navigation system automatically searches through any navigation added and attempts to assign a hotkey to it. Example:
addnav('{motd}', false, false, true); may turn out to have the navigation link of "
<em>{</em>motd}". In
lib/pageparts.php, page_footer will try to replace {motd} it does not exist, except for in the template's definition. Instead, you want to force
private_addnav() (it's what addnav() is passed through) to not mess with the link name ({motd}, {mail} or {petition} in this example) - which can be done with
addnav('{motd}', '!!!addraw!!!');.
However, it seems as if you want the
original definition of these template parts removed. This means you have to first remove it from the template itself and then add it after, so duplication does not occur. I would do this through a module - hook into
everyfooter. An example of what the 'dohook' function should look like is below. (I saw no mention of {petitioncount} however. That is in the
$footer global more than likely). Note that this example should work, I see no reason as to why it will not since the replacement comes
almost immediately after the
everyfooter hook.
<?php
function moduleName_dohook(string $hook, array $args): array
{
global $header;
$templateParts = ['{motd}', '{mail}', '{petition}'];
// Remove the original so that lib/pageparts.php doesn't
// leave the originals outside of the navigation stack.
str_replace($templateParts, '', $header);
// Move them inside of the navigation stack.
addnav('Other Info');
foreach ($templateParts as $key) {
addnav($key, '!!!addraw!!!');
}
return $args;
}