(Small question) QOTD from text file or Google Sheet

A small question: I would like to add a Quote of the Day section in a box on my home page. BUT, rather than use one of the many QOTD widgets out there, I want to use my own collection of quotes that are (somewhat) relevant to my site’s niche. And to make matters worse, my hosting company does not allow FTP access to the file server, so the quote list cannot live there.

I messed around some with using the Google Sheets API, but it’s going to take more time and effort than I want to put into it. (And frankly, I’m not sure that’s the best solution anyway.)

SO – has anyone built and implemented something like this, that you are willing to share?

Okay, going to give this one bump, then mark it closed if no answer. I realize it’s a really niche question, so no worries if no one has a suggestion. Thanks!

Here’s a very basic implementation. The downside is that it’ll require you to update the quotes every month. The upside is that it’s pretty simple.

Somewhere in your theme or via the HTML card, add an element with the id of “quote” (or whatever you want to call it). This is where the quote will be injected.

<p id="quote"></p>

Then, add this JS to your theme or via a script tag in Code Injection:

<script>
    const quotes = [
    "The only way to do great work is to love what you do. - Steve Jobs",
    "The purpose of our lives is to be happy. - Dalai Lama",
    "Life is what happens when you're busy making other plans. - John Lennon",
    "Get busy living or get busy dying. - Stephen King",
    "You only live once, but if you do it right, once is enough. - Mae West",
    "Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas A. Edison",
    "If you want to live a happy life, tie it to a goal, not to people or things. - Albert Einstein",
    "Never let the fear of striking out keep you from playing the game. - Babe Ruth",
    "Money and success don’t change people; they merely amplify what is already there. - Will Smith",
    "Your time is limited, don't waste it living someone else's life. - Steve Jobs",
    "Not how long, but how well you have lived is the main thing. - Seneca",
    "If life were predictable it would cease to be life, and be without flavor. - Eleanor Roosevelt",
    "The whole secret of a successful life is to find out what is one's destiny to do, and then do it. - Henry Ford",
    "In order to write about life first you must live it. - Ernest Hemingway",
    "The big lesson in life, baby, is never be scared of anyone or anything. - Frank Sinatra",
    "Sing like no one's listening, love like you've never been hurt, dance like nobody's watching, and live like it's heaven on earth. - Mark Twain",
    "Curiosity about life in all of its aspects, I think, is still the secret of great creative people. - Leo Burnett",
    "Life is not a problem to be solved, but a reality to be experienced. - Soren Kierkegaard",
    "The unexamined life is not worth living. - Socrates",
    "Turn your wounds into wisdom. - Oprah Winfrey",
    "The way I see it, if you want the rainbow, you gotta put up with the rain. - Dolly Parton",
    "Do all the good you can, for all the people you can, in all the ways you can, as long as you can. - Hillary Clinton",
    "Don't settle for what life gives you; make life better and build something. - Ashton Kutcher",
    "Everything negative – pressure, challenges – is all an opportunity for me to rise. - Kobe Bryant",
    "I like criticism. It makes you strong. - LeBron James",
    "You never really learn much from hearing yourself speak. - George Clooney",
    "Life imposes things on you that you can't control, but you still have the choice of how you're going to live through this. - Celine Dion",
    "Life is really simple, but men insist on making it complicated. - Confucius",
    "Life is a succession of lessons which must be lived to be understood. - Helen Keller",
    "My mama always said, life is like a box of chocolates. You never know what you're gonna get. - Forrest Gump",
    "Watch your thoughts; they become words. Watch your words; they become actions. Watch your actions; they become habits. Watch your habits; they become character. Watch your character; it becomes your destiny. - Lao Tzu"
];

// Get the quote element
const quoteEl = document.getElementById('quote');

// Index the day of the month 
const dayOfTheMonth = new Date().getDate();

// Access the quote and put it on the page
quoteEl.textContent = quotes[dayOfTheMonth - 1];
</script>

Here’s the code in action: QOTD

More advanced solutions would obviously require more advanced code.

2 Likes