Forum
Navigation Groups
Is there away to allow the admin to select the appropriate navigation group for different groups of 'products' using a generic 'product' page template?
Is there away to allow the admin to select the appropriate navigation group for different groups of 'products' using a generic 'product' page template?
Hi Nick,
Categories sound more appropriate to me here. You could have the admin add them to different categories and use
perch_shop_products()
to filter by category.HI Hussein,
Unfortunately I'm not (currently using shop) I guesss what I was asking was whether its possible to pass a variable (the name of a navgroup) into the perch_pages_navigation array?
e.g. 'navgroup' =>'variablename',
You could do this by creating a custom field type for nav groups
I think this might be a little out of my league! As I'm a designer rather than a programmer. Is this something that you have done yourself?
Do you create a new page for each product? If so, it might make sense to have the admins perform this through the page's settings.
Hi Hussein,
The products are buttons. Currently they are made out of three different materials. The are between 2-8 different styles/designs made in each material. Currently I have one 'product' template that consists of a main content area which displays the buttons of a given style/design and a sidebar in which I want to show the styles available made from the same material. I thought I could do this by asigning a 'style/design' to a navigation group based on its material at the point of creating the page. However I don't know how to allow the navigation group to be swapped out. As its set in the array of perch_pages_navigation() in the template.
I currently got around this by creating page templates for each material, but this doesn't strike me as being very efficient and it also doesn't allow the admin to add new products made of a new material without first having to create a corresponding page template.
So my first though was is it possible to pass a variable into the array for the navgroup name?
You certainly can use a variable here as long as it's a string.
How you set the value of
$navgroup
can be done in different ways. If editors select the material on the product edit form, you probably want to use the value of that field.Can you show us your template?
Hi Hussein, Sorry for the detail, I'vedbeen trying to figure this out… with no joy.
The variable I'm trying to use as the value for $navgroup is set in the region 'Pattern' that use the following template 'pattern-sample.html' and is the value of the 'catSlug'
You are using a self-closing
perch:categories
tag, so yourperch:category
tags here don't output anything. Useperch:categories
as a pair tag instead like so (removed HTML for clarity):To get the value of
catSlug
on yourpage.php
(assuming you are using a single-item region):$pattern_array
would containcatPath
, but notcatSlug
.Option A: find
catSlug
from thecatPath
string:Option B: you can create a template
templates/categories/category_slug.html
and useperch_category()
to getcatSlug
.templates/categories/category_slug.html
:page.php
:Now you can output the region and navigation in whatever order you want.
page.php
:Hope this helps!
Hussein, incredible! Perfect. You're a star thank you.