Forum
How can I allow the client to choose a gallery and it outputs all the images of...
I want the client to be able to select the gallery that goes with a vehicle. So I have a dropdown in the template, that shows the galleries available.
Template:
<perch:content id="album" type="albumlist" label="Album" />
The above code is just out putting the slug for the album, which is correct, but I want to be able to take that slug and show the images for that gallery, so I can build a slider.
On the page, I've tried various things, this is what I have and its not working.
<?php
$albumSlug = $album[0]['album'];
perch_gallery_album($albumSlug);
if(perch_get('s')) {
perch_gallery_album_images(perch_get('s'), array(
'template' => 'gallery_slider.html',
'image' => true
));
}
?>
So that doesn't work:
Array
(
[type] => 8
[message] => Undefined variable: album
[file] => /public_html/stock/vdp.php
[line] => 10
)
So how do I pass that slug album id to my page from the template once the user can selected it?
Health check
PHP 5.5.38 is up to date
MySQL 5.5.5-10.0.28-MariaDB is up to date
Image processing available
Summary information
Perch: 3.0, PHP: 5.5.38, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 15d5c781cfcad91193dceae1d2cdd127674ddb3e $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0), assets (3.0), categories (3.0)
App runtimes: <?php $apps_list = [ ];
PERCH_LOGINPATH: /cms
PERCH_PATH: /home/sites/sitename.com/public_html/cms
PERCH_CORE: /home/sites/sitename.com/public_html/cms/core
PERCH_RESFILEPATH: /home/sites/sitename.com/public_html/cms/resources
Image manipulation: GD
PHP limits: Max upload 64M, Max POST 64M, Memory: 128M, Total max file upload: 64M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
HTTP_HOST: sitename.com
DOCUMENT_ROOT: /home/sites/sitename.com/public_html/
REQUEST_URI: /cms/core/settings/diagnostics/
SCRIPT_NAME: /cms/core/settings/diagnostics/index.php
Where is
$album
created?Well its not, I think, I tried using this code, mentioned here: https://docs.grabaperch.com/addons/gallery/fieldtypes/ - but that was saying that the region didn't exist.
I want to be able to take the album slug and use that to show the images that go with that album.
As you can probably tell, i have no idea what I am doing, I know what I want to do :/
So using this code, I can show the images I need, but here I am hard coding the gallery ID.
The user is selecting the gallery via the vehicle_details templates, which is bellow the above code, so I thought there is no way it can work.
So I need to work out how to get the gallery id into the page before the vehicle_details template. So I may need to move this code elsewhere:
I'm using list and detail, i have a stock page that lists the cars:
Can I somehow pass the gallery id from /stock/index.php to the vehicle details page?
Oh my gosh, thank you so much Duncan! It works.