XF 2.2 Category or prefix next to the forum title

claudiucjc

New member
Hello, I'm trying to add the category next to the forum title like in the screenshot. It is possible something like that?
help-bread.webp

It doesn't matter the position of that text, probably will be at the beggining of the forum title (h1).
I would like to do that because I will have few forum with the same name but different category (and url) and I would like to make sure when someone will do a post they will see the right category.

Thank you.
 
Solution
Edit the PAGE_CONTAINER template from line 490.

Change this:
HTML:
<xf:if is="!$noH1">
    <h1 class="p-title-value">{$h1}</h1>
</xf:if>

To this:
HTML:
<xf:if is="!$noH1">
    <xf:set var="$firstBreadcrumb" value="{$breadcrumbs|last}" />
    <h1 class="p-title-value">{{ $firstBreadcrumb ? $template == 'forum_view' ? {$firstBreadcrumb|first}.' > ' : '' : '' }}{$h1}</h1>
</xf:if>

The result is this for a forum with a parent:

1614723283247.png

This for a forum with no parent:

1614723266118.png
Edit the PAGE_CONTAINER template from line 490.

Change this:
HTML:
<xf:if is="!$noH1">
    <h1 class="p-title-value">{$h1}</h1>
</xf:if>

To this:
HTML:
<xf:if is="!$noH1">
    <xf:set var="$firstBreadcrumb" value="{$breadcrumbs|last}" />
    <h1 class="p-title-value">{{ $firstBreadcrumb ? $template == 'forum_view' ? {$firstBreadcrumb|first}.' > ' : '' : '' }}{$h1}</h1>
</xf:if>

The result is this for a forum with a parent:

1614723283247.png

This for a forum with no parent:

1614723266118.png
 
Solution
@Brogan thank you very much for help (where I'm sending the beer)?

I have few more sub-questions:
1. I would like to have the forum title and after breadcrumb (because some of my titles are very long name of universities)
2. Can I do it as a metatitle as well? Because at the moment the metatitle is not changed with forum title - breadcrumb?
 
Yes, you can edit the code I posed to change how it is displayed.
This will place the category after the title - you may want to use a different separator in this case, such as |.

HTML:
<h1 class="p-title-value">{$h1}{{ $firstBreadcrumb ? $template == 'forum_view' ? ' | '.{$firstBreadcrumb|first} : '' : '' }}</h1>

To change the meta data you would need to edit the same template in the head section at the top but I would advise against it as the correct meta title is already being served.
 
@Brogan I don't know exactly where I have to change and what I have to add:
I think I have to change the code between title:
HTML:
<title><xf:title formatter="%s - %s" fallback="{$xf.options.boardTitle}" page="{$pageNumber}" /></title>
But I don't know which part from code to add there, because I don't think I can add a h1 tag in header title tag.

And another think if you are able and want to help me:
Title | breadcrumb I would like to use just for one category name the rest categories can stay normal. But this category it will have different universities with same faculties and here people in that forum can be confused if they don't see the category and in google I will have the same title.
 
I'm thinking to do something like this, but the problem is I don't know the xenforo syntax and I don't know how to check if the category name is == to.

Because the @Brogan code is working exactly how I want but I want this code to working in just on category of my forum and the other categories to be normal with the default: <h1 class="p-title-value">{$h1}</h1>

Any ideas how I can make this code working or if it is possible something like this?

HTML:
<xf:if is="!$noH1" AND  category_name == "Universități">
<xf:set var="$firstBreadcrumb" value="{$breadcrumbs|last}" />
<h1 class="p-title-value">{{ $firstBreadcrumb ? $template == 'forum_view' ? {$firstBreadcrumb|first}.' > ' : '' : '' }}{$h1}</h1>

<xf:else />

<h1 class="p-title-value">{$h1}</h1>

</xf:if>
 
What you are asking for now is completely different to what was requested originally and fundamentally changes the code.

If you just want to apply the change to one category it's easier to just use:

HTML:
<xf:if is="!$noH1">
    <xf:if is="$containerKey == 'node-2'">
        <xf:set var="$firstBreadcrumb" value="{$breadcrumbs|last}" />
        <h1 class="p-title-value">{$h1}{{ ' | '.$firstBreadcrumb|first }}</h1>
    <xf:else />
        <h1 class="p-title-value">{$h1}</h1>
    </xf:if>
</xf:if>

Change node-2 to match the node you wish to have the breadcrumb displayed on.
 
What you are asking for now is completely different to what was requested originally and fundamentally changes the code.
@Brogan I know and I'm really sorry for that.

The title with breadcrumb si exactly how I want but I can't manage to make it work like before.
Screenshot 2021-03-04 at 00.27.22.png
I've created to more categories, but for example I don't want to have title with breadcumb in that 2 categories, just in the category with "Universități" I would like to do it available (if you would like to have a look my forum address is unistudent.ro)

Later edit: It is
HTML:
class="block block--category block--category1"



Thank you.
 
Last edited:
I can't edit my previous post.
@Brogan if <xf:if is="$containerKey == 'node-2'"> or == node-1 it will be visible just for that node.
What I need is to be visible on whole category, because that category have lots of nodes.

Edit: actualy I see now ... have to be forum_view of that specific category ("Universitati") to show the breadcrumbs
 
PAGE_CONTAINER şablonunu 490. satırdan düzenleyin.

Bunu değiştir:
[KOD=html]<xf:if is="!$noH1">
<h1 class="p-title-value">{$h1}</h1>
</xf:if>[/KOD]

Buna:
[KOD=html]<xf:if is="!$noH1">
<xf:set var="$firstBreadcrumb" value="{$breadcrumbs|last}" />
<h1 class="p-title-value">{{ $firstBreadcrumb ? $şablon == 'forum_view' ? {$ilkBreadcrumb|ilk}.' > ' : '' : '' }}{$h1}</h1>
</xf:if>[/KOD]

Sonuç, ebeveynli bir forum için şudur:

View attachment 247713

Bu, ebeveyni olmayan bir forum için:

View attachment 247712

Merhabalar, ekran görüntüsündeki gibi forum başlığının yanına kategori eklemeye çalışıyorum. Böyle bir şey mümkün mü?
View attachment 247155

Bu metnin konumu önemli değil, muhtemelen forum başlığının başında olacaktır (h1).
Bunu yapmak istiyorum çünkü aynı ada sahip ancak farklı kategoriye (ve url'ye) sahip birkaç forumum olacak ve birisinin bir gönderi yaptığında doğru kategoriyi göreceklerinden emin olmak istiyorum.

Teşekkürler.


Thank you very much I Have a Question How Do I Move the Title to BreadCrumb
 
Back
Top Bottom