Forum

Thread tagged as: Question, Problem

Perch Pages Navigation from other pages

Hi, I've setup a few product pages (using perch pages) and I am using perch_content_custom to display them on other pages but I'm having trouble linking to the actual page from the other page.

heres how I'm calling it on my page, all displaying fine

        <?php
perch_content_custom('product', array(
    'page'=>'/products/mechanics-of-fluids/*',
    'template'=>'product-listing.html',
));
?>

and here is my template for displaying it.

<li>
        <img src="<perch:content id="product-image" width="258" height="167"/>" class="product">
        <p><perch:content id="product-code" type="text"/></span> - <perch:content id="product-name" type="text"/></p>
        <a href="<perch:pages id="pagePath"/>">View Product</a>
    </li>

The links don't work, I'm not sure I'm using the the correct format.

I've tried using a navgroup template, but I'm having issues drawing out the content to use (i.e images and text) and I don't really want my client to have to add an image twice (once when setting up the page and once when defining content on the region.

Any help would be awesome

Nik

Nik Gill

Nik Gill 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Use:

<perch:content id="_page" />

Excellent, spot on cheers.

While in the same navigation mode I'm creating a more standard navgroup.

I have category pages... and then product pages and I'm having a little trouble.

The main category page needs to show the sub-category's in the nav, which I have accomplished using the following code. This is fine and works well, just showing the sub-pages of the main section parent.

<?php perch_pages_navigation(
    array(
        'navgroup' => 'mechanics-of-fluids',
        'template' => 'right-menu.html',
        'levels'=>'2',
        'from-path'=>'/products/mechanics-of-fluids',
        'from-level'=>'2',
    )); ?>

for the sub-category pages and the product pages in that category, I want to show just the products in these categories, which I had hoped I could show like so;

<?php perch_pages_navigation(
    array(
        'navgroup' => 'mechanics-of-fluids',
        'template' => 'right-menu.html',
        'levels'=>'3',
        'from-path'=>'/products/mechanics-of-fluids',
        'from-level'=>'3',
    )); ?>

This outputs the product... but also it's parent and also the other sub page

Is this possible... or am I being over hopeful, I'd hoped not to have to set a master nav group for a section and then a second nav group per subsection

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you reduce levels to 2 does that exclude the sub page?

Yeah, that excludes the sub page (the product) and leaves me with the same result as the first snippit

What I want is to exclude the sub pages and just leave me with the product - which I thought should be at level 3.

'include-parent'=>false doesn't seem to have any effect either false or true

Ideally I just wanted to show the products which are sub pages of their parent

Drew McLellan

Drew McLellan 2638 points
Perch Support

What if you set from-level to 4 ?

Drew McLellan

Drew McLellan 2638 points
Perch Support

(All I can do is guess at what settings to try - I have no mental model of what your site looks like.)

yeah, that doesn't do anything either

Totally appreciate how difficult this is for you to guess at... I'll see if I can break it down.

In the page structure I have

  • mechanics-of-fluids (section leader page) - this is inside a top level folder called 'products'
  • Fundamental Hydraulic Studies (sub category and sub page of the above)
  • productpage.php (product page and sub page of above page

Basically three levels of pages

Ideally, I want to isolate and show only the products of the sub category on both the sub category page and the product page but I'm seeing the product, the sub category page and another sub category page on the same menu.

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you use no option and just output the nav group, is everything correctly nested?

yeah, it seems to

alt text for image

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are they nested? They don't look nested.

To be honest, I'm not sure... this is how they appear in Perch

alt text for image

Drew McLellan

Drew McLellan 2638 points
Perch Support

In the nav group, right? If so, yes that looks good.

Yep, those are all covered by the same navgroup

i.e when I'm on the Fundamental Hydraulic Studies page, I just want to see it's sub pages listed in the menu and no others and when I'm on the Hydraulic Applied Studies page, I just want to see the sub pages from that.

Is that possible? or am I trying to attain something which can't be done at the moment?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yep, those are all covered by the same navgroup

Not covered by - is that a screenshot of the navgroup itself? You do have them nested in the navgroup, right?

Right no... this is the navgroup... thought it would nest them automatically. What have I done wrong?

alt text for image

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to nest them.

Ok, I think this is where the problem is... I'm not totally sure how to do that.

Do I have to specify a second template in my navgroup php? like this

perch_pages_navigation(array(
    'template' => array('item.html', 'subitem.html')
));

or should this be something set in the admin.

I've done an fairly extensive search in the perch docs and couldn't find much that specifically related to nested navigation,

Really appreciate your help, I know it must be frustrating. This is the deepest I've ever had to go with nav groups and I'm a little out of my comfort zone (in a good way though)