Dirty Butter Posted July 5, 2015 Share Posted July 5, 2015 I have always shown a scripture verse at the bottom of our pages. And I've always wanted some way to randomize, or at least automatically change, which verse was shown, but never felt like I could accomplish that. I still don't know what to do, but just maybe I have reached the point where I could follow someone's directions to accomplish this.In preparation for any directions I hopefully can follow, I have populated a new CubeCart_scriptures table with 2 rows:scripture_id index int(11) with autoindexscripture_verse utf8_unicode_ci textRight now there are 11 entries in the verse row, but I would hope to add more later.I'm planning at this point to add whatever code is needed to the ccpower.php file, if that makes sense.So - am I asking for something difficult, fairly easy to do, or maybe impossible??? Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 6, 2015 Share Posted July 6, 2015 Incredibly easy to do. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 6, 2015 Author Share Posted July 6, 2015 Good to hear. Whenever you have the time to help would be very appreciated. Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 6, 2015 Share Posted July 6, 2015 Seeing as you already have the Site Testimonials mod, it would be (fairly) trivial to hack a copy of that. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 6, 2015 Author Share Posted July 6, 2015 I actually already looked over the Testimonials code in gui.class.php to see if I could tell how to do it myself. Is that the right place to copy and attempt? Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 6, 2015 Share Posted July 6, 2015 I would make an educated guess and say yes.(I checked SFWS T&C's and I read them to infer it should be OK to use a mod more than once on the same store.) Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 7, 2015 Author Share Posted July 7, 2015 Well, I fiddled around with making the changes myself, but it's past me. Since I paid for Testimonial, and you say this should be easy for a knowledgeable person, I will contact SemperFi before I do anything else. Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 7, 2015 Share Posted July 7, 2015 Sure. If he wants to take a bit longer than what you are willing to wait, ask him for permission to send me a copy of the mod and I'll work with you to figure it out. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 7, 2015 Author Share Posted July 7, 2015 I couldn't resist working on this again on my own before giving up and emailing Daren. I was able to search and work out a query that does return a random row.SELECT * FROM `CubeCart_scriptures` WHERE scripture_id >= (SELECT FLOOR( MAX(scripture_id) * RAND()) FROM `CubeCart_scriptures` ) ORDER BY scripture_id LIMIT 1But I wasn't able to understand how to then select just the scripture_verse and get it on the page. Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 7, 2015 Share Posted July 7, 2015 The SELECT * is returning all columns of one record in an associated array of an indexed array:[0] => ['scripture_id' of row 0] = somenumber, and ['scripture_verse' of row 0] = somephrase So, the query results are being assigned to a variable,such as $scripture_random_record. To display what you want, use the variable this way:$GLOBALS['smarty'] -> assign('RAND_VERSE', $scripture_random_record[0]['scripture_verse']); Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted July 7, 2015 Author Share Posted July 7, 2015 (edited) I think I was misleading - the query I came up with did not come from SFWS's code, but from searching the web. I have emailed Daren. Thank you for your help so far. Even my feeble attempts, though unsuccessful, teach me a little, thanks to your patience in explaining how things work. Edited July 7, 2015 by Dirty Butter Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.