Display various quotes in a text element dynamically

Hi,
I have around 30 different quotes out of which I would like to have one displayed on my homepage dynamically (changing everytime the site is refreshed). I am assuming the easiest way to do something like this is with a looper, but unfortunately my tries so far have been unsuccessful. What would be the proper way to do this and how should I save the quotes so that the looper can access them?

Thanks for any help!

Hello Daniel,

Thanks for writing in!

You can use the Looper Provider JSON and place your quotes in a JSON list. For example,

[
  {
    "author": "Albert Einstein",
    "quote": "Life is like riding a bicycle. To keep your balance, you must keep moving."
  },
  {
    "author": "Maya Angelou",
    "quote": "You will face many defeats in life, but never let yourself be defeated."
  },
  {
    "author": "Mark Twain",
    "quote": "The secret of getting ahead is getting started."
  },
  {
    "author": "Eleanor Roosevelt",
    "quote": "The future belongs to those who believe in the beauty of their dreams."
  },
  {
    "author": "Nelson Mandela",
    "quote": "It always seems impossible until it's done."
  }
]

You can then use the {{dc:looper:field key="author"}} dynamic content to display the author and {{dc:looper:field key="quote"}} for the quote as well.

Hope this helps.

Hi Ruenel!

thanks for your response! I used your quote examples and managed to create the json looper provider in the section where I want to display the quotes. I activated the looper consumer for the text element that you can see below in the screen and put in both of the fields you suggested. That seems to be working well. However, what is still missing is the ability for the quotes to change randomly/automatically. What could I have overlooked there?


Thanks for your continuous support!

Hey Daniel,

You can use a condition with a random number. For example;
{{dc:looper:index_number}} == {{dc:random:integer min="1" max="10"}}

which means that the quote will only be displayed when the condition above is true assuming that you have 10 quotes.

Best Regards,
RueNel

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.