I had another website that I wanted to 'integrate' with Drupal.
What I wanted was the following:
- Create a role-specific menu navigation to my legacy web site, where Drupal would serve as a front end.
- When invoking the web pages from my legacy web site, Drupal should provide user name and few other parameters (via URL parameters).
In the default Drupal 6.6 installation it is not possible to create navigation components
specific to each individual user role (needed for item (1) )
In addition to that, in the default Drupal installation there is no specific way to invoke
an external page(s) as an 'iframe' so it looks 'integrated' within Drupal.
Both of the above, however, are supported if we add several modules:
- CCK module (specifically including IFrame support)
- Content Access Module
- Simple Menu module (if you want sliding style menus to appear at the top of the page).
Conceptually this is what we will be doing:
a) We will create new content types (using CCK module) that will allow us to access external
b)We will assign the user's role-based permission to those content types (using Content_access module) such that when nodes of those specific content types are instantiated -- the menu system (and therefore Simple Menu module) would only show menus applicable to a specific user based on his or her role.
For example my legacy system has the following user roles:
- Define_product_offers (accessible to product creation User role)
- Review_orders (accessible to customer support)
We can call them the CS and PC roles.
We also have a special role called Site Administration (this is for site administrations).
We now want:
- users with PC role to see a menu and access Define_product_offers external page (and pass their user ID when accessing)
- users with CS role to see menu and Review Orders external page (and pass their user ID when accessing)
Let's start (assuming now that the modules mentioned above are installed)
- Create roles
Administration | User | roles
PC, CS, SiteAdmin
- Create three new content types using the CCK module
First one -- ProductOffersLinks
Create a new field under this content type can call it ProductOfferLink. Type: Iframe, Body empty, no comments
Also, this is IMPORTANT, check the checkbox that allows the person who will instantiate this content type to use what are called 'tokens'.
This is where the Content Access Module becomes handy.
It adds another tab called 'Access Permissions'. There you can set what roles are allowed
to view or modify the nodes of this node type.
Second One OrdersLinks, with a field OrdersLink of type Iframe (the same as above).
Third one, and this may or may not be how you want to do it -- a content type called
AdminLinks and create a new field there of type multiline text
- Go to the Adminstration|User Management|Permissions tab, scroll to the
content_permissions module section and make sure that you checked the
View option for the appropriate User Roles.
For example, the PC role should have view permissions to OffersLink field
The CS role should have a view permission to OrdersLink
And the Admin role should have a view (and modify of course) to the AdminLinks
- Rebuild permissions (I always do this) Go to 'Administration'|Post settings|Rebuild Permissions
- Now you are ready to instantiate the new Node Types.
So we will instantiate ProductOffersLink first, and in the URL we will put the
URL of your legacy web page that deals with Product offers. This node will only be visible
to users with the PC role. Viewing an IFrame field
means that Drupal will load the referenced web page right within Drupal. There is also
an option to create a new separate window.
When specifying the URL, you can do also add the special Drupal supported tokens.
For example http:\\samedomainasdrupal\legacy\oders_page\[user-name]
The [user-name] will be substituted by Drupal dynamically with the user name of the specific user that is 'viewing' this Iframe node. That's why selecting that 'checkbox' to allow tokens in the URL was important.
Instantiate the other content type for the OrderLinks in a similar way.
Now the third one -- for the AdminLinks. Since it is of type text, just add http:\\mydrupalsite.com\?=admin
This is the link to all the admin pages.
- Now we need to rearrange the menu so that only our nodes will be seeing by users. While the Drupal navigation menu is useful for typical 'community network sites'. My site is not a vanilla community network and I need to control what users can do what things.
So in this little example I only want the users to access Product Offers and Order Links
So I first disable the Navigation by making sure that it does not get displayed in any blocks
(this is done by going to Administration | Blocks and making sure that the Navigation is not
attached to any block).
Then I create a new top level menu, I call "Master Menu".
I go to Administration | Menu and create that new menu.
Then I go to SimpleMenu Module (also under Administration), and I set the 'Master Menu'
As the menu that SimpleMenu module is using.
Now I can add whatever things I want to the Master Menu and the SimpleMenu module will put a nice DHTML-like menu bar on top of the Drupal page.
- There is a bit of care required here. First, since we disabled the
all-intrusive Navigation Menu, we also lost the log off button.
First thing we do therefore, is we go and add a new item under the Master Menu,
called Logout, and the link is simply Logout.
- Now we go back to the Nodes we instantiated for the three content types we created
(we can go back to them simply going to Administration | Content ). Edit each one and
specify the 'Parent Menu' as Master Menu and Menu Name as say 'Legacy1', 'Legacy2' and Go-Admin
Now we need to instantiate an additional node for every type.
I call it Menu Node, when instantiating it, make sure you click on the Menu option, and select Master Menu as a parent menu.
In Drupal, to create submenus, a submenu by itself must be a node.
So I chose to have it of the same type as the corresponding submenu items -- so that Role-based permissions on those node types work correctly.
Now you can go back to the Administration | Menus. Select the Master Menu and drag around
each menu item and rename the submenu if you need.
Drupal, now by managing permissons for each node instance, will deactivate the appropriate menu items depending on which user has logged in.
The SimpleMenu listens to it and only puts on the menu bar the links to the nodes
that belong to content types that have the permission to view for a particular user role.