Jump to content

Page/category system


Gast

Recommended Posts

I have a simple page system for a content management system where you can make a page with the parent id of 0 (ie. a top level page), and then make other pages underneath using the parent page's ID as that page's parent id (if that make sense). This is what I mean:

Page 1 (parent id: 0, id: 1)
[blockquote]Page 2 (parent id: 1, id: 2)[/blockquote]
[blockquote]Page 3 (parent id: 1, id: 3)[/blockquote]
[blockquote]Page 4 (parent id: 1, id: 4)[/blockquote]
Page 5 (parent id: 0, id: 5)
Page 6 (parent id: 0, id: 6)
[blockquote]Page 7 (parent id: 6, id: 7)[/blockquote]
[blockquote]Page 8 (parent id: 6, id: 8)[/blockquote]
[blockquote][blockquote]Page 9 (parent id: 8, id: 9)[/blockquote][/blockquote]
[blockquote]Page 10 (parent id: 6, id: 10)[/blockquote]
Page 11 (parent id: 0, id: 11)

Like that for example. Now each page is stored in the same table in the database. I can fetch all the results easily, by fetching all pages with the parent of 0 to display differently as they are top level pages, and then inside the while() loop used for that do another while() loop for each other page.

However I don't want to do loads of loops inside each other as I dont want to limit the amount of levels a page can go down. Is there a way to just fetch all pages under the right parents in one go?

TIA

Niall
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.