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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agentrickard’s picture

The problem is that DA doesn't know how to look up the path for direct comment links, only nodes.

pwiniacki’s picture

Category: support » feature
Status: Active » Needs work

I tried to change that with no luck, anyway its nice feature request then.

agentrickard’s picture

Project: Domain Views » Domain
Version: 7.x-1.4 » 7.x-3.x-dev
Status: Needs work » Active

This 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.

agentrickard’s picture

Title: User latest comments view - point to wrong domain » Link comment/%/* to canonical domain
kerios83’s picture

I just tried to add similar functionality on my site but without good results. I guess it won't be possible till 'we' 'fix' DA.

agentrickard’s picture

Did you try using hook_domain_source_path_alter()?

kerios83’s picture

I guess he used hook_domain_source_alter()... ? Gona check this and post an answer.

agentrickard’s picture

hook_domain_source_alter() only runs on node paths, this is explained in domain.api.php.

kerios83’s picture

You 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.

agentrickard’s picture

Status: Active » Needs review
FileSize
1.53 KB

Here's a patch that adds support for comment URLs. Could really use a good test.

batigol’s picture

I 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).

agentrickard’s picture

Thanks!

Have you noticed any performance slowdown? I'd still like to get an automated test here, too.

batigol’s picture

Nope 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.

kerios83’s picture

I have test it, it's working !

agentrickard’s picture

Status: Needs review » Needs work
FileSize
4.09 KB

The tests are almost ready, but the last two fail.

pwiniacki’s picture

@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.

agentrickard’s picture

Thanks. I think the code is fine, we just needs automated tests for maintainability.

kerios83’s picture

Does 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.

agentrickard’s picture

"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.

kerios83’s picture

On 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.

agentrickard’s picture

Do you know how to write tests?

kerios83’s picture

@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.

pwiniacki’s picture

Wasn't it tested ? I thought it's in DA already :)

agentrickard’s picture

It is not, because in my local browser tests I get inconsistent results.

pwiniacki’s picture

I 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.

pwiniacki’s picture

After update to 3.11 patch is working like expected. +1 to go.