XF 2.1 Conditional Statement for 1st Page of Forum Only

jgaulard

Active member
I am trying to display a piece of text on only the first page of my site's forums. For all the following pages, I'd like the text not to show. Does anyone know what code I should use for this conditional statement?

Thanks.

Jay
 
You can use this conditional:


Gave instructions on how to find the template name there too.
 
You can use this conditional:

What I mean is, if I have a certain forum (not the overall website, but one of the many forums contained therein) that has multiple pages and pagination down at the bottom of the thread list, I'd like the conditional to say, only show this text snippet on the first page of this particular forum and not any of the following pages. Something like:

(if page 1 of pagination)
text here
(else)
no text
(/if)

So unfortunately, the conditional you linked to won't work in this case. Thank you though.
 
You can edit the template forum_view and add something like this:

Code:
<xf:if is="$page == '1'">
page 1
</xf:if>
<xf:if is="$page == '2'">
page 2
</xf:if>

Appears to work there.
 
You can edit the template forum_view and add something like this:

Thanks very much for this. Your code needed one small tweak to work. I changed "$page" to "$pageNumber" and it's working.

Thanks again.

Jay

PS - I added this code to the PAGE_CONTAINER template because I wanted it to affect the description text that physically shows to the user on the forum page.
 
Last edited:
Thank you @jgaulard, that tip worked for me. In my case the text I looked for to show is the description.
I paste the code
Code:
              <xf:if is="$pageNumber == '1' AND $description is not empty">
                    <div class="p-description">{$description}</div>
                </xf:if>

Just a question, the block of text snippet that you added at the end of your forum view, is that an add-on? an extra field? (the one I refer on the attachment)
Thank you in advance and kind regards
 

Attachments

  • block-text-forum-view.webp
    block-text-forum-view.webp
    22.5 KB · Views: 8
Last edited:
Thank you @jgaulard, that tip worked for me. In my case the text I looked for to show is the description.
I paste the code
Code:
              <xf:if is="$pageNumber == '1' AND $description is not empty">
                    <div class="p-description">{$description}</div>
                </xf:if>

Just a question, the block of text snippet that you added at the end of your forum view, is that an add-on? an extra field? (the one I refer on the attachment)
Thank you in advance and kind regards
That's a great question and one I have been meaning to answer in a post for a while. Let me write it up so I can explain everything thoroughly and when it's completed, I'll link to if here. It shouldn't take too long.

UPDATE:

I wrote the post with the instructions in it. Please take a look here:


Thanks!
 
Last edited:
Top Bottom