This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorials:zencartmods:quotes.html [2011/06/29 19:56] daigo created |
tutorials:zencartmods:quotes.html [2016/01/28 18:05] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ==== Put a random quote on your zen cart template ==== | ||
+ | {{:tutorials:zencartmods:quote.png}} | ||
=== Create the Table === | === Create the Table === | ||
Line 24: | Line 26: | ||
Find the place in the template where you'd like to insert the random quote, and add these lines: | Find the place in the template where you'd like to insert the random quote, and add these lines: | ||
+ | in file **includes/templates/YOUR_TEMPLATE/tpl_SOME_FILE.php** | ||
<code php> | <code php> | ||
$quote_sql = $db->Execute("SELECT * from quotes WHERE quotes_active = 1 ORDER BY RAND() LIMIT 1;"); | $quote_sql = $db->Execute("SELECT * from quotes WHERE quotes_active = 1 ORDER BY RAND() LIMIT 1;"); | ||
- | $quote_content = '<div style="color: #000;font-weight: normal">"' . stripslashes($quote_sql->fields['quotes_text']) . '"</div> <br /><div style="text-align:right; margin-right: 10px;"> - <a style="font-weight: normal" href="'.stripslashes($quote_sql->fields['quotes_link']).'" target="_blank">' . stripslashes($quote_sql->fields['quotes_author']). '</div></a></div>'; | + | $quote_content = '<div>"' . stripslashes($quote_sql->fields['quotes_text']) . '"</div> <br /><div> - <a href="'.stripslashes($quote_sql->fields['quotes_link']).'" target="_blank">' . stripslashes($quote_sql->fields['quotes_author']). '</div></a></div>'; |
echo $quote_content; | echo $quote_content; | ||
</code> | </code> | ||
+ | |||
+ | Obviously you should modify this to match your own template, and add whatever CSS would make it look good. | ||
+ | |||
+ | === Test it Out === | ||
+ | |||
+ | Add a few quotes into your database and test it out! | ||
+ | |||
+ | === Helper File === | ||
+ | |||
+ | You don't want to have to manually add quotes in the db through mysql every time, that would be a pain! Instead you should [[tariffhelper.html|make yourself a nice helper file]] in php that you can use through the zencart admin. | ||
+ | |||
+ | Here's an example of a simple file we use to make managing the quote a little easier: | ||
+ | |||
+ | {{:tutorials:zencartmods:quotes.php.zip|}} |