vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=324856

Random Quotes
by Alice
01 Apr 2017 20:30

Hello Again,

Does anyone happen to know the best method to have random quotes displayed everytime a page in vBulletin is refreshed?

An image of where I have setup for the quotes to be displayed is as follows:

http://i.imgur.com/29KA8Fk.png?1

And the code for that is:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Hopefully, someone out there is able to provide some insight. Thank you,

MarkFL 01 Apr 2017 20:44

What I would do is define a 2D array of quotes, where each element of the array contains a quote and the author, and then generate a random number between 1 and the length of the array (inclusive), then pass the selected array element to your template. :)

Alice 01 Apr 2017 20:48

Quote:

Originally Posted by MarkFL (Post 2584601)
What I would do is define a 2D array of quotes, where each element of the array contains a quote and the author, and then generate a random number between 1 and the length of the array (inclusive), then pass the selected array element to your template. :)

How would I interface that with a vbulletin template though? Like there are plenty of random tutorials out there that involve php code, but I don't know how to integrate that into a vBulletin template so its a little confusing, you know?

MarkFL 01 Apr 2017 20:52

You could use a global plugin hook, and I believe in vB 3 you don't even need to register the variables in your template.

I don't have time right now, but if you want, I will look into creating a vB 3.8.x product to do this. :)

Alice 01 Apr 2017 20:53

So you can use the plugin in much the same way as I did to define the $quotemain for the footer template, right?


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It might be a good idea. I know so many people still use 3.8.x, heck I still know someone who still uses 2.3.x LOL!

--------------- Added 01 Apr 2017 at 21:48 ---------------

Quote:

Originally Posted by MarkFL (Post 2584603)
You could use a global plugin hook, and I believe in vB 3 you don't even need to register the variables in your template.

I don't have time right now, but if you want, I will look into creating a vB 3.8.x product to do this. :)

Okay, so I got somewhere with this. In the quotes_main template (which is called in the footer template as &quotemain), I added:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The contents of the quotes_database.js is:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And the contents of quotes_call.js is:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And this is how it shows up on my forum:

http://i.imgur.com/WKaQou4.png?1

-Sara

blind-eddie 01 Apr 2017 22:02

Use this.... edit to your liking
I have an edited version of it on my site.

http://www.vbulletin.org/forum/showt...highlight=tips

Alice 02 Apr 2017 02:44

Quote:

Originally Posted by blind-eddie (Post 2584607)
Use this.... edit to your liking
I have an edited version of it on my site.

http://www.vbulletin.org/forum/showt...highlight=tips

Thank you so much for your contribution. I've actually already implemented what I included above and it works splendidly :)


All times are GMT. The time now is 12:21.

Powered by vBulletin® Version 3.8.14
Copyright © 2021, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.