1

I am currently experimenting with knockout.js so i can make views output more dynamic.

I know React and angular among other newer frameworks are recommended but i do not want to create single page apps or have a separate built app with a fully headless Drupal.

Currently i am constructing my views as normal so the user doesn't have to do anything new. I then rewrite the results so i can add the required knockout.js functionality. For example I can add local filtering options, local cached data, dynamically update portions of the page all without ever making additional requests to the server. Most of the functionality works 100% in the users browser unless i request more data.

I am currently looking at it to make a POS "point of sale" built on top of Drupal commerce module. The idea behind this is to make it almost 100% offline first and fully dynamic.

My question is, generally does anyone have experience with augmenting views like thiss and if so what frameworks did you use ?

4
  • React or Angular aren't solely for making SPAs. KnockoutJS looks dead. Anyway we build decoupled things with React all the time and this is pretty straightforward, create Views with URLs and exposed filters. A POS is well outside of the scope of this site, but it's doable (we did it in 2008 with Ubercart and jQuery).
    – Kevin
    Jul 3, 2022 at 23:12
  • @Kevin thanks for the reply. If I understand correctly if I used react or angular I would still need to create a fully decoupled app. I would not then be able to let users of drupal create custom views etc. Jul 4, 2022 at 1:36
  • You can mix it into Twig templates, it does not have to be entirely decoupled. Even if it were 100% decoupled, the View is being accessed by its URL anyway by JS where its response would be returning JSON.
    – Kevin
    Jul 4, 2022 at 1:37
  • I regret this but I vote to close this question as not confirming to forum rules, as it is asking for opinion-based recommendations.
    – cilefen
    Jul 4, 2022 at 3:03

2 Answers 2

1

React is reasonably easy to get started with. It's easy to add pieces of React onto an existing site; you definitely don't need to make a completely decoupled app.

I've built a few React frontends for views and it was pretty easy once I learned the basics of React.

For an easy way to get started, see this tutorial on how to integrate React into an existing app.

For more information, see this curated list on getting started with React and Drupal.

For an example of a module that integrates React, see React Comments, which adds a React UI to standard Drupal comments.

0

The quickest way to do this is take your view and create a new display type of "REST export" if you don't see this option you will need to enable the core "RESTful Web Services" module.

this gives you a new toy as you can then deliver the data via rest endpoint to any "front-end" page using whatever js library you want.

all you need to know how todo is create a custom module, with a custom controller (to make the page) and provide a template for that page and add js to that page

(see https://www.drupal.org/docs/drupal-apis/routing-system/introductory-drupal-routes-and-controllers-example to do that ^^^)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.