Comments

alan d.’s picture

Issue summary: View changes

Added new task to this meta issue

alan d.’s picture

Title: Roadmap » [Meta] Roadmap for Domain Fields initial development
Priority: Normal » Major
alan d.’s picture

Issue summary: View changes

Added sub-issue link.

IcanDivideBy0’s picture

It would be nice if it is possible to define display settings for each domain.
In my case, I want an image field to display with a certain image style depending on the domain it shows on.

alan d.’s picture

You mean http://drupal.org/project/domain_view_modes ?

Note that it is best to handle this yourself in code, but the module does allow you to automatically rebuild the domain specific displays for nodes.

carn1x’s picture

Could this module provide the following solution?

- 2 Domains: "domainA", "domainB"
- On both domains, there is a shared content type "Page", which has certain fields restricted to only show for registered users. During the registration process is a checkbox forcing the user to accept terms and conditions.
- There are separate terms and conditions for both domains: "termsA" and "termsB".
- User registers for domainA, accepts termsA and is granted "roleA"
- roleA is able to view content on domainA with access to the restricted fields for Page
- User now visits domainB whilst logged in, and views a Page, and because they are in roleA, they have permission to view restricted fields, however they have not accepted termsB, so they should not be able to view restricted fields.

Does that make sense?

alan d.’s picture

Partially

This module provides a way to restrict access, so it will hide fields based on the domain. However the rest of this is up to you.

1) Handle the users role during sign-up. There is a million modules out there that handle this in different ways, I done a very old comparison here: http://drupal.org/project/rolekey (this was a module that I dropped after a proliferation of other similar modules). I would use rules & actions.

2) Write your own field handling. See http://api.drupal.org/api/drupal/modules!field!field.api.php/function/ho...

/**
 * Implements hook_field_access().
 */
function MYMODULE_field_access($op, $field, $entity_type, $entity, $account) {
  if (empty($entity_type) || empty($entity)) {
    return TRUE;
  }
  if ($op == 'edit' || $op == 'view') {
    list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
    # $bundle is the content type, $id is the node $nid
    if ($entity_type == 'node' && $bundle == 'page') {
      if (empty($account->?????)) {
        return FALSE;
      }
    }
  }
  # this does not overwrite anything, it is the false above that controls things.
  # EDIT: NOT RETURNING ANYTHING IS LIKE RETURNING FALSE!
  return TRUE;
}

Or just finish off the entire process yourself.

  $domain = domain_get_domain(); 
  if ($domain['domain_id'] == 1) {
  }
  else {
  }
mrryanjohnston’s picture

Is there any chance that we can export these settings into features in future releases?

alan d.’s picture

I'm happy to help get patches into the module, but I would only do this myself on a need to basis which would not be in the foreseeable future.

alan d.’s picture

Issue summary: View changes

Task two completed and committed and updated the meta list.

ridfa’s picture

Thanks for this usefull module.

Would it be possible to administer a different field value for each domain, such as name.domain1 has a value 1 and name.domain2 has a value 2.
In this case, the same node ID would show differents values for the same field, depending on a domain rule.
Maybe is there a drupal way to administer and display this, in code or with a module ?

alan d.’s picture

@ridfa
I will read this as a support request. Best to start new threads for these :)

Skip access, it would probably complicate things. Try something like this:

function MYMODULE_node_view($node, $view_mode, $langcode) {
  switch ($node->type) {
    case 'page':
      $items = field_get_items('node', $node, 'field_resources', $langcode);
      if (!empty($items)) {
        // we have content, lets do something based on the domain.
        // Update $node->content['field_resources']
      }
      else {
        // No content, maybe unset $node->content['field_resources'] if it is being rendered.
      }
  }
}
alan d.’s picture

Issue summary: View changes

Update

dchalmer’s picture

Alan, just a quick thank-you from me. Domain Fields was the perfect solution to my problem - how to display the same news story on two domains, but displaying a different "News category" heading for the story on each domain... so, in the template for the content type:

      <h3><?php
        // Only one of these will be shown, courtesy of the magic of Domain Fields... :)
        print render($content['field_subtype']);
        print render($content['field_lse_news_category']);
      ?></h3>
      <?php
        hide($content['field_subtype']);
        hide($content['field_lse_news_category']);
      ?>

And in my Views it's even simpler: just add both fields to the list to be displayed, your code ensures only the one for the current domain is displayed.

Thanks again!
D.

alan d.’s picture

@dchalmer
Thanks, glad you found it useful :)

mas0h’s picture

Issue summary: View changes

This module doesn't support views, all restricted fields are showing under all subdomains! any suggestions?

alan d.’s picture

That would probably suggest a security issue with views, but by design if you are caching the results in a non-domain aware manor.

davidlfg’s picture

Assigned: alan d. » davidlfg
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new9.31 KB

Attached a patch proposes two improvements:
1- Support Exportables / Features.
2- Change the variable table for other structure, retaining all the same logic. I think it is really important because Drupal, query the table Variable by each request and In some cases one project a project might contain many Domains.

Any comment is appreciated!