random quote

RandallC

Well-known member
I want to add random quote to the header area on my forum but every code I found for some reason needs a button on there that changes the quote. I know there is a random one out there just to display text in a normal fashion.

I dont know all of them I have tried are not what I am looking for.

Think of Hello Dolly from wordpress is what I am looking for. Just displays random text.
 
This can be done without an add-on. Utilize the Advertising setup. The following code will load a random quote each page load.

Setup -> Advertising -> Add advertisement ->
Title: Quotes
Position: Container header
HTML:
Code:
            <div class="p-header-quote u-hideWide">
                <xf:set var="$quote.1">Random quote #1</xf:set>
                <xf:set var="$quote.2">Random quote #2</xf:set>
                <xf:set var="$quote.3">Random quote #3</xf:set>
                <xf:set var="$quote.4">Random quote #4</xf:set>
                <xf:set var="$quote.5">Random quote #5</xf:set>
                <xf:set var="$quote.6">Random quote #6</xf:set>
                <xf:set var="$quote.7">Random quote #7</xf:set>
                {$quote.{{ ($xf.time % 7) + 1 }}|raw}
            </div>

Save.


Pretty easy to edit. Each quote requires its own line (just increase the number)

Code:
<xf:set var="$quote.#">Random quote #7</xf:set>

You also need to adjust the: $xf.time % 7 value to the number of quotes you have. Example if you only have 3 quotes:

Code:
            <div class="p-header-quote u-hideWide">
                <xf:set var="$quote.1">Random quote #1</xf:set>
                <xf:set var="$quote.2">Random quote #2</xf:set>
                <xf:set var="$quote.3">Random quote #3</xf:set>
                {$quote.{{ ($xf.time % 3) + 1 }}|raw}
            </div>

The "u-hideWide" class will also automatically hide the quotes at the "wide width" so they won't be shown on smaller screens.
 
Top Bottom