Dynamic Selection?

Posted on 2014-08-27
Last Modified: 2015-06-02
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?
Question by:sandshakimi
    LVL 9

    Expert Comment

    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:

    Kind regards,
    LVL 9

    Accepted Solution

    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.

    Author Comment

    How much of this is done via the GUI versue custom module?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
    Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now