-2

So I've done some pretty hacky things with Drupal, one of them being for simple data requests.

For example, say I have a simple form that asks for a registration ID number. This ID number is saved in a non-Drupal table in the same database. All I want my script to do is return whether or not that ID number is valid or whatever operation, but all I need to return is a string of "true" or "false" on an Ajax call that is called when the ID form field is blurred.

We don't have access to modules, so just adding in our own isn't an option, and we run on a multi-site environment, so adding a php file to our themes folder ends up becoming a terribly long string.

One thing I have done in the past is just create a new basic page and then use a php script in the page area to die("true"); but that always just feels so hacky.

My end goal would be to find some way to use drupals router and just print something without building a whole page around it, and I'm not exactly sure how I would be able to go about that.

Edit: also sometimes when I die("some text") in a basic page in Drupal that "some text" will appear in every page in the footer, even on pages where it shouldn't even be getting anywhere near the die("some text"); line. Why does this happen in Drupal?

closed as unclear what you're asking by kiamlaluno Jun 12 '15 at 4:46

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

3

My end goal would be to find some way to use drupals router and just print something without building a whole page around it

Assuming your question is "how do I do that?", then it's very easy.

Just don't return anything from your page callback, print it instead:

function my_page_callback() {
  echo 'This will print to the buffer, but not invoke the page theme wrappers';
  drupal_exit();
}
  • Of course Drupal has a function like that. I just never thought of what it would be called to look it up. On a similar note, is there any way to load Drupal themes thru a bootstrapped version of Drupal? For example if I wanted to use the Drupal theme but have an mvc framework running for some type of admin interface for a registration form? Again, hacky, but without access to modules it makes it hard to do things the Drupal way, at least until d8 gets out of beta and we can start using it in prod. – Kirkland Mar 23 '15 at 11:50

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