Jump to content

Input Field Type for multi-level deep 'Categories'


biotech
 Share

Recommended Posts

Hello everyone,

Brand new to PW and after few hrs loving the potential and control but hating my state of ignorance :)

I understand that page hierarchy is one way to organize (categorize) content so I am trying to build Categories for use in a Blog type of content.

So far, I have made a page called "Categories" with simple just "title" field and created children records (subcategories).

post-435-0-59256200-1329612669_thumb.png

In my 'blog' I created a field called "categories" and used it to pull records from the page above.

However, any input field type I choose does not pull children records and only parents are shown.(i.e camping and photography)

post-435-0-63894100-1329612911_thumb.png

The only field type that is capable is "PageListSelectMultuple*" but unfortunately there is no way to prevent duplicated categories/pages to be selected.

Checkboxes would be my preference but not sure how to go about it all or what am I missing in the setup.

Thank you for your time.

O.T. but where would I find 'skyscraper site profile' to download?

Link to comment
Share on other sites

Hi, biotech and welcome!

Actually, despite you can choose a page twice or even more times using PageListSelectMultuple, after you save the page all the duplicated pages will be gone as it allows to have the same page only once.

Link to comment
Share on other sites

Thanks for the answer Slkrm, that is pretty sweet feature to know.

I still have some newbie questions:

- So is the approach above the way to go about making categories correct though?

- Is there no way to use checkboxes for categories (with subcats) like in WP?

PageListSelectMultuple is memorizing first time around but the tree expanding can get slow.

Thank you.

Link to comment
Share on other sites

- So is the approach above the way to go about making categories correct though?

Biotech, I think you can safely use this approach. Not sure though wether you need both categories and subcategories. If it's a personal blog I think it can be a little bit of overkill. I would just create one level of categories, and if it's not sufficient I would add tags. But it's my very personal point of view :) And if you are dealing with huge multi-user blog with a lot of articles, this structure is the way to go.

However, any input field type I choose does not pull children records and only parents are shown.(i.e camping and photography)

As for checkboxes. I think you might create a dedicated template and use it for your sub-categories aka pages. Then you could use an option in your field settings to set selectable pages by the template they use and not by their parent. Is it what you need?

I'm not sure how it's done in Wordpress, but I think you can have it even better with Processwire, because you can always code your own Inputfield the way you want or customize already existing.

PageListSelectMultuple is memorizing first time around but the tree expanding can get slow.

If you worry that PageListSelectMultuple can't handle big number of pages - just don't! I think Ryan could explanain how it's all optimized to work with hundreds or maybe even thousands of pages ;)

Link to comment
Share on other sites

Thanks slkwrm for hanging with me.

I am ok with simplicity of cats too but most of my 'blogging' users will be more familiar with true hierarchy of categories rather than pages. Even the concept of 'go to page called 'blog-categories' to edit categories' is a little different.

I think you might create a dedicated template and use it for your sub-categories aka pages

This could be the case but not sure where to start. What would that page need to output? Some text string or array or straight up html form with checkboxes?

Not much of a php guy, most of experience comes from ExpressionEngine and 'tag' based world.

Is 'skyscraper site profile' used in demo somewhere where it can be downloaded? Would love to see examples how some other concepts are done such as template breakdowns an includes, breadcrumbs, master-detail pages, pagination, logged in/out conditions, search composed of cats and custom fields etc. etc.

So much to learn :)

Thanks again.

Link to comment
Share on other sites

I am ok with simplicity of cats too but most of my 'blogging' users will be more familiar with true hierarchy of categories rather than pages. Even the concept of 'go to page called 'blog-categories' to edit categories' is a little different.

Well, maybe you shouldn't tell your users categories are pages :)

The page in PW is very close to a "node" consept in Drupal. Users, roles, permissions are actually pages. And having such a powerful tool like custom fields (aka fieldtypes) at your command you can create any kind of pages which can serve very different purposes going far beyond traditional usage. And thanks to great API you can get all the data from that pages' fields very easily.

I think you might create a dedicated template and use it for your sub-categories aka pages

This could be the case but not sure where to start. What would that page need to output? Some text string or array or straight up html form with checkboxes?

The key point here is to understand what are templates in PW. When I just registered here on forums I didn't quite uderstand what it was. I'll quote Apeisa's answer which he PM'ed me back then, 'cause it's short and comprehensive:

Template means two things in pw:
  • It is actual template file, normal php file which renders the output (usually output is just html page, but can be anything: json, xml... no limits here).
  • It is also "content type", so template has always fields that tell what kind of data page can have.

This is kind of simplification, but it makes very straightforward when building sites: you always know what files create the output (well, you can use same "template file" for different "templates" and you can actually use same fields for different templates [in P21 at least] so it is more flexible than that).

Using $page and $pages API-variables in your template file you can get and then output any data you want and the way you want it. PW doesn't output any markup (but in some cases it provides reasonable defaults, e.g. for pagination), so it's up to you what's on your page and how it looks.

I heard many good things about EE, but I'm not familiar with it. I think there are people here on forum with some EE background, who can draw some analogies or compare PW with EE.

After you've read all the documentation pages on the website, try to use forum search to find many ready-to-use recipes, since all the most typical questions has already been answered (try to request breadcrumbs, template, pagination etc.). Also I recommend you to add Soma's brilliant Processwire cheat sheet to your bookmarks, it will save you a lot of time.

Here is an interesting thread about some advanced tips regarding different aproaches of templates organization.

Also check out this thread, may be helpful as w(h)ell :).

P.S.: As far as I know Ryan can send you skyscraper site profile on request, try to PM him about it.

Hope it helps.

Cheers.

Link to comment
Share on other sites

Great answers Slkwrm. Biotech, thanks for your interest in ProcessWire. I only have the skyscrapers profile for PW 2.0 available. I can send it to you, but so much has changed since then that I'm not sure it's the best example anymore. I do plan to update it, hopefully soon. Just need to get a couple free hours to do it.

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...