Integrating Zoop and Drupal

Here Zoop community member Jeremy will be walking us through how he integrated Zoop and Drupal. This tutorial will be created Wiki style in hopes that others will aid / update.

Objective
The purpose of this tutorial is to show you how to add a Zoop (1.3) application or page to Drupal 5 as a content page. These techniques will probably work in Drupal 4 but the function names are different. Additionally, I will explain how to integrate session management from Drupal into Zoop. The latter opens up the entire scope of user/session/subscription management modules to your Zoop app. ..Yes, you read that correctly. **I have not tested any of this with Zoop 1.5**

Adding your Zoop application or page to Drupal

  1. Create a new page in Druapl. Set the input mode on the page to be php
  2. Add you content like so. You must use the functions in the sample to add css and js to you page. The function calls will be executed before the page loads and the files you load will appear in the head tag of the Drupal page. So, don't expect execution of and scripts in the body. If you want execution when the page loads you need to add an onload in one of the js files you load. That's what I did ...keep reading. Alternatively, there's supposed to be a "correct" way to create an onload in Drupal. I don't know what that is.

    Nothing is written in stone reagarding what to include and what to exclude. I have no HTML in my pages other then a single div with an id attribute since my Zoop app is 100% Ajax.

    <div id="myContentDiv"></div>

  3. This example sets a body onload event that will trigger an Ajax call using Prototypes Upater method. The returned content fills the div. From there the application is visible to the user. I happen to have a smarty template that loads a set of four divs into along with other application content. I use those four divs to display additional messages, content, status information and whatever else I want.

    The myapp.js file contains this along with the entire application.

    embed = MyApp;
    window.onload=function(){
      if(embed){
         loadEmbed('Embed' + embed,'myContentDiv','myZone');
      }else{
         alert('Error: No content specified for loading'); 
      }
    }
    loadEmbed = function(what,where,zone){
      var url='/skeleton/index.php/' + zone + '/' + what;
      new Ajax.Updater(where,url,{method: 'get', onComplete: function(transport){initApp();}
                                               });
    }

    This js loads the content returned from /skeleton/index.php/myZone/EmbedMyApp/ in to myContentDiv and onComplete it runs initApp(). initApp() just sets some defaults on the page.

  4. If you are not using AJAX just load the Zoop components you need in to the page. Remember that submitting the page will submit to the Drupal URL, not the Zoop URL. Thus, you cannot expect zoop behavior. However, you could probably create other pages in Drupal to handle you posts. After all Drupal accepts PHP content. Really, AJAX is so easy with Zoop and Prototype. Why would you not use it.
  5. save you page and test it.

Integrating Zoop and Drupal session and user management

Before I start, know that I've been using this scenario on a large application for going on 9 months with absolutely no ill effects.

...Your mileage may vary and I may have left something out unintentionally (Though I'm pretty sure I didn't).

Are you ready?
Go get something to eat and a pot of coffee, this could take days! ;-)

  1. Locate Your Drupal includes/bootstrap.inc file. (yes, Drupal needs to be installed already).
    Take note of the path to that file.
  2. Open the file session/session_component.php in your Zoop source directory. (yes, Zoop needs to be installed already)
  3. change the name of the init function to something else. I renamed mine '_init'. You might prefer 'original_init' or 'mydoghasfleas'.
  4. Paste in this shiny new init function. Make sure you replace 'your_drupal_bootstrap_path' with the path you took note of above. Make sure it's the full path to the bootstrap.inc file.

