Hi,
I've searched for a module that is capable of the following but could not find anything close (except for a 404 Error related module). I don't know if the following scenario is doable with the existing modules for Drupal6.
I have two web sites, say frontsite.com and backsite.com.
* If a visitor is visiting frontsite.com/something I would like to extract "something" as a session variable for that visitor.
* I would like to see if there is any user in frontsite.com that has the username "something", if not I would like to assign a default value to that session variable instead of something.
* In frontsite.com there are lots of links to backsite.com. I would like to change these links to link to backsite.com/something for that visitor.
Do you have any idea if this is possible or not?
PS: If I wasn't clear enough about anything just ask me and I'll try to explain as clear as I can.
PS2: I'm aware that what I'm trying to do sounds crazy, but I have high expectations about Drupal :)
Comments
I'm not sure if I understand
I'm not sure if I understand your question, but more importantly: you didn't tell us which problem you're solving. Do you need some kind of single sign-on? Two sites with a shared user base? You've described the solution you want to build, but there may be better/easier solutions already available for your needs, depending on your needs.
The problem
Hi,
Actually what I've tried to explain was the problem (a weird one though).
Let me try to explain in another way.
Say there is a user in my website firstsite.com: user1
In this case firstsite.com/user1 is considered to be a referral address that users uses to redirect some customers to firstsite.com. So whenever a user lands to firstsite.com/user1 I would like to register this as a referral from user1.
There are lots of URLs linking to secondsite.com in the page. I would like all these links to be converted to secondsite.com/user1.
In essence, if a user refers to firstsite.com I would like to refer to secondsite.com as if user one has directly referred to secondsite.com.
I'd love to help, but I can't
I'd love to help, but I can't wrap my head around this, sorry.
Loosening the requirements
Hi,
Sorry for my inability to explain the problem properly. Maybe, as a starting point we can discuss something simpler:
If a visitor lands on first.com/foo, on that very page I would like to show her a link to second.com/foo.
Conditions:
* If foo is a user in first.com use his username.
* If foo is not a user in first.com reset it to the default user.
Does that look any better?
Well yes, that looks simpler.
Well yes, that looks simpler. The question remains how/where you want to insert that link. Let's start with the easiest method, which is hard-coding it in a template:
If you want to output this another way (ie. as a field in Views or as a menu item) things would get more complex.
Small problem
Thanks again for the code snippet. But there is a problem: I would like this to work only for anonymous visitors. I don't really care about the registered users in that respect. So the logic should be something like this:
Anonymous user visits firstsite.com/foo
I get the "foo" part of the URL (I guess this should be possible using the Token module?)
Check if there is a user with username "foo"
If there exists such a user then put a link on the page to secondsite.com/foo
Else put a link on the page to secondsite.com/default
I would like to integrate this functionality with a page or a story so that I can inform the incoming anonymous user about the whole thing. So the best thing, probably, would be inserting a page/story on the page and then displaying the link at the end of the page. I don't want to include the PHP code directly in the node since that node will be editable to some users. Perhaps it could be implemented as a "block"?
OK, I see. Token module is
OK, I see. Token module is not what you need here, you're looking for the arg() function (http://api.drupal.org/api/function/arg/6).
BTW I think this should work, but it is untested code.
You are right that inserting php code in nodes is a bad idea in general. You can create a block for this and place it anywhere on your page. You can also insert this code in a template such as page.tpl.php or node.tpl.php.
This looks good
This looks good. I cannot try this right now, but I'll test it in a few hours and let you know of the result.
Since I don't want to show this on all pages, I'll need to show the block selectively. I'm thinking of making use of 404 redirection as a solution to this. I can create a page and show this block only on that page and use the 404 redirection to redirect everything other than the proper site content to redirect to that page. Does it sound sane?
A different approach
Here is a different approach to solve the above problem:
I can use the profile pages of the users for this purpose.
Using pathauto module I can set firstsite.com/foo to redirect to user "foo"s profile page.
I can insert a node (the same node for every user) into every user's profile and show the block only at profile pages. In this case, the redirection for every users will work.
For firstsite.com/nonsense kind of landing pages (where "nonsense" is not a registered username) I can siply use the 404 redirect and use a static page to serve this purpose.
This sound more doable to me. Two things to handle:
1. Insert a node into every user's profile
2. Find out a way to show a block only if the page is a user profile.
Thanks!
Just for the sake of completeness: I've solved the problem with this approach. Below is the code I used to modify the profile pages:
I modified the profile pages using hook_profile_alter() so that the profile included the body of a node and a link that is entered as a custom profile setting in every users registration form.
So I didn't need to deal with any blocks (where and how to display it).
This solved my problem and thanks a lot marcvangend for your time and consideration.