Jump to content

Another Category Question / Site Tree


thomasklaiber
 Share

Recommended Posts

I know there are a lot of category-topics on this forum already, but I can't find a solution for my problem.

I got the following page-tree:

Downloads

- Download 1

- Download 2

- Categories

-- Category 1

-- Category 2

--- Subcategory 1

---- Deeper Subcategory

-- Category 3

So categories can be really deep. Each download is assigned to one category only. And I would like to output it in my template like this:

Category 1

- Download 1

Category 2

- Subcategory 1

-- Deeper Subcategory

--- Download 2

But I can't find a good selection to do so.

Link to comment
Share on other sites

It all depends on how your pages are related to each other (i.e., besides ancestry). Do they share templates? How are you relating the pages; page reference fields? I am also wondering, if each download is assigned to one category only, then a download and a category seems to be pretty much the same thing, no? Unless there can be more than one download per category then I don't see the need for categories and downloads (e.g. Category 1 could contain download 1 and download 8 and Category 2 download 6 and download 7). A bit more info would help.. :).

By output in your "template" do you mean you want to create a nested list/menu in your template file as you've illustrated?

Link to comment
Share on other sites

Hi kongondo,

a download has the template "download"

and a category currenty has the default-template (basic-page) but could be changed.

In the download-template I set a field called "download_category" where I can select a single Page (the category).

And a Category could have multiple downloads.

And yes, the output should be something like a nested <ul> list .. like the Pagetree in the Backend of PW.

My first try was this:

$kategorien = $pages->find("parent=/kundenbereich/downloads/kategorien/");
foreach ($kategorien as $kategorie) {

    $downloads = $pages->find("template=download, sort=-date, sort=download_kategorie, download_kategorie=".$kategorie->name.", kundengruppe=".$user->kundengruppe);
    foreach ($downloads as $download) {
        ... 

But it doenst work well with the nested categories.

Link to comment
Share on other sites

For that to work, you would have to use some recursive function in order to go through every category and make a UL tree from them.

My question to you is: why do you want to output a massive tree of categories and list all downloads under each of them like you're trying to do in your code? :) It would make more sense to me if, depending which category you're viewing, it just shows the child category titles so you can click through to them as well as the downloads for the current category.

  • Like 1
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

×
×
  • Create New...