Drupal 6 按域自定义首页
我有一个房地产代理的 drupal 6 网站。由于每个代理都有自己的网址,因此我想将它们全部定向到主网站,并为每个域名使用不同的主页(在本例中是他们的用户个人资料页面,可以查看其属性)。
到目前为止,我使用模块的 init() 函数来检查域是否与主域不同,并查找该域属于哪个用户。
我知道我可以使用 drupal_goto('users/username') 但我更愿意在不更改 url 的情况下执行此操作。这样,该网站看起来更适合代理“定制”,而不是主网站中的重定向。
这是我的 init() 函数的代码:
if(!strstr($_SERVER['SERVER_NAME'],'maindomain')){
//look in profile field id 8 to which user the domain belong
$value = db_result(db_query("SELECT uid FROM {profile_values} WHERE fid = 8 AND value like '%s'"), $_SERVER['SERVER_NAME']);
if($value){
//store the uid in $agent_site for further use
global $agent_site;
$agent_site = $value;
if(drupal_is_front_page()){
//Do the equivalent of drupal_goto('users/username') without modifying the url
}
}
}
非常感谢您的想法。
I have a drupal 6 website for a real estate agency. Since each agents have their own url, I want to direct them all to the main website and use a different homepage per domain name (in this case their user profile page which have a view of their properties).
So far I use the init() function of a module to check if the domain is different from the main one and find to which user the domain belong.
I know I could use drupal_goto('users/username') but I would prefert to do it without changing the url. This way the site look more "customize" to the agent rather than a redirect in the main website.
Here is the code of my init() function:
if(!strstr($_SERVER['SERVER_NAME'],'maindomain')){
//look in profile field id 8 to which user the domain belong
$value = db_result(db_query("SELECT uid FROM {profile_values} WHERE fid = 8 AND value like '%s'"), $_SERVER['SERVER_NAME']);
if($value){
//store the uid in $agent_site for further use
global $agent_site;
$agent_site = $value;
if(drupal_is_front_page()){
//Do the equivalent of drupal_goto('users/username') without modifying the url
}
}
}
Thank you very much for your ideas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过首页模块
http://drupal.org/project/front
或者您也可以使用启动页面
http://drupal.org/project/splash
Have you tried the front page module
http://drupal.org/project/front
Or you can also use a splash page
http://drupal.org/project/splash