Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Black Friday Intro Offer for your subscription's lifetime
🎉 Black Friday sale is here! Great savings on professional and developer memberships! Get 25% off now with code BLACK-FRIDAY-2024!

[SOLVED] CB Gallery Module - Cached random order?

  • sysopcrew
  • sysopcrew
  • OFFLINE
  • Posts: 74
  • Thanks: 14
  • Karma: 3
7 years 7 months ago - 6 years 9 months ago #293007 by sysopcrew
I've got the module working to show 7 random gallery images from profile.%, but the images do not change unless I change the Limit on the Media tab in the module setting. It seems to generate a new random selection only when it's saved with new settings.



Is there a cache?

Version 2.0.1

--
David Riviera
Attachments:
Last edit: 6 years 9 months ago by krileon. Reason: Added [SOLVED] tag to subject

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
7 years 7 months ago #293042 by krileon
Replied by krileon on topic CB Gallery Module - Cached random order?
Yes, the random order value is cached per gallery. There's already a feature ticket to review improving this.

forge.joomlapolis.com/issues/6250


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: sysopcrew

Please Log in or Create an account to join the conversation.

  • sysopcrew
  • sysopcrew
  • OFFLINE
  • Posts: 74
  • Thanks: 14
  • Karma: 3
7 years 7 months ago #293045 by sysopcrew
Replied by sysopcrew on topic CB Gallery Module - Cached random order?
One thing I've done is cache the directory build/database call every 15 minutes into a stored array, then use array_rand(), shuffle($array) or array[rand(0,count($array)-1)] to pick a key until the cache expires. You aren't reading the disk or database every time, but get pretty decent random display. Creating an item in the gallery could trigger the array cache, even. Just some ideas. At least I'm not crazy thinking it was misconfigured. Thanks!

--
David Riviera

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
7 years 7 months ago #293062 by krileon
Replied by krileon on topic CB Gallery Module - Cached random order?
The galleries are cached into session and pass from page to page using the gallery id generated from the galleries parameters. The random value is basically just the id. The big issue is it needs to have the same random seed when moving from Page 1 to Page 2 for example (otherwise paging literally can't work with random usage). This means it needs to cache with the gallery or be passed with the pagination link. Passing with pagination link only means when you edit an entry and hit cancel it returns to the wrong seed if you're on page 1 since it'll generate a new seed. This means return URLs then need to have it. It was easier to just cache it with the gallery initially and improve it later.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

6 years 9 months ago #302149 by ichepurnoy
Replied by ichepurnoy on topic CB Gallery Module - Cached random order?
To show 1 random image (from users' uploads) in a module, I went to module's settings , and set Media \ Paging \ OrderBy to `random`.
In the `Gallery` tab there, I've set `asset` option to `profile.%`. Done!
Just stating this for anyone who might be stuck on this.

Please Log in or Create an account to join the conversation.

  • sysopcrew
  • sysopcrew
  • OFFLINE
  • Posts: 74
  • Thanks: 14
  • Karma: 3
6 years 9 months ago - 6 years 9 months ago #302150 by sysopcrew
Replied by sysopcrew on topic CB Gallery Module - Cached random order?
Yes, random now works because of a fix krileon put in forge.joomlapolis.com/issues/6250 six months ago.

--
David Riviera
Last edit: 6 years 9 months ago by sysopcrew.
The following user(s) said Thank You: krileon

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum