⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Nested categories in n_n relations



jgalak1

jgalak1
  • profile picture
  • Member

Posted 02 July 2017 - 21:22 PM

Wondering if there's any good way to do this, but here's hoping.  Found some really old threads that might be relevant, but nothing since like 2014.

 

In the current version of GC, is there any way to have an n_n relationship where one side is a tree structure, and have that fact visible in the Edit box?

 

Here's the relevant table structure:

 

Pages

  PageID - Int, AI, primary index

  PageName, etc....

 

Tags

  TagID - Int, AI, primary index

  TagName - varchar

  ParentID - Int

 

Foreign key constraint setting Tags.ParentID to refer to Tags.TagID.

 

PageTag

  PageID - Int

  TagID - Int

 

Foreign key constraint setting PageTag.TagID to refer to Tags.TagID.  Foreign key constraint setting PageTag.PageID to refer to Pages.PageID

 

The CRUD is set to display Pages.

 

$crud->set_table('Pages');

$crud->set_relation_n_n('Tags', 'PageTag', 'Tags', 'PageID, 'TagID, 'TagName');

 

The idea is that I can tag pages with multiple tags, but the tags themselves have a hierarchical relationship.

 

Like:

 

Tag 1

   Tag 1.1

   Tag 1.2

   Tag 1.3

Tag 2

Tag 3

  Tag 3.1

 

Any of the tags, 1, 1.1, 1.2, 1.3, 2, 3, 3.1  are legitimate things to tag a page with.

 

Everything works fine, except that in the Edit view, the hierarchical relationship isn't visible.  I'd like it to show the user which tags are subcategories of what.

 

Is there any easy way to do this?

 

Thanks.