I just got our drupal config working with a role-based home page.
This really isn't hard, but getting it all tuned and working correctly took a bit of time. I think you would take my ideas and easily adapt them to more sophisticated uses.
Role Based home page
What I'm doing here is just using a static page as a home page. You'll need to flag the static page as "Promoted to front page" and "static on front page". Also, it will look better if you change the default story publishing prefs to make all other content not be promoted to the front page by default. While someone could override this, as long as you have control over the content creators, it works well enough. You could certainly hack node.module to do a more clean implementation.
So, after implementing profile.module, create the static page and promote it to the front page. Edit it as a php page with contents like this:
global $user;
$enthome = "Welcome to the Acme Enterprise Sales Portal.";
if (!$user->uid){
$enthome.="CONTENT FOR NOT-LOGGED IN USERS";
}
if ($user->profile_sales == "yes") {
$enthome.="SALES CONTENT ON HOME PAGE you will see this content if you are in the Sales role";
}
if ($user->profile_se == "yes") {
$enthome.="SE CONTENT ON HOME PAGE you will see this content if you are in the SE role";
}
if ($user->profile_role3 == "yes") {
$enthome.="ROLE3 CONTENT ON HOME PAGE you will see this content if you are in the ROLE3 role";
}
if ($user->profile_manager == "yes") {
$enthome.="MANAGER CONTENT ON HOME PAGE you will see this content if you are in the MANAGER role";
}
$enthome.="end of content";
print $enthome;
The intention here is that each user is only in one role, but if they were in multiple roles you could certainly clean up the HTML to handle that.
Comments
role-based menu
here's the menu code. Just make a block and put it in the top left corner, or whereever you please. You could easily make this more complex with collapsible menus and such if you wanted.
Thanks! This could certainly
Thanks! This could certainly help me accomplish what I am trying to do. I have a few questions though:
1) How would I modify your code to check for a "webmail" role?
I tried changing if ($user->profile_sales == "yes") to if ($user->profile_webmail == "yes") and if ($user->webmail == "yes")
But the link does not show up in the block in either case.
2) Is there a way to conditionally show this block? (e.g., show block only for users with role="weblink"?
Thx.
the solution
if ($user->role == "sales") {
$enthome.="sales content";
}
I tried changing if ($user->p
You did configure the webmail role in profile.module, right? If not, you need to do that first, then you should have a drop-down box for the role in the user configuration. Make sure that is turned on. also, don't forget to declare global $user.
A completely empty block won't display. So if you wrap your whole block in a conditional statement, and the user doesn't meet the condition, the block won't display at all.
Yes!!! A working conditional, role-based weblink
Thanks tdailey and AXIN. As a result of tdailey's Role-based menu, and AXIN's suggestions, I now have a convenient, conditional (role-based) webmail link on my site. The link allows direct access to a webmail interface, and is only displayed for users with a specific role (in my case: "family"). The block code is very simple:
I also installed an excellent webmail script (UebiMiau) based on instructions posted my "mir" at the following URL:
http://s88567960.onlinehome.us/forums/index.php?showtopic=137
The combination does just about everything I'm looking for, so now I would like to tweak it by dictating how the linked (webmail) page is rendered. Does Drupal support this? That is, can I code a weblink in such a away that the referenced page is rendered to either:
(a) a new window/page instead of the current one, or
(b) to a frame within a pre-existing static page on the website?
TIA,
Donovan.
a new window/page instead of
a new window/page instead of the current oneThat's easy. In HTML you can:
<a href="http://www.yourlink.com" target="_blank">Your Link Text</a>In XHTML strict, you'll need to use an onclick window.open method. I tried to paste the sample code here but for some reason it gets labeled at suspicious data. Anyway, you probably don't care about XHTML strict so just use target=.
(b) to a frame within a pre-existing static page on the website?For that, you just need to define a node as an iframe and reference the iframe:
Just make this a PHP static page and reference the link to the page.
Worked perfectly!!!
Thanks tdailey. I implemented option (b) as you suggested and it worked perfectly. I now have a permission-based webmail access link, and webmail client interface integrated into my drupal installation. Thanks so much for your help. This is too cool -- and will probably be of interest to others. I'll post a link to some screen shots shortly.
Here's a link to screenshots for those wanting a peek
You can check out the screenshots in my "Drupal" image gallery at the following URL:
http://www.dillonsdomain.com/image/tid/30
looks great! glad i could he
looks great! glad i could help out. That's a pretty nice webmail interface. I've used SquirrelMail, which is a bit more complex, probably, but it's nice too.
I'll have to check out Squirr
I'll have to check out SquirrelMail. I would like to tighten the integration a bit further by auto-populating the Username and Password fields, and perhaps some skinning for cosmetics. Would SquirrelMail facilitate this? Also, I recall seeing somewhere that SquirrelMail requires an IMAP server, which my webhost (1and1) does not support. Can you confirm this?
Thanks again for all of your help tdailey.
changing
I tried changing if ($user->profile_sales == "yes") to
if ($user->profile_webmail == "yes") and if ($user->webmail == "yes")
--------------------------------
Busby SEO Challenge.