Back to RJGallery Support

merodeador
merodeador

Hi, I'm trying to show a gallery inside a static page by using a snippet (created from a partial that includes the gallery component).

In the partial, i can choose which gallery to show by selecting it from the dropdown menu in the component's settings :

Imgur

This will show the same gallery wherever i use the snippet.

I've tried to use the external parameter like this :

Imgur

and then add the galleries manually. I looked up the gallery ID's and titles in the database table raviraj_rjgallery_galleries :

Imgur

my partial's code now looks like this :

[viewBag]
staticPageSnippetCode = "photoGallery"
staticPageSnippetName = "photoGallery"
staticPageSnippetProperties[galleryID|type] = "dropdown"
staticPageSnippetProperties[galleryID|title] = "choose a gallery"
staticPageSnippetProperties[galleryID|options|1] = "a gallery"
staticPageSnippetProperties[galleryID|options|2] = "another gallery"
staticPageSnippetProperties[galleryID|options|3] = "third gallery"
staticPageSnippetProperties[galleryID|options|4] = "more photos"
[gallery]
idGallery = "{{ galleryID }}"
lang = "Gallery"
jqueryinject = "yes"
thumbnail = "true"
caption = "true"
desc = "true"
counter = "true"
controls = "true"
preload = "1"
mode = "fade"
speed = "500"
loop = "true"
auto = "false"
pause = "2000"
escKey = "true"
height = "150"
width = "150"
resizer = "crop"
==
<div>
    {% component 'gallery' %}
</div>

Now i can go to the static page, drag the snippet into the editor and choose the gallery from the snippet's options :

Imgur

This is great, but... i need to load the list of galleries dinamically instead of hard-coding them into the partial. How can i achieve this?

Thanks in advance.

Last updated

merodeador
merodeador

Never mind. i figured out the correct way of doing this.

I was going the wrong way altogether by trying to dinamically modify the viewBag parameters (which doesn't work because life cycle functions can't return any values ).

For anyone else stuck with this :

It's not necessary to make a partial to include the component as a snippet, this is possible by using the component directly.

I found the info i needed on the static pages documentation

To make the component available as a snippet, just open the file /plugins/raviraj/rjgallery/plugin.php and insert the following code inside the Plugin class :

public function registerPageSnippets()
 {
 return [
      'Raviraj\Rjgallery\Components\Gallery' => 'gallery',
      ];
 }

(...which actually is the same code used to register the component).

Last updated

1-2 of 2