Forum

Thread tagged as: Question
Simon Clay

Simon Clay 127 points

Hi Daniel,

Perch shouldn't pick it up as a new region. It should automatically get the images and links and show them on the homepage with links in place.

A few things to check... what is the name of the Region for your projects on your projects.html page, or better still, can you show me the php code on that page?

from 'projects.html' :

<section id="griff-projects-content">   


        <?php
            perch_content_create('Projects list image', array(
                  'template'  => 'portfolio_detail.html',
                  'multiple'  => true,
                  'edit-mode' => 'listdetail',
            ));

            if (perch_get('s')) {
             // Detail mode
                $result = perch_content_custom('Projects list image', array(
                      'template' => 'portfolio_detail.html',
                      'filter' => 'slug',
                      'match' => 'eq',
                      'value' => perch_get('s')     
                ));
        ?>
        <div class="projects-nav">
            <ul class="np-link">
                <?php 
                    $results = perch_content_custom('Projects list image', array(
                        'template'      => 'portfolio_detail.html',
                        'filter'        => 'slug',
                        'match'         => 'eq',
                        'value'         => perch_get('s'),
                        'count'         => 1,
                        'skip-template' => true,
                        'return-html'   => true,
                    ));
                    perch_content_custom('Projects list image', array(
                        'template'   => 'portfolio_prev.html',
                        'filter'     => '_order',
                        'match'      => 'lt',
                        'value'      => $results[0]['_sortvalue'],
                        'sort'       => '_order',
                        'sort-order' => 'DESC',
                        'count'      => 1,
                    )); 
                    perch_content_custom('Projects list image', array(
                        'template'   => 'portfolio_next.html',
                        'filter'     => '_order',
                        'match'      => 'gt',
                        'value'      => $results[0]['_sortvalue'],
                        'sort'       => '_order',
                        'sort-order' => 'ASC',
                        'count'      => 1,
                    ));

                    //PerchSystem::set_var('is_prev', true);

                e
                ?>
            </ul>
        </div>
        </div><!-- project header -->
        <?php
                $result = perch_content_custom('Projects list image', array(
                      'template' => 'portfolio_h_detail.html',
                      'filter' => 'slug',
                      'match' => 'eq',
                      'value' => perch_get('s')     
                ));

            }
            else {
             // List mode
                perch_content_custom('Projects list image', array(
                    'template' => 'portfolio_listing.html',
                )); 
            }

        ?>


</section><!-- /projects-content -->
Simon Clay

Simon Clay 127 points

Cool, so, this on your homepage should work:

<?php 
perch_content_custom('Projects list image', [  
'page'=>'/projects.html',  
'template'=>'project_carousel.html',  
]);  
?>

and a template named: project_carousel.html in /perch/templates/content containing:

<perch:before> 
<section class="slider">  
</perch:before> 
<div> 
<a href="/projects.html?s<perch:content id="slug" type="slug" />"><perch:repeater id="images" label="Images" max="1"><img src="<perch:content type="image" id="image" label="Image" scope-parent="true" width="980" height="600" crop="true"/>" class="d-all t-all m-hide" alt="<perch:content type="text" id="alt" label="Description" />"</perch:repeater></a> 
</div> 
<perch:after> 
</section><!-- /slider --> 
</perch:after>

ok so that is indeed just showing the images on the homepage which is great

https://dev.griffbuild.co.nz/index.html

it is however loading another (invisible) image along side each that appear on the projects page

And, is each homepage image link is linking to the projects page, I was hoping it would link to the actual project page that each image relates to...

Thanks Simon

Simon Clay

Simon Clay 127 points

Ok, for linking to the actual project: sorry, missed an '=' in the template code:

Should be:

<perch:before>  
<section class="slider">  
</perch:before>  
<div>  
<a href="/projects.html?s=<perch:content id="slug" type="slug" />"><perch:repeater id="images" label="Images" max="1"><img src="<perch:content type="image" id="image" label="Image" scope-parent="true" width="980" height="600" crop="true"/>" class="d-all t-all m-hide" alt="<perch:content type="text" id="alt" label="Description" />"</perch:repeater></a>  
</div>  
<perch:after>  
</section><!-- /slider -->  
</perch:after>

Just looking into the invisible image issue now...

Simon Clay

Simon Clay 127 points

Ok, I can see the links to the actual projects are working now.

Now to find the issue with those mysterious images. Can you show me the homepage code?

from index.html:

  </head>

<body>

<?php perch_layout('global.header'); ?>

<div class="wrapper">  

    <?php  perch_content_custom('Projects list image', [  'page'=>'/projects.html',  'template'=>'project_carousel.html',  ]);  ?>      

<section id="griff-home-links"> 

    <div class="home-about-link t1-t2 m-all"><a href="about.html" title="About Griff Build"><img src="assets/images/home-about-image.jpg" alt="image-link about griff build" class="fullimg"/><h2>About</h2></div></a>
    <div class="home-projects-link t3-t4 m-all"><a href="projects.html" title="Griff Build Projects"><img src="assets/images/home-projects-image.jpg" alt="image-link griff build projects" class="fullimg"/><h2>Projects</h2></div></a>    
    <div class="home-contact-link t5-t6 m-all"><a href="contact.html" title="Contact Griff Build"><img src="assets/images/home-contact-image.jpg" alt="image-link contact griff build" class="fullimg"/><h2>Contact</h2></div></a>    

</section><!-- home links -->

<?php perch_layout('global.footer'); ?>

</div><!-- wrapper -->

one thing I notice is the invisible one always links to the last (3rd) project, If I ad a new project it then goes to the last (4th) project

Simon Clay

Simon Clay 127 points

Ok, spotted it. There is a missing '>' on the image tag.

<perch:before>  
<section class="slider">  
</perch:before>  
<div>  
<a href="/projects.html?s=<perch:content id="slug" type="slug" />"><perch:repeater id="images" label="Images" max="1"><img src="<perch:content type="image" id="image" label="Image" scope-parent="true" width="980" height="600" crop="true"/>" class="d-all t-all m-hide" alt="<perch:content type="text" id="alt" label="Description" />">
</perch:repeater></a>  
</div>  
<perch:after>  
</section><!-- /slider -->  
</perch:after>

Thanks you very much Simon

Fantastic Support

Give this man some points.

Regards, Dan

Simon Clay

Simon Clay 127 points

Hey, thank you Dan. I learn a lot from the forum myself, so it's good to get involved.

Good luck with your build.

I have similar project sliders in some of my websites, but I don't always want to feature every project in the slider. So I sometimes add a tickbox in the project template for 'Show on homepage slider'. Adding this to the project tempate:

<perch:content id="feature_in_slider" type="checkbox" label="Feature on Home Page Slider" value="yes" suppress="true" />

And then filter on that ID on the homepage:

<?php  
perch_content_custom('Projects list image', [  
'page'=>'/projects.html',  
'template'=>'project_carousel.html',  
// filter the featured projects
'filter'=>'feature_in_slider',
'match'=>'eq',
'value'=>'yes',
]);  
?>

Even better, sound like a good feature, will add it in

Thanks again