Forum

Thread tagged as: Question, Gallery, Field-Types

Gallery inside portfolio detail page

Hey I need some help with this following issue:

I created a two-page list and detail page with the description from the "articles and solutions" site. Works fine so far.

So what I have so far is a portfolio site where you see a link ox my work and when you click on it you get to the new page project.php which is my detail page.

this is what i wrote to my project.php:

 <?php
perch_content_custom('Projects', array(
     'page' => '/website3/index.php',
     'template' => 'project.html',
     'filter' => 'slug',
     'match' => 'eq',
     'value' => perch_get('s'),
     'count' => 1,
));
?> 

Now I used the gallery app and created an albumlist field to select a gallery for my project.

I added this gallery to the bottom of my detail page with the following code:

<?php
$album = perch_content_custom('Projects', array(
'skip-template'=>true,
'filter'=>'slug',
'match'=>'eq',
'value'=>$_GET['s'],
));

$opts02 = array(
'template'=>'a_list_image.html'
);
if (is_array($album)) {
// ['album'] is the ID of the field to get the slug from
$albumSlug = $album[0]['album'];
perch_gallery_album($albumSlug,$opts02);
}
?>

Till here everything works like expected. I have my detail page using the project.html template and under this section i have my gallery for this project. But what I need is to output the gallery inside of the project.html template and not beneath it.

Is there a solution for this issue?

I searched for that issue and found this link: https://github.com/shb/perch-fieldtype-album/blob/master/README.md

I tried to get it work but as soon as I insert this new field type to my template the site does not load and repeats the preloader forever.

Thanks for your help.

Joerg Vogel

Joerg Vogel 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes:

$album = perch_content_custom('Projects', array(
'skip-template'=>true,
'filter'=>'slug',
'match'=>'eq',
'value'=>$_GET['s'],
));

$opts02 = array(
'template'=>'a_list_image.html'
);
if (is_array($album)) {
// ['album'] is the ID of the field to get the slug from
$albumSlug = $album[0]['album'];
PerchSystem::set_var('album_html', perch_gallery_album($albumSlug,$opts02, true));
}

perch_content_custom('Projects', array(
     'page' => '/website3/index.php',
     'template' => 'project.html',
     'filter' => 'slug',
     'match' => 'eq',
     'value' => perch_get('s'),
     'count' => 1,
));

And in project.html add:

<perch:content id="album_html" encode="false" />

Great Thanks a lot!!