hi, it is possible not created internal paths like /field-collection/field-name/id?
or at least block access to external users, if possible.

Comments

robmalon’s picture

Title: i wouldn't the path item /field-collection » Removing or Altering /field-collection Paths

I'd also like an option to disable these paths, though I would suspect being able to alter them could be useful as well. Perhaps with path auto at some point too?

I've only been able to disable these paths via a custom redirect/404 module I use on a per site basis. That's working well enough so far! My primary worry was in having SEO related issues.

gargsuchi’s picture

I am also interested in a UI for paths field collection items. Anything in the near future? Or if you can give me some pointers, I can try to roll out a patch for the same.

pedrosp’s picture

I presume that duplicated content generated by the field collection view and the source node is obviously bad for SEO purposes.
I use to deal with the Rabbit Hole module to avoid duplicate content, however I can't figure out how to use it with field collections.
Anyone has a related experience ?

STINGER_LP’s picture

Yep, I rejected from using this module after discovering this unwanted "feature" in favor of "Field group" + "Fieldgroup multiple".

indyana’s picture

I also wish I could easily do something else with these paths. I wanted to continue using field-collection, so here are two quick hacks I found for this in the meantime, in case anyone else is interested:

1) Block access to users:
http://drupal.org/node/1282066
I just did a quick test of this by adding the content to field_collection_menu_alter. Appears to work as intended.

2) Redirect the pages. This is a very broad redirect added to Drupal's .htaccess file. Should be placed above the index.php redirect section (section that ends with "RewriteRule ^ index.php [L]").

# Redirect field-collection to index

RewriteCond %{REQUEST_URI} ^/field-collection
RewriteRule ^ index.php [R=301,L]

If your Drupal installation is in a subdirectory, change RewriteCond:
RewriteCond %{REQUEST_URI} ^/<subdirectory>/field-collection

Or just redirect one collection...
RewriteCond %{REQUEST_URI} ^/field-collection/field-<fieldname>

Typical disclaimer here: only tested on my own server, test well before using in a production environment, etc.

mrharolda’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev
Category: support » feature

Line 820 of field_collection.module reads "As of now there is no UI for setting the path.".

... but it looks like that's the only thing that is missing?!?

If I hack a 'path' form element into the field settings, use it and clear the menu cache, it just works!

Any reason for not enabling this?

feuillet’s picture

I would love to see a way to customize field_collection path elements.

If I hack a 'path' form element into the field settings, use it and clear the menu cache, it just works!

How exactly have you done that? Would you bother posting the code to solve this issue?

Thx!

Best Regards,
Sandro

pere orga’s picture

amir simantov’s picture

Sharing my code, as well.
Removing access to paths like /field-collection/NAME_OF_FIELD/FC_ENTITY_ID

/**
 * Implements hook_field_collection_item_view().
 */
function MYMODULE_field_collection_item_view($field_collection_item, $view_mode, $langcode) {
	if (arg(0) !== 'field-collection') {
		return;
	}

	if (user_has_role(3)) { // Administrator
		drupal_set_message("Access is disabled for non-admin.", 'warning');
		return;
	}

	drupal_access_denied();
}
jmuzz’s picture

For defining paths other than field-collection it may be best to use pathauto with the patch in this issue #1525352: Add pathauto support.