Jump to content

How to use existing subpages as categories?


totoff
 Share

Recommended Posts

hi forum,

as this is quite a complicated question, i'm not sure if my english will be sufficient or not. i'll do my best, but please be forgiving ... :rolleyes:

i'm about to relaunch my portfolio page with processwire. i would like to have some sort of category system to show prospects only references from a given service they are interested in. in other words: they should be able to filter the page "references" by category while every category is a service i offer.

i could easily go and make a site tree like /categories/service-xyz (like ryan does in the blog profile) and use it for the purpose of filtering my references. but i don't like this idea, as i already have a page were my services are listed /leistungen/ with detailed subpages /leistungen/service-xyz. that means: my "category system" already exists and i would like to use it for the purpose of categorizing my references instead of going and make an extra section categories.

well, but in this case i need to show different views under /leistungen/ (services) depending on how the visitor arrived on this site. in case the visitor clicked on a category for my references, the page must list all references filed under this category. in any other case, it must give an overview over the services i offer. this is, where i'm stuck. i have no idea how one could do that or even if my approach is efficient and a good one. maybe it's just better to set it up with an extra section /categories?

appreciate your feedback or ideas for a solution. and sorry again for my english. really need to take some lessons after being out of shool for some years ...

best, christoph

Link to comment
Share on other sites

Hi Christoph,

Your english is very good, don't worry. Not sure I understand exactly what you want to do but serving "views" is relatively easy to achieve by allowing urlSegments in the template settings.

You can then serve different views dependent on the urlSegment (which you will append to your "a" tags).

Eg:

if ($input->urlSegment1 == "category") {
include("./categories.inc");
}

You can then create categories.inc where you will test for the urlSegment2 and show the relevant category.

So if your link goes to "blog/category/news", your template would help you output just the pages linked to the "news" category.

// categories.inc
<?php
$name = $sanitizer->pageName($input->urlSegment2);
$category = $pages->find("template=category, name=$name");
$articles = $pages->find("template=article, category=$category");
?>

Hope this makes sense, if not I can try and show you in more detail

  • Like 3
Link to comment
Share on other sites

many thanks for your quick reply onjegolders! i think that points me in the right direction. have to figure out how i'll make it in detail, but serving different content depending on the url segment could be the solution.

maybe i'll come back with more questions once i have played around with this for a while.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...