Forum

Thread tagged as: Question, Problem, Configuration

detail.php portfolio items in the sitemap?

I have a lot of portfolio items which I have set up and work great, to show in the sitemap, but they dont with my current setup.

My portoflio items are configured through a details.php page, just like in the 'Perch portfolio items with categories tutorial'.

Here is my sitemap.

<?php
header('Content-type: application/xml');
include('perch/runtime.php');
echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">';

// site pages
perch_pages_navigation(array(
    'template' => 'sitemap.html',
    'flat' => false,
    'hide-extensions' => true
));

// blog posts
perch_blog_custom(array(
    'template' => 'sitemap.html',
    'paging'   => false,
    'count'    => 9999,
    'sort-order' => 'ASC'
));

echo '</urlset>';
Kieran Hunter

Kieran Hunter 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can add them in the same what you display a listing in your portfolio section - just like you've already done with Blog.

I got it working!

I made a 'portfolio_sitemap.html' template in the standard templates/content folder.

<url>
<loc>https://localhost:8888/detail/<perch:content id="slug" for="title" type="slug" /></loc>
</url>

Then included this in my sitemap.php like so

<?php
header('Content-type: application/xml');
include('perch/runtime.php');
echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">';

// site pages
perch_pages_navigation(array(
    'template' => 'sitemap.html',
    'flat' => false,
    'hide-extensions' => true
));

// blog posts
perch_blog_custom(array(
    'template' => 'sitemap.html',
    'paging'   => false,
    'count'    => 9999,
    'sort-order' => 'ASC'
));

// portfolio posts

perch_content_custom('Portfolio', array(
  'template' => 'portfolio_sitemap.html',
));

echo '</urlset>';