Skip to Content Skip to Menu

🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

Finding gallery id from CB gallery plugin

  • svictor
  • svictor
  • OFFLINE
  • Posts: 13
  • Thanks: 1
  • Karma: 1
8 years 2 months ago #286996 by svictor
Greetings,

A while ago, I’ve built a small module to display a random image from CB Gallery anywhere on the website. The module shows the image, its description and some informations from the user profile.
That all worked well with CB Gallery 1.x. I displayed the image by passing a query like this as the <img> src attribute:
Code:
index.php?option=com_comprofiler&view=pluginclass&plugin=cbgallery&action=items&func=preview&type=photos&id=73&user=179&format=raw
Basically my module looks in the table #_comprofiler_plugin_gallery_items and picks a random photo from there, checks that it’s viewable and the user still exists and then builds an url as above to display the image from CB gallery.

Version 2.0 of the plugin introduced a "gallery" parameter in the query. The query for the full image is now something like this:
Code:
index.php?option=com_comprofiler&view=pluginclass&plugin=cbgallery&action=item&func=show&id=14&gallery=554f2a4ca8699ce06f80a035b0422d7c&Itemid=483&format=raw

How can I get the "gallery=554f2a4ca8699ce06f80a035b0422d7c" part of the query from the informations I have: picture id and user id?

Cheers,
Victor

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48622
  • Thanks: 8302
  • Karma: 1446
8 years 2 months ago #287000 by krileon
Replied by krileon on topic Finding gallery id from CB gallery plugin
CB Gallery 2.x comes with a module and it has an order by of random so you shouldn't need to use a custom implementation anymore. You can't get the gallery ID unless you build the gallery. This is how it loads parameters from page to page and secures galleries. You'd need to use the PHP API to properly build a gallery if you want the ID.


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.

  • svictor
  • svictor
  • OFFLINE
  • Posts: 13
  • Thanks: 1
  • Karma: 1
8 years 2 months ago - 8 years 2 months ago #287021 by svictor
Replied by svictor on topic Finding gallery id from CB gallery plugin
Thanks! I wasn’t aware of that new module.

I tried it and couldn’t yet achieve what I need. I’m facing two issues.
1. By default I can only see my own images when I’m logged in, and no images at all when I’m not logged in. I saw the field Asset, and understood from its docstring that this is the expected default. However, the rest of it is a bit cryptic to me. What do I need if I want to pick images in all galleries of all users and display them to unregistered visitors?
EDIT : I found the question had already been answered here : www.joomlapolis.com/forum/153-professional-member-support/234639-cb-gallery-module?start=6
So this is solved. Next one remains…

2. Once I manage to do this, my next step would be to set random order and restrict the display to one image. I tried setting Media -> Order By -> random but I always get the pictures of my gallery in the same order. And if I set Media -> Limit to 1, it’s always the same picture. Did I miss another setting for randomness?

EDIT : Additionnally, I’m looking at the CB gallery plugin, as my module is in fact displayed in an article. It would certainly be more straightforward to use the plugin. But it only accepts items_orderby="COLUMN_DESC_OR_ASC" right ? Is there a plan to support random ordering in the plugin too?

My use case is very simple: on the frontpage of our website we have a greeting text in which we include one random picture from our members’ gallery. My intention is to tweak the module/plugin to also display the name of the member, some additional fields from her profile, and link back to the profile page. Please feel free to suggest a simpler way to achieve this if available

Regards,
Victor
Last edit: 8 years 2 months ago by svictor.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48622
  • Thanks: 8302
  • Karma: 1446
8 years 2 months ago #287050 by krileon
Replied by krileon on topic Finding gallery id from CB gallery plugin

2. Once I manage to do this, my next step would be to set random order and restrict the display to one image. I tried setting Media -> Order By -> random but I always get the pictures of my gallery in the same order. And if I set Media -> Limit to 1, it’s always the same picture. Did I miss another setting for randomness?

It's randomized per session/gallery. If you want random on every page load it won't do that as it won't be able to cache between loads losing significant performance efficiency. Will review improving the randomization of it for next release.

forge.joomlapolis.com/issues/6250

EDIT : Additionnally, I’m looking at the CB gallery plugin, as my module is in fact displayed in an article. It would certainly be more straightforward to use the plugin. But it only accepts items_orderby="COLUMN_DESC_OR_ASC" right ? Is there a plan to support random ordering in the plugin too?

You can supply the random orderby using items_orderby="random".

My use case is very simple: on the frontpage of our website we have a greeting text in which we include one random picture from our members’ gallery. My intention is to tweak the module/plugin to also display the name of the member, some additional fields from her profile, and link back to the profile page. Please feel free to suggest a simpler way to achieve this if available

The module supports Joomla template layout overrides so you could override the layout to have other information if you're wanting. The layout also has complete access to the gallery object.


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.

  • svictor
  • svictor
  • OFFLINE
  • Posts: 13
  • Thanks: 1
  • Karma: 1
8 years 2 months ago #287099 by svictor
Replied by svictor on topic Finding gallery id from CB gallery plugin
Ok thanks for considering to improve random ordering in future releases.

The description of the plugin could mention the possibility to order by random too.

I’ll try the template override suggestion.

Thanks !

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

Moderators: beatnantkrileon
Powered by Kunena Forum