Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only for info: using this with Drupal 9 and nodes, with node entity reference field, permalink - some additional ideas welcome. #679

Closed
therobyouknow opened this issue Apr 26, 2022 · 0 comments

Comments

@therobyouknow
Copy link

therobyouknow commented Apr 26, 2022

Thank you for this wonderful modern, good Developer Experience (DX) js library for tree display and exploration.

This ticket is mainly an informational one to outline how we have been already using jqtree with Drupal 9 successfully. Some input on combining permalink display with exploration welcome.

Outline

I've built a drupal 9 project with 10s of thousands of Drupal nodes, where each Drupal node has a field referencing its parent. This enables a deep and wide hierarchical tree to be modelled in data.

Data modelling leading to using Drupal nodes referencing their parent node, with jqtree for display of deep tree

In our problem domain, the concept of Drupal's hierarchical taxonomy can present itself as the apparently obvious choice. But in the end, nodes were chosen.

This is because:

1 - in data modelling of Drupal concepts, the tree was about the nodes themselves rather than a separate set of terms describing them, for one reason not to use Drupal taxonomy entities and bundles

2 - Moreover, taxonomy terms, in terms of data modelling ought to tag more than one piece of content. In our case, each node was unique and therefore not more than one node shared a Drupal taxonomy term.

3 - Thirdly and related, I also believe that generally a Drupal taxonomy should contain a relatively small number of terms, e.g. in 10s, not several 10s of thousands. Several out-of-the box drupal taxonomy hierarchical tree solutions in the forms of modules were considered, but these did not scale well to 100s of thousands, particularly because of the sheer number and the solution attempted to render all of them at once.

So the outcome of the above evaluation of existing solutions, was to develop a custom solution. In-page interactivity (i.e. without having to load the page on each click) was needed, and I did research on js tree based libraries. jqtree emerged from that research as the best candidate, because of it's clean modern documentation and abundant real-life examples. Thank you.

I should make the distinction between the concept of Drupal taxonomy and taxonomy as a general definition. Taxonomy as a general definition applies in our case, for modelling data related to biological/biodiversity of species taxon/taxa hierarchy. It's just that we are choosing not to use Drupal's taxonomy structure entity to model them, but instead rather, Drupal nodes, for the reasons already outlined above.

In our custom Drupal 9 module, endpoints defined in routing.yml, along with Controller class methods, provide the endpoints urls with parameters that jqtree defines as needing to show this tree and to click to expand.

Also in the custom module, code has been added to respond to an event click on jqtree node for displaying of information about the Drupal node, next to the jqtree. The code also changes the url in the browser ( https://stackoverflow.com/a/3503206/227926 ) to provide a permalink.

Another endpoint implementation expands (opens) the jqtree to that node id in the permalink url. The Drupal side implementation of this endpoint uses server-side recursion function in the custom Drupal module to build the required jqtree json, to return to jqtree from an endpoint call, starting from the node id in the url of the child, successively enclosing this in js obj structures.

Extension ideas of our project: Next idea: Merging permalink expand tree functionality with expanding other parts of the tree - suggestions welcome!

The permalink based expansion of the jqtree could be expanded so that browsing other levels and expanding those of the same tree is possible. I think this would be achievable by generating sub tree json of those expansions returned by an endpoint triggered by an expand event.

Would welcome any thoughts on the above extension, particularly in terms of which jqtree events, calls, functions to use. I will be researching this too and would aim to contribute back here. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants