MyBB Community Forums

Full Version: Random Quote Generator Partially Complete - Help Needed
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

My site is www.vampirecounts.net

Recently someone was working on a modification on my test site, which would insert a random quote generator, which would display on every page. Highlighted in red in the below pic:

[attachment=25189]

The problem was is that whilst he did 99% of it, he then disappeared and I am unsure what I need to do to copy this function over to my live site - unfortunately I am not very technical.

Hence why I have come to here for help!

Here is what I have found so far:

Inserted into header template:

<div class="tborder">
	<div class="thead">
<strong>Quotes</strong>
<div class="expcolimage">
<img src="images/carpe-noctem/collapse.gif" id="quotes_col" class="expander" alt="[-]" title="[-]" style="cursor: pointer; ">
</div>
	</div>
<p id="quotes"></p>
</div>
<br />

Two templates inserted into Global Templates:

quotes
<div style="background-color: #101010; color: #848484; border-top: 1px solid #525252; border-bottom: 1px solid #525252; border-left: 1px solid #525252; border-right: 1px solid #525252; text-align: center; margin: 10px auto; padding: 5px 20px">
	<strong>{$mybb->settings['quotestext']}</strong><br />
	{$showrandomquotes}
</div>

quotes_alt
<table width="100%" border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<thead>
	<tr>
		<td class="thead">
			<div class="expcolimage"><img src="{$theme['imgdir']}/collapse{$collapsedimg['quotes']}.gif" id="quotes_img" class="expander" alt="[-]" /></div><div><strong>{$mybb->settings['quotestext']}</strong></div>
		</td>
	</tr>
</thead>
<tbody style="{$collapsed['quotes_e']}" id="quotes_e">
	<tr>
		<td class="trow1">{$showrandomquotes}</td>
	</tr>
</tbody>
</table>
<br/>

Finally in the jscript folder for this theme I found a quotes.js, which includes a sampling of the quotes I need.

I understand I will need to copy the new templates / template changes and js file over to the live site. However I am having trouble tracing:

{$mybb->settings['quotestext']}
<td class="trow1">{$showrandomquotes}</td>

I assume they refer to other changes elsewhere, but I can't figure out where Sad

Also, the collapse button on the right does not work, so any suggestions on how to make that work would be appreciated.


Thanks for much for any help.
Well, usually you'd have a plugin in inc/plugins called randomquotes.php or something which would create settings on activation and use various hooks to initialize the $showrandomquotes variable at some point.
Nope, no plugin file as far as I can see, and the quote function works fine so the coding must be there somewhere.

Anywhere else I should look?
Use the file verification tool and check the modified files... The $showrandomquotes would have to appear somewhere in the code so you can use some tool that can search for this string in your files
op
TL;DR

just edit and include this .js
it will solve your problems =)

il appreciate a rep+ if i have been useful

quotes.js
var quotes=new Array(); // do not change this!
quotes[0] = "quote 1";
quotes[1] = "quote 2";
var q = quotes.length;
var whichquote=Math.round(Math.random()*(q-1));
function showquote(){document.write(quotes[whichquote]);}
showquote();
Frostshutz: I wasn't aware there was such a tool. Is it a plugin I download?

Glad: That file would overwrite the quotes.js. But what about the previous coding in the global templates that point elsewhere such as $showrandomquotes ? I will of course give a rep of we can get this fixed Smile
It's in ACP->Tools
Well I have tried but I can't find it. Here is what I have found out so far:

The files quotes and quotes_alt in Global Templates appear to be irrelevant. I messed around with them, even renamed the templates and they had no affect whatsoever on the the generator.

The following code was found in headerinclude

<script type="text/javascript" src="{$mybb->settings['bburl']}/{$theme['imgdir']}/jscripts/quotes.js"></script>

So I am really confused on what to do. I tried copying the header and headerinclude changes, plus the quotes.js over to the live site, however it did not work.

No random quotes where generated, and whilst a table did appear with "Quotes" as the title, the grey swirly surrounds (you can see them around the other tables www.vampirecounts.net) were missing.

Any thoughts?

If this cannot be fixed can anyone advise of a way to create this random quote generator easily?
Why not try a jvascript function that is displays a variety of popups which is randomly generated by pressing a button.
I don't really want anything popping up.

The premise for this change was just a standard table that appeared on every page in the header, randomly displaying a quote on page refresh. I also wanted an expander / collapse option on the right hand side (like you can do for the forum sections), for those members who did not want to see it all the time.
Pages: 1 2