1

I'm writing a module that displays graphs based on a selection of arguments (an array with items to display, a daterange and some other stuff). This results in a long and ugly url.

Is there a way to get the arguments to the page with the graphs without putting everything in the url for that page? I'm looking for something that can keep temporary variables with a short reference that I can pass in the url, but haven't been able to find anything.

I'm using Drupal 7.

2 Answers 2

1

You could use form submission or cookies to store values, but neither of these are a particularity good ideas.

I would recommend (if you don't like the URL showing) using AJAX to retrieve/update the graph. You still have the ugly url but you hide it inside the ajax request.

So your module displays

/mypath

but the request could be

/mymodule/displaygraph/x/as/32432/s///

3
  • I am already using AJAX to get the actual graph data from a (Drupal) webservice. But I need some way to get the parameters selected by the user across to the page that displays the graph. Would you suggest to submit those via ajax and do a page reload?
    – Whiskey
    Aug 8, 2011 at 12:05
  • In this case, why not just use ajax to bring back the graph, rather than a page with it embedded. Aug 8, 2011 at 14:17
  • I could do that, but the layout of that page does not allow for the graph.
    – Whiskey
    Aug 10, 2011 at 7:00
0

The solution turned out to be a simple one: put the urls with an index in the session, pass the index as an argument to the next page and once there lookup the url again in the session.

4
  • 1
    Of course, this solution means that you can't use the same URL to always arrive at the same graph. That's the tradeoff.
    – rfay
    Sep 1, 2011 at 20:05
  • Agree with rfay, this precludes the ability for a user to send the graph page to a friend via hyperlink, for example.
    – Entendu
    Sep 1, 2011 at 20:17
  • True, but in this case that is not a problem. But well pointed out, thanks.
    – Whiskey
    Oct 22, 2011 at 18:17
  • you could use ctools object cache if you don't want to fool around with creating your own index: uppitywis.org/help/ctools/object-cache
    – acouch
    Jan 6, 2012 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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