Breadcrumbs not working (for Detail item)
Hi, I can't get breadcrumbs to work for a item detail page. Even when outputting dummy text.
breadcrumbs_test.html is within the navigation folders.
Appreciate any help!
.HTACCESS
RewriteEngine On
RewriteRule ^product/([a-zA-Z0-9-/]+)$ /admin/templates/pages/products-detail.php?s=$1 [L]
RewriteRule ^category/([a-zA-Z0-9-/]+)$ /admin/templates/pages/products-category.php?cat=$1 [L]
Page PHP
<?php
perch_pages_breadcrumbs(array(
'template'=>'breadcrumbs_test.html'
));
?>
Navigation Template
TESTESTESTS
<perch:before>
sdfgdfsgdfsg
<ul class="breadcrumbs">
</perch:before>
<perch:pages id="pagePath" />
<li>
<perch:if exists="perch_item_last">
<perch:pages id="pageNavText" />
<perch:else />
<a href="<perch:pages id="pagePath" />?s=<perch:content id="test" type="slug" />"><perch:custom id="pageNavText" /></a>
</perch:if>
</li>
<perch:after>
</ul>
</perch:after>
If you add debug to the page, what does it output?
I'm not sure navigation functions will work for you due to the unusual way you're rewriting your URLs directly into the templates folder.
Am using the same method as the Portfolio with Categories set-up ( https://docs.grabaperch.com/video/v/portfolio-with-categories/ ). i.e. Slug and redirection.
Is there a way the page hierarchy can be saved?
i.e. Pages:
The Perch Content item exists on the 'Lounge' page.
The breadcrumb should be:
Products > Chairs > Lounge
You can tell Perch what the page should be by using
PerchSystem::set_page()
Not sure how to get the ideal outcome with that?
The problem is that the detail page is not actually a page, it's just perch content, and it's not a sub-page of the page (i.e. Lounge) that the content exists.
Ok. How can I help you?
Would like the Perch Content items to be simulated as an actual page, a sub-page of where the Perch Content is saved.
Current: Products > Chairs > Lounge (Perch Content)
Would like: Products > Chairs > Lounge > Lounge-Name (i.e. Perch Content item). At least just for using Perch Breadcrumbs.
The problem with using a slug, even on the back of the Lounge page, is that the Lounge text is not linked within the breadcrumbs.
I.e. Products (linked) > Chairs (linked) > Lounge (not linked, because active page)
Why do these need to come from the navigation functions? Why not pass them into the template?
Am currently passing HTML breadcrumbs via the template however it's inefficient and repetitive for 100's of products.
Surely you just do it once for all products?
Nope, there are 4 primary categories, and around 10 sub-categories under each primary. So there are basically around 40 variants. Hence the Breadcrumbs would be perfect for automation.
Next best thing I can think of (if the sub-page simulation can't be done for perch breadcrumbs), is to create categories/sub-categories along with a breadcrumb HTML textarea. Then display the breadcrumb HTML in page via custom template if the sub-category is selected in item content. It just means the category/sub-category needs to be selected for every product, no huge biggie, better than the general textarea HTML method per item at least.
You don't have 40 pages all doing the same thing though? The logic can run through one central point.
One master page for summary and detail.
Same as the Portfolio with Categories set-up ( https://docs.grabaperch.com/video/v/portfolio-with-categories/ ). i.e. Slug and redirection.
Perch CMS pages as follows:
All the above are using the products-summary.php page
At the third level i.e.
Perch content exists as product-item. product-item may be 1 to 100+ products/items.
The product-item is displayed through the master page product-detail.php via slug.
Ok, great, so you just need to set the breadcrumb once, dynamically, not 40 times.
Yep, except can't get breadcrumbs working for the product detail page, because the item is from perch content, it's not an actual page, would need the item detail simulated as a page. I don't know how to get working.
Can you show me what you're trying and how it's not working? The solution here is to use the content, not just navigation functions.
How can I get the page hierarchy with links automatically into the content then? It needs to work like breadcrumbs.
Content exists on perch page Lounge: Products > Chairs > Lounge
What does
perch_pages_breadcrumbs()
output?Nothing, as per start of thread.