Elxis CMS Forum

Extensions => Modules => Topic started by: bledi on May 07, 2020, 15:38:07

Title: Gallery module
Post by: bledi on May 07, 2020, 15:38:07
Hello
I want to use a gallery of images for each articles on the right side columns.
So each article has a gallery of it's own.
The simple gallery module it is still not fixed for elxis 5.1....
Any Suggestion which module i can use??
Thanks in advance

Title: Re: Gallery module
Post by: datahell on May 07, 2020, 19:58:55
What you ask is a custom solution so you need a custom module. However with a very small change in the default Elxis gallery module you can do what you want. I write you below how to do it.

Open file modules/mod_gallery/mod_gallery.php
Find line 53:
$this->dir = $params->get('dir', '');

Replace it with:
if (defined('ELXIS_ARTID')) {
   switch (ELXIS_ARTID) {
      case 12: $this->dir = 'article12/'; break;
      case 15: $this->dir = 'article15/'; break;
      case 23: $this->dir = 'article23/'; break;
      default: $this->dir = $params->get('dir', ''); break;
   }
} else {
   $this->dir = $params->get('dir', '');
}

Note 1: 12, 15 and 23 are sample article IDs. Replace them with your owns and add the same way all the articles you want before the "default" case.
Note 2: For each article create a corresponding folder inside folder "media/images/". For example: media/images/article45/ and upload the article gallery images there
Note 3: The default case will display in all other pages the default gallery as set in module parameters. if you dont want to display a gallery in this case then replace the above code with this:

$showgallery = true;
if (defined('ELXIS_ARTID')) {
   switch (ELXIS_ARTID) {
      case 12: $this->dir = 'article12/'; break;
      case 15: $this->dir = 'article15/'; break;
      case 23: $this->dir = 'article23/'; break;
      default: $this->dir = $params->get('dir', ''); $showgallery = false; break;
   }
} else {
   $this->dir = $params->get('dir', ''); $showgallery = false;
}
if (!$showgallery) { return; }