Posted by vstar-gdo on September 21, 2011 at 8:39pm
Hi,
I am using Drupal 6 and Services 6.x-3.0-rc3. I have one non-drupal website that calls my drupal site to get an index of some blog data from a REST server. I wrote a custom 'blog' resource to return the appropriate data and I have this working if the non-drupal site asks for xml or json... it returns the correct data in the correct format.
But now the non-drupal site would like to have a snippet of html returned instead of json or xml. Does anyone know how to do this? I was hoping I could use a template to theme the output or something.... but I have not figured out a way to do that so far.
Any other ideas? Any tips are welcome!!
Thank you,
Kate
Comments
Rather than services, you
Rather than services, you might consider using a menu hook. There's actually a nice explanation for how to use a menu hook to return html here http://viziontech.co.il/tutorial1. I've used variations of this, but it basically boils down to creating the markup however you want - I've used views_embed_view or instance, wrapping it in the drupal_json method to JSONify it, then using JQuery after the target page loads it and .html() on the results to convert it back to html after it's received. The benefit of doing it this way is it avoids a lot of the template output while still delivering standard HTML markup.
Thank You
I just wanted to thank you for your response. It helped me to see that a simpler solution was definitely in order. All I needed to do was return simple html. So I implemented a menu_hook where the page callback just had some print statements and then exit() so that no other drupal hooks would be called. Much simpler than using a REST server, which doesn't seemed designed to transfer formatted html but rather just the data itself (which seems as it should be).
thanks again!