XF 2.2 How to Edit Browser Tab Title Formatting

VisEntities

Active member
I'm looking for help on how to edit the way titles are formatted in the browser tab for my forum. For example, I don't want the site name to appear last, and I'd prefer to use - instead of |

I've tried searching the web but haven't found any useful answers. Any guidance or tips on how to achieve this would be greatly appreciated!

aaaaaaaaa.webp
 
Solution
You can edit the PAGE_CONTAINER template. I think replacing the existing line with the <title> tag with this would do what you want:

HTML:
<title><xf:title formatter="%s" fallback="{$xf.options.boardTitle}" page="{$pageNumber}" /></title>

Then you can edit the title_page_x phrase to swap the | for an -.
You can edit the PAGE_CONTAINER template. I think replacing the existing line with the <title> tag with this would do what you want:

HTML:
<title><xf:title formatter="%s" fallback="{$xf.options.boardTitle}" page="{$pageNumber}" /></title>

Then you can edit the title_page_x phrase to swap the | for an -.
 
Solution
So this's what I ended up doing
HTML:
    <title><xf:title formatter="{$xf.options.boardTitle} - %s" fallback="{$xf.options.boardTitle}" page="{$pageNumber}" /></title>

That made it: xenForo - Resources, so far it's perfect (btw editing title_page_x didn't do any effect)

But now I have a follow up question, how to make it so if the page title had more than 2 words, I make each word in the page title capitalized, this below been suggested but I don't know how right is it or if it's a good idea to do like this to begin with
HTML:
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            var titleElement = document.querySelector('title');
            var parts = titleElement.textContent.split(' - ');
            if (parts.length === 2) {
                parts[1] = parts[1].replace(/\b\w/g, function(char) {
                    return char.toUpperCase();
                });
                titleElement.textContent = parts.join(' - ');
            }
        });
    </script>

Also by resource page names, it displays the prefix name first, which I'd like to exclude and only display the resource name
Appreciate the help!
 
Last edited:
and by the way (editing title_page_x didn't do any effect)
It does for pages (ie. page 2+ of a long thread).

how to make it so if the the page title had more than 2 words, I make each word in the page title capitalized
You can place this line before the <title> one:
HTML:
<xf:page option="pageTitle" value="{{ page_title()|to_upper('ucwords') }}" />
 
Back
Top Bottom