Forum

Thread tagged as: Question

Categories sample files

Hi,

Watching this:

https://docs.grabaperch.com/video/tutorials/techniques/portfolio-with-categories/

Wondered if the files you show in the video are available for me to work from as it's easier than we keying in the code from scratch - easier for me to get my head round things this way.

Thx.

Andrew Areoff

Andrew Areoff 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't think so with this one, but there's not really a lot to enter.

Ok, just having trouble working out exactly what's in the code from the small video.

Drew McLellan

Drew McLellan 2638 points
Perch Support

The code is in the transcript - can you not copy and paste it?

So far, I'm having real trouble getting the categories to work.

I've added the main files from your video and I am getting it to work in the CMS but not outputting pages at the moment.

If you are stuck, I've got a working version here, some slight changes to the tutorial because I renamed one of the templates but might help

Appreciate that Clive. How might I be able to grab a copy of the templates?

I can post the relevant template here? Which template are you stuck with?

It's basically all of the ones in this video:

https://docs.grabaperch.com/video/tutorials/techniques/portfolio-with-categories/

Not sure I need all of them but most.

Otherwise I must be doing something else wrong as not getting an output on the page.

OK, here is portfolio_listing.html template

<perch:before>
    <ul class="modules">
</perch:before>

<li class="module"><a href="/detail/<perch:content id="slug" for="title" type="slug" />">
  <img src="<perch:content id="listimage" type="image" label="Image for Listing Page" width="300" height="200" crop="true" />" alt="<perch:content id="title" label="Title" required="true" title="true" />" />
  <h2><perch:content id="title" label="Title" required="true" title="true" /></h2></a>
</li>
<perch:after>
    </ul>
</perch:after>

and this one is list_detail_portfolio_item.html (in the tutorial, this is called portfolio_item.html).

<div class="portfolio-item">

    <h1><perch:content id="title" label="Title" required="true" title="true" /></h1>
    <perch:content id="desc" type="textarea" label="Description" markdown="true" editor="markitup" />

    <ul>
        <li><strong>Client:</strong> <perch:content id="client" type="text" label="Client" required="true" /></li>
        <li><strong>Year:</strong> <perch:content id="year" type="text" label="Year" required="true" /></li>        
    </ul>

    <perch:repeater id="gallery" label="Images for Slideshow">
        <perch:before>
            <div class="galleria">
        </perch:before>
           <a href="<perch:content id="image" type="image" label="Image" width="1024" />"><img src="<perch:content id="image" type="image" label="Image" width="200" height="100" crop="true" />" data-big="<perch:content id="image" type="image" label="Image" />" data-title="<perch:content id="imagetitle" required="true" title="true" label="Image Title" />" data-description="<perch:content id="imagedesc" type="text" label="Image Description" required="true" />" />         
           </a>
           <perch:after>
            </div>
          </perch:after>
    </perch:repeater>

    <perch:categories id="Work" label="Type of work" set="work" required="true">
  <perch:before>
    <h3>Our work on this project</h3>
    <ul class="tags">
  </perch:before>
      <li><a href="/category/<perch:category id="catPath" />"><perch:category id="catTitle" /></a></li>
   <perch:after>
      </ul>
    </perch:after>
    </perch:categories>
    <perch:categories id="Sector" label="Sector" set="sector" required="true">
      <perch:before>
      <h3 class="clearleft">Sectors</h3>
      <ul class="tags">
      </perch:before>
      <li><a href="/category/<perch:category id="catPath" />"><perch:category id="catTitle" /></a></li>
    <perch:after>
    </ul>
    </perch:after>
</perch:categories>

   <perch:content id="listimage" type="image" label="Image for Listing Page" width="300" height="200" crop="true" suppress="true" />
   <perch:content id="slug" for="title" type="slug" suppress="true" />
    </div>

and this is category_single.html

<h1><perch:category id="catTitle" type="smarttext" label="Title" required="true" /></h1>
<perch:category id="desc" type="textarea" label="Description" editor="markitup" markdown="true" size="s" />

I think these are pretty much the same as the tutorial video but I may have changed image sizes.

Thank you very much for the code.

It's got me a lot further.

The Listing page is working.

But when I click through to the detail page I'm getting an error that the page is not found.

There is a rewrite rule in an .htaccess file and this is needed for the detail page link to work, it's mentioned in the tutorial and video. If you create the same rule, as long as your server supports URL rewrites, the detail page link should work.

This is what I've got in the .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^detail/([a-zA-Z0-9-/]+)$ /detail.php?s=$1 [L] </IfModule>

But doesn't display the detail page.

That looks correct.

If it were me, I would check the server supports URL rewrites, check the detail.php page is in the correct location, then enter the actual detail.php?s=slug URL and check that works.

.... then check my code again.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What URL are you attempting to view the detail page at, and what result are you getting?

At the moment, the rule you have is looking for a URL like

/detail/abc-123

and rewriting that to

/detail.php?s=abc-123

At the moment the listing page call this url:

/perch/detail/slug-name-here

it's not putting a .php or query string at end. That's probably because I have the entries in my .htaccess file.

Drew McLellan

Drew McLellan 2638 points
Perch Support

The files shouldn't be inside your Perch folder.

Ah Ok.

So I've got my perch install in a folder /perch/

I've put my website pages in /perchtestsite/

Added: <?php include('/perch/runtime.php');?> to the top of the pages I want to use in Perch.

Empty page and doesn't show up in Perch to add content too even after refreshing the web page in browser.

Added: <?php include('/perch/runtime.php');?> to the top of the pages I want to use in Perch.

Your website folder lives beside the perch folder, correct? Then you want to put ".." in front of "/perch/runtime.php".

<?php include('../perch/runtime.php');?>

Thanks. Got that up and running I would have thought /perch/runtime.php would have works but I won't argue.

Right, all back up and running but still the issue remains that when I click through from the listing page to the detail page I get a not found error.

The url is something like this:

https://www.xxx.com/perch/detail/slug-name-here