[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 121
  • Last Modified:

Dynamic Selection?

Laptop Buttons
Got a use case where the User selects a laptop button, and the specs appear on the right.

So the requirements are:

1) Dynamic data is pushed to the sidebar
2) The data (laptop specs) are stored in the Drupal database

And longer term..

3) The data (laptop specs) might come in via web service as more laptop buttons are offered.

What's the best approach for #1 & #2, and what technologies should I consider for #3?
0
sandshakimi
Asked:
sandshakimi
  • 2
1 Solution
 
oliverpoldenCommented:
Drupal has an api for Ajax forms. You would make the buttons submit buttons and when that is clicked it would do a callback to retrieve the HTML or JSON which is used to replace the sidebar.

So you would create your own custom form that defines the buttons. You would need a menu item callback to process the button clicked and return your data for the sidebar and you would beed to create a placeholder in the sidebar for you to replace.

This should be possible with no JavaScript if you return HTML from your callback.

See here for how to create an Ajax form:
https://www.drupal.org/node/752056

Kind regards,
Oliver
0
 
oliverpoldenCommented:
Going forward you could make the request for data in your callback function or do it all in JavaScript however it would be best for the data to be stored when you add a laptop. That way you can still display the data if the other site or service is down. There is the amazon associates module which I think works in this way so you could have a look at that code. Essentially when a node is saved, it requests the data and saves it as extra fields in the node.
0
 
sandshakimiAuthor Commented:
How much of this is done via the GUI versue custom module?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now