2

I have a feature on my Drupal7 site where users can store a list of personal stock symbols (NYSE, NASDAQ, etc) and then do different actions on that list; quote, chart, etc. These lists are private to each user. For the first iteration, using a custom module, I've stored them in a custom table after the user enters them using the Drupal Form API. The form has a text box for list title, and a text area for entering symbols separated by space or comma. They can have multipe lists by clicking a 'add more' button. The data is stored in a flat structure of "-list_title1 sym1 sym2... -list_title2 sym1 sym2..." It is then split out for use in the UI. Some users have more than 300 symbols.

For the second iteration I would like to be able to store these symbols so that they can be referenced individually (deleted or added, notes about symbol) and the lists sortable. I would like to be able to utilize Views and features like Draggable_views so that the symbols could be re-orderd in a list. I would like users to be able to add symbols to their list from other content eg: news, trending symbols, symbol lookup.

There's a reference to $user->data in this Drupal8 article but I couldn't find more details on it. https://www.webomelette.com/storing-user-data-such-preferences-drupal-8-using-userdata-service The user_save api may work but I'm not sure how you would store this two-level data structure. https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_save/7.x

I could not find any contrib modules for storing this data privately other than Profile2 which I don't think would work for this kind of content. I'm looking for Drupal APIs to store this data on a per-user basis.

2

You could use ECK and link it to the user using Entity Reference. You'll need to some small custom coding to auto fill the entity reference field with the logged in user's id. Better yet, you can use Rules for a no code solution to autofill the entity reference with the logged in user ID.

Here is a video on ECK and for entity reference.

  • 1
    interesting ... why not add the custom code also? – Pierre.Vriens Jun 9 '18 at 13:04
  • @Pierre.Vriens sorry, my brain was stuck in D8 mode. – No Sssweat Jun 10 '18 at 5:01
  • was, or is still? – Pierre.Vriens Jun 10 '18 at 5:09
  • 1
    was, forgot that Rules existed. – No Sssweat Jun 11 '18 at 9:45

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.