function init()
{
    require_once 'your_drupal_bootstrap_path';
    drupal_bootstrap(DRUPAL_SESSION_DATA_ONLY);
}

  • Your done.
  • Testing and Using your Drupal - Zoop Integration

    Assuming everything was done correctly with the bootstrap integration above you're ready to use drupal and zoop together.

    Here's a way to have your Zoop app depend on Drupal for permissions,user management, sessions, etc.

    1. Open up the zone file for your zoop app.
    2. In your initZone file use something like this condition to control whatever you want to control.

     $user = $GLOBALS['user'];  //This is one of the globals that Drupal creates.
     //print_r($user);  // Do this to see what you have access to.
     if($user->uid > '1'){
         if( $user->roles[4] == 'Premium Subscriber' || $user->roles[6] == 'Some Role'){
              define_paying_subscriber_globals(); // A function that does stuff for these people.
         }else{
              // Unauthenticated user - must login via drupal
              print "The Section is for paying subscribers only.<br/>";
              exit;
         }
     }else if($user->uid == '0'){
         print "You are not logged in.<br/>";
         exit;
     }

  • You can access this page outside drupal or you can integrate Ajax calls to this page in your drupal page (that's what I do). The latter is detailed on this page.
  • Now you can build your site using all the user and group management possibilities of Drupal and use zoop to build the core application. In my case, I use premium content and roles in Drupal to control what parts of the application my users can access. There is no need to limit yourself to the initZone function. You can access the drupal globals from anywhere you want.

    gotchas with Drupal:

    1. Drupal templates can change the layout of your zoop generated content. This is often a very good thing. However, it can be a real pain when using various selector widgets that have their own styles. This is generally because some templates are designed to enforce styles globally. So, you'll find css constructs for things like div,th,td,table ...etc that will affect any such elements on the page. If you care, you should modify the template css or your code accordingly.

    Go create something,
    Jeremy Brooks

    I am glad that I have seen

    I am glad that I have seen this posts, it's been a long time that I am looking for this codes but I never find it anywhere online. I think now is the time to see if this works for my drupal site.
    Thanks,
    darren @ brand names

    darrensy 31 Jul 2011

    Thank You.

    Thank you for sharing this information. It helps me to widen my knowledge.

    eczema cure

    angel1975 16 Sep 2011

    wow really great post i

    wow really great post i really like this post thanks for sharing...sunglasses

    aldis 30 Sep 2011

    best article

    Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up!
    blog immobiliare
    donna cerca uomo roma
    portali immobiliari

    jacklavoro 05 Jan 2012

    Drupal has had functions to

    Drupal has had functions to assist with accessing database tables. These functions can perform tasks such as SQL query cleansing, multi site table name prefixing, and helpers for generating proper SQL queries for the database. In addition, Drupal six introduced an abstraction layer that allowed programmers to create SQL queries without writing SQL. Thanks a lot.
    Regards,
    professional thesis writers

    jaffa 09 Jan 2012

    Drupal isolates core files

    Drupal isolates core files from contributed modules and themes. This increases flexibility and security and allows administrators to cleanly upgrade to new releases without overwriting their site's customizations. To maintain this separation, drupal does not support altering drupal core's software. Thanks a lot.
    Regards,
    Social Bookmarking Service

    jaffa 12 Jan 2012

    Stumbled upon your website

    Stumbled upon your website while I was searching for information and facts for our internet site, obviously this isnt all releative however its interesting how one can reach a web site accidentally and find your self looking at something different but just as useful. I tend to get diverted a really often like this. Rhonda Allison

    jhonmgt745 31 Jan 2012

    Nomi king

    Thank you for making the sincere effort to talk about this. I feel very strong approximately it and would like to learn more. If its OK, as you gain more extensive knowledge, might you thoughts including extra articles similar to this one with additional information? It could be extremely useful and helpful for me and my friends.
    epicuren

    jhonmgt745 31 Jan 2012

    Nomi king

    Awesome site! Your style is very unique in comparison with most other writers. Thank you for publishing whenever you have the opportunity to, I will be sure to book mark your blog!

    clayton shagal collagen gel plus

    jhonmgt745 31 Jan 2012

    Nomi king

    Thank you for the fantastic suggestion! I just got here on your web site and really like the contents. I anticipate reading your posts in the near future. Fantastic post, really useful. I believe plenty of visitors will uncover this very useful.Keep post in coming future as well!

    jan marini bioglycolic

    jhonmgt745 31 Jan 2012

    Drupal isolates core files

    Drupal isolates core files from contributed modules and themes. This increases flexibility and security and allows administrators to cleanly upgrade to new releases without overwriting their site's customizations. To maintain this separation, Drupal does not support altering Drupal core's software. Thanks.
    Regards,
    brampton criminal lawyer

    jaffa 18 Jan 2012

    clearance furniture

    I just wanna say thank you for the information that you have been shared to us readers. Thanks for posting this kind of theme.

    clearance furniture

    simran 18 Jan 2012

    With this economic crisis

    With this economic crisis the actual its always, I chose to ready methods for filing for unemployment benefits. Offers picture would have been to detail the fact that the lack of employment setup toils, what the normal means agreeing to or just rejecting assertions, and be able to add content articles outside of my own ring practical knowledge in what excellent maneuvers while simple slipups are formed in declaring bankruptcy under joblessness beneficial
    Music Producers properties.

    ali.shass 25 Jan 2012

    Site visitors Mayhem Review-

    Site visitors Mayhem Review- the content on this post is seriously a single of probably the most effective substance that i?ve truly are obtainable throughout. I actually like your post, Ill are obtainable again to verify for new posts. hair regrowth laser

    ali.shass 25 Jan 2012

    Zoop as a framework provides

    Zoop as a framework provides both lower level and 70-291 more advanced functionality. Forms is one of the more advanced functions within Zoop. It is built on top of the gui, guicontrol and db components and provides C-TFIN52-64 a bridge between them. For the 1.2 Release of Zoop, Forms was redone to provide both better efficiency and an easier interface for the programmer.642-983 Forms integrates the database with the gui offering a very nice answer to database driven forms, searching, and lists.

    roter 07 Sep 2011

    Locate Your Drupal

    Locate Your Drupal includes/bootstrap.inc file. (yes, Drupal needs to be installed already).
    Take note of the path to that file. viagra

    eavedrop44 19 Dec 2011

    In today's competetive

    In today's competetive business environment, every business is facing a cut throte competition including rental car services. Dulles car service is one of the leading limousine rental car provider in Washington DC and its surroundings.

    kellysmith 19 Oct 2011

    That's what I did ...keep

    That's what I did ...keep reading. Alternatively, there's supposed to be a "correct" way to create an onload in Drupal. I don't know what that is. it montreux

    eavedrop44 13 Dec 2011

    That's what I did ...keep

    That's what I did ...keep reading. Alternatively, there's supposed to be a "correct" way to create an onload in Drupal. I don't know what that is. live tweets

    eavedrop44 23 Dec 2011

    Great write-up, I am a big

    Great write-up, I am a big believer in commenting on blogs to assist the weblog writers know that they’ve added one thing worthwhile to the world large net!Anyway, in my language, there aren’t a lot good source like this.hiv zelftest

    kingsteen 27 Oct 2011

    This book will be kept

    This book will be kept current with the current stable version of Zoop. It is authored by the creators and maintainers of Zoop and can be considered the greatest book of it's kind.
    Camerabeveiliging

    casica 31 Oct 2011

    We can not wait zoop

    We can not wait zoop behavior. However, probably you could create other pages of Drupal to manage their posts.Now records management can build our website using all the possibilities for users and group management and use Drupal to build zoop application base.

    mapleen 05 Nov 2011

    Now you can build your site

    Now you can build your site using all the user and group management possibilities of Drupal and use zoop to build the core application. In my case, I use premium content and roles in Drupal to control what parts of the application my users can access. There is no need to limit yourself to the initZone function. You can access the drupal globals from anywhere you want.resume help

    eavedrop44 12 Nov 2011

    This is generally because

    This is generally because some templates are designed to enforce styles globally. So, you'll find css constructs for things like div,th,td,table ...etc that will affect any such elements on the page. If you care, you should modify the template css or your code accordingly.
    catering supplies

    eavedrop44 16 Nov 2011

    Wow, really great

    Wow, really great information sharing. I have already read so much on this topic but your this article has answered so many questions in my mind. limo service in DC

    Ali Khaan 19 Nov 2011

    I have yet to properly know

    I have yet to properly know how to use a 3D object creating software, but I am planning to take some courses next year. This would definitely mean taking the next step in graphic design for me. I do well at 2D so far, though. But learning 3D would be the next challenge, so I can improve my portfolio and enhance my career opportunities. Right now I have this issue with an exe file extension in my Illustrator installation kit. I was hoping to find an answer here, in one of these tutorials.

    gregory 29 Nov 2011

    Locate Your Drupal

    Locate Your Drupal includes/bootstrap.inc file. (yes, Drupal needs to be installed already).
    Take note of the path to that file. catering equipment

    eavedrop44 03 Dec 2011

    Wow, really great

    Wow, really great information sharing. I have already read so much on this topic but your this article has answered so many questions in my mind. car service washington DC

    robert katez 06 Dec 2011

    Oracle braindumps || ccip

    Oracle braindumps || ccip braindumps || ccent braindumps || 640-802 braindumps || 70-640 braindumps || 70-680 braindumps || SY0-201 braindumps || VCP-410 braindumps ||

    Its not the case that reader must be completely agreed with author's views about article. So this is what happened with me, anyways its a good effort, I appreciate it. Thanks

    Leo123 09 Dec 2011

    Definitely, what a great

    Definitely, what a great website and revealing posts, I surely will bookmark your blog.Have an awsome day!
    anti aging skin care

    ali.shass 09 Dec 2011

    I found your blog web site

    I found your blog web site on and test just a few of your early posts. Proceed to maintain up the excellent operate. I simply further up your feed to my Information Reader. In search of ahead to reading extra from you later on! makeup videos

    ali.shass 09 Dec 2011

    . That's what I did ...keep

    . That's what I did ...keep reading. Alternatively, there's supposed to be a "correct" way to create an onload in Drupal. I don't know what that is.
    lamotrigine lamictal

    eavedrop44 11 Dec 2011

    I found this despatch to be

    I found this despatch to be rather useful. I am using it in a paper I am scribble literary works at college.
    Club Beats

    ali.shass 17 Dec 2011

    alishassThanks for providing

    alishassThanks for providing such a great article, it was excellent and very informative. It's my first time that I visit here. I found a lot of informative stuff in your article. Keep it up. Thank you. chinese calendars

    ali.shass 19 Dec 2011

    Paste in this shiny new init

    Paste in this shiny new init function. Make sure you replace 'your_drupal_bootstrap_path' with the path you took note of above. Make sure it's the full path to the bootstrap.inc file. write my thesis

    eavedrop44 21 Dec 2011

    Nomi king

    Hey nice blog, just looking about some blogs, appears a fairly nice platform you might be utilizing. Im presently using WordPress for a few of my websites but looking to change 1 of them around to a platform comparable to yours as being a trial run. Anything in particular youd recommend about it?

    repechage reviews

    jhonmgt745 03 Feb 2012

    Nomi king

    Just want to say your article is stunning. The lucidity in your post is simply striking and i can assume you are an expert on this subject. Well with your permission allow me to grab your rss feed to keep up to date with incoming post. Thanks a million and please keep up the delightful work. deck repair

    jhonmgt745 27 Dec 2011

    Nomi king

    Thx für die Daten. Der Blog ist extrem gut. Hab deinen Webblog gebookmarked Grüße Bifsoft

    jhonmgt745 05 Jan 2012

    Nomi king

    I'd have to consent with you here. Which is not something I typically do! I enjoy reading a post that will make people think. Also, thanks for allowing me to comment! Environ Products

    jhonmgt745 05 Jan 2012

    Nomi king

    hey buddy,this is one of the best posts that I’ve ever seen; you may include some more ideas in the same theme. I’m still waiting for some interesting thoughts from your side in your next post

    singapore math

    jhonmgt745 17 Jan 2012

    Nomi king

    This is my first time i visit here. I discovered lots of useful thing in your weblog especially its discussion. On the numerous feedback on your posts, I guess Im not the only one having all the enjoyment right here! keep up your great work. buy microchip pic

    jhonmgt745 18 Jan 2012

    Website links swap idea hi,

    Website links swap idea hi, how about exchange inbound links with my sites at Education is Important?. This time, I suggest a three-way back link directed from my other website. My exchange link contact info is at the home page.
    Dermalogica Microfoliant

    ali.shass 24 Jan 2012

    academic regalia

    The temperature increases, rainfall in the Southeast will increase but because of evaporation the area may get even drier. The researchers concluded with a statement saying that any rainfall comes from complicated internal processes in the atmosphere that are very hard to predict because of the large amount of variables. Thanks a lot.
    academic regalia

    antojames 25 Jan 2012