Building a Nesting Pages and Routes from the Divhunt CMS

Hi there!

I need to build a nested structure of CMS items from the Divhun CMS. I am looking for ideas on structuring the Collections and the pages. I have been testing and have one picture of how to get some of what I need to do. However, it is not ideal, and I think there is a better way I haven’t figured out yet!

Here is a general example:

I want to create a list page with a list of categories.

Once a user clicks on a Category, they are taken to another list page or all the subcategories. Finally, clicking on a CMS item in the category brings you to the item as a single page/post.

The route should follow the pattern: /categories/:subcategory/:item.

And if I can figure out how to do that, then creating a Breadcrumb component for those pages should also be pretty straightforward.

Here is a specific example of how this may look like in practice:

Category → US States (FL, AL, NY …)
Subtagery → Counties (Subcategory)
2ndLevelSubcategory → Cities

Let’s take Florida, Miami-Dade County, and “North Miami Beach” as examples.

North Miami Beach page route: /fl/miami-dade/north-miami-beach
North Miami Beach page breadcrumb: FL > Miami-Date > North Miami Beach


What I have come up with so far:

Since I have not been able to figure out how to get the value of the dynamic portion of the route, the only thing I can think of is very clunky and a nightmare to maintain

Create 50 pages (one for each state) and create a collection with the information for the cities; list the State of the City as a Field and Filter the collection for that State on each of the State pages.

Of course, this solution doesn’t even consider the Counties. It’s impractical to create a Page for every County.


I know there is a better way! Please help me see the light :smiley:

Thank you in advance! :slight_smile:

2 Likes

I don’t know how much of a coincidence this is, but that’s exactly what I’ve been trying to accomplish in the last couple of days. Nested CMS is probably coming soon and that would solve a lot of issues.

The only feasible and straight-forward way is to create CMS pages directly without (page-> souce). This is will allow us to create all pages for a CMS collection. For example all your categories ( let’s say Cities) once you create a CMS page will all have xyz.com/cms-name/citie1

Once this is done, you can have a relation between your cities and zipcodes, each city will have a bunch of zipcodes witch are CMS page too… you got the point

you got the point. Once this is done the rest should be easy to fix and get done.

But with that said, Divhunt has come a long way and as of right now is better than 99% of anything else out of the market, so we can expect that very soon

@Studio350

Divhunt dynamic pages and routes are very flexible, so you can most likely achieve this.
We lack tutorials for CMS :frowning: that would help you a lot.

You can use variable $route->get(‘subcategory’) to get value from route. And then you can use function to replace - to space.

$route->get('subcategory')->replace('-', ' ')

This is for sure possible, just it’s hard to explain without proper tutorial. We will try to do tutorial in next few days.

1 Like

Thank you, @dejan. I will keep hacking away at it :).

I will post here if I figure it out before the tutorial is ready.

1 Like

Hi @Studio350 ,
Have u figure this out?