I'm using simply views block to display latest user comments. But the link to the comment always start with the current domain path. This is wrong cause it allow to see comments from other domains (with should be disallow). I have tried to add Domain Source: Domain Source ID, Domain Access: Domain ID and so on, but without any results.
$view = new view;
$view->name = 'user_latest_content';
$view->description = 'user_latest_content';
$view->tag = 'default';
$view->base_table = 'comment';
$view->human_name = 'user_latest_content';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'User Latest Comments/Posts:';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: Comment: Author */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'comment';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
$handler->display->display_options['relationships']['uid']['required'] = 1;
/* Relationship: Comment: Content */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'comment';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['relationships']['nid']['required'] = 0;
/* Field: Comment: Title */
$handler->display->display_options['fields']['subject']['id'] = 'subject';
$handler->display->display_options['fields']['subject']['table'] = 'comment';
$handler->display->display_options['fields']['subject']['field'] = 'subject';
$handler->display->display_options['fields']['subject']['label'] = '';
$handler->display->display_options['fields']['subject']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['subject']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['subject']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['subject']['alter']['external'] = 0;
$handler->display->display_options['fields']['subject']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['subject']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['subject']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['subject']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['subject']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['subject']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['subject']['alter']['trim'] = 0;
$handler->display->display_options['fields']['subject']['alter']['html'] = 0;
$handler->display->display_options['fields']['subject']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['subject']['element_default_classes'] = 1;
$handler->display->display_options['fields']['subject']['hide_empty'] = 0;
$handler->display->display_options['fields']['subject']['empty_zero'] = 0;
$handler->display->display_options['fields']['subject']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['subject']['link_to_comment'] = 1;
$handler->display->display_options['fields']['subject']['link_to_node'] = 0;
/* Sort criterion: Comment: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'comment';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
$handler->display->display_options['sorts']['created']['granularity'] = 'minute';
/* Contextual filter: User: Uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'users';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['relationship'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'user';
$handler->display->display_options['arguments']['uid']['default_argument_options']['user'] = FALSE;
$handler->display->display_options['arguments']['uid']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['uid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['uid']['not'] = 0;
/* Filter criterion: Comment: Approved */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'comment';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status_node']['id'] = 'status_node';
$handler->display->display_options['filters']['status_node']['table'] = 'node';
$handler->display->display_options['filters']['status_node']['field'] = 'status';
$handler->display->display_options['filters']['status_node']['relationship'] = 'nid';
$handler->display->display_options['filters']['status_node']['value'] = 1;
$handler->display->display_options['filters']['status_node']['group'] = 0;
$handler->display->display_options['filters']['status_node']['expose']['operator'] = FALSE;
/* Filter criterion: Content translation: Language */
$handler->display->display_options['filters']['language']['id'] = 'language';
$handler->display->display_options['filters']['language']['table'] = 'node';
$handler->display->display_options['filters']['language']['field'] = 'language';
$handler->display->display_options['filters']['language']['relationship'] = 'nid';
$handler->display->display_options['filters']['language']['value'] = array(
'***CURRENT_LANGUAGE***' => '***CURRENT_LANGUAGE***',
);
$handler->display->display_options['filters']['language']['group'] = '0';
/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');
If I set node source as subdomain2 then link to the comment should look http://www.subdomain2.mypage.com/comment/6247#comment-6247 and not http://www.subdomain(1 or 3).mypage.com/comment/6247#comment-6247
Please test it. Maybe I do set views wrong or simply misunderstood DAviews behavior ? Any advice is much appreciated.
Comment | File | Size | Author |
---|---|---|---|
#15 | 1444756-domain-comment.patch | 4.09 KB | agentrickard |
#10 | 1444756-domain-comment.patch | 1.53 KB | agentrickard |
Comments
Comment #1
agentrickardThe problem is that DA doesn't know how to look up the path for direct comment links, only nodes.
Comment #2
pwiniacki CreditAttribution: pwiniacki commentedI tried to change that with no luck, anyway its nice feature request then.
Comment #3
agentrickardThis would have to go into the main module.
The idea is that we need to map
comment/%cid/view
and related paths to lookup the canonical domain of the nodes those comments are attached to.Comment #4
agentrickardComment #5
kerios83 CreditAttribution: kerios83 commentedI just tried to add similar functionality on my site but without good results. I guess it won't be possible till 'we' 'fix' DA.
Comment #6
agentrickardDid you try using hook_domain_source_path_alter()?
Comment #7
kerios83 CreditAttribution: kerios83 commentedI guess he used hook_domain_source_alter()... ? Gona check this and post an answer.
Comment #8
agentrickardhook_domain_source_alter() only runs on node paths, this is explained in domain.api.php.
Comment #9
kerios83 CreditAttribution: kerios83 commentedYou were right about hook_domain_source_path_alter() I don't know what goes wrong but he wasn't able to close this issue. When he goes back from trip I will call him to the blackboard.
Comment #10
agentrickardHere's a patch that adds support for comment URLs. Could really use a good test.
Comment #11
batigol CreditAttribution: batigol commentedI was away for a few days. I'm gonna find some time and test it. THX agent !
EDIT: This is working great ! All comment links to proper domains with proper language affix. Amazing job - tested on localhost drupal 7.15 and domain access 7.x-3.3. More live tests are coming !
EDIT2: Everything goes extremely well. There is proper link for comments to domain they belong to. Even if you try some specific options like - Publish to and - Source domain everything is working as intended. This is working with forum comments to (however not with forum topics - forum nodes - itself cause they are nodes not comments).
Comment #12
agentrickardThanks!
Have you noticed any performance slowdown? I'd still like to get an automated test here, too.
Comment #13
batigol CreditAttribution: batigol commentedNope I didn't notice any performance slowdown. But honestly I was exited that it works just fine and my eyes were not direct on performance issues.
Comment #14
kerios83 CreditAttribution: kerios83 commentedI have test it, it's working !
Comment #15
agentrickardThe tests are almost ready, but the last two fail.
Comment #16
pwiniacki CreditAttribution: pwiniacki commented@agentrickard your patch is working with DA 3.3 I'm using it for a long time with a good result. I didn't test it with newest version of DA. However I'm in need to upgrade one of my site to 7.18 so it will be a good opportunity to upgrade DA too and test it. I'm not a programmer so I won't help with a code but I can write here if errors were found.
Comment #17
agentrickardThanks. I think the code is fine, we just needs automated tests for maintainability.
Comment #18
kerios83 CreditAttribution: kerios83 commentedDoes latest DA has this option included ? Cause I'm thinking of using DA but comments shared on all domains is not something I can afford right now.
Comment #19
agentrickard"Needs work" means that the patch needs more development. Specifically, I asked for tests in comment #17.
Comments on all domains are only an issue if you display comments outside the context of the node they are attached to.
Comment #20
kerios83 CreditAttribution: kerios83 commentedOn my test page, when somebody click on a username, it show his latest comments/forum posts. But when you click on a link to comment, it's open in domain you are currently browsing, not the domain the comment "belong to".
If I remember correctly this patch was working very well - after clicking on a comment link you were moved to correct domain.
Let me know if I can help with anything, so next version of DA will have this patch mounted.
Comment #21
agentrickardDo you know how to write tests?
Comment #22
kerios83 CreditAttribution: kerios83 commented@agentrickard, nope. I'm not a programmer. I can help test this module but I can't improve it via writing code. However I can say if there is error somewhere or what to improve.
Comment #23
pwiniacki CreditAttribution: pwiniacki commentedWasn't it tested ? I thought it's in DA already :)
Comment #24
agentrickardIt is not, because in my local browser tests I get inconsistent results.
Comment #25
pwiniacki CreditAttribution: pwiniacki commentedI discovered https://www.drupal.org/node/1508448 and when playing with it and checking domain access queue I recognize this bug here. Provided patch is working with v3.3 I'm using it all the time on my live sites.
Comment #26
pwiniacki CreditAttribution: pwiniacki commentedAfter update to 3.11 patch is working like expected. +1 to go.