I have contenty type in which I am referencing to another node. In node display setting, I set hide title (also on referenced node). I choosed to render entity and whole content.

But still, when I am displaying node, I have link to referenced content displayed. How can I hide it? (not via css, but definetly not render it).

Comments

haydeniv’s picture

Under your content type click on the Manage Display tab. On the line with your entity reference field there should be a sprocket button on the far right column. Click on that and uncheck "Link label to the referenced entity"

adelka’s picture

StatusFileSize
new32.15 KB

I don't have this option.. see enclosed printscreen.

haydeniv’s picture

Change the format to "Label" first instead of "Rendered Entity".

adelka’s picture

well, its not the solution I am looking for.
I need to render entity, but without the link to reffered content.

haydeniv’s picture

Status: Active » Closed (works as designed)

Ah I seem to have misunderstood what you are looking for. Entity Reference does not have much control on the way the entity is rendered. That is at the theme layer. Basically you are telling it to render the full node where that field is. ER assumes you want the title displayed when it calls entity_view() http://drupalcontrib.org/api/drupal/contributions!entity!entity.module/function/entity_view/7.

As a consequence $title is passed to node.tpl.php in your theme and renders the title according to your theme which most likely wraps the title in a link. To change that you will need to modify node.tpl.php in your theme. You'll probably want to include some kind of condition in there for the view_mode so that it does not link for full view but still links for teaser view, unless you don't care about the title linking in the teaser. There are many resources out there for how to override the node.tpl.php file. Hope that helps.

batigolix’s picture

Issue summary: View changes

Indeed as explained in #5: when a entity reference is rendered as a full node than it will use node.tpl.php. That template contains a condition to check for the $page variable. If that is false than it prints the title of the node as a link.

The are various solutions (such as using a different view mode or tinkering with the tpl.php templates) but you can also clear the title using hook_node_view. On a page with a entity reference to a node this runs twice: once for the referencing node and once for the referenced node. It checks if the node is the same as the one returned by menu_get_object.

function MYMODULE_node_view($node, $view_mode, $langcode) {
  $page_node = menu_get_object();
  if ($node->nid != $page_node->nid) {
    $node->title = NULL;
  }
}

I have not seen any bad side effects, yet

Richard15’s picture

StatusFileSize
new78.36 KB

Nice solution but I still have the link under H2 :(

philsward’s picture

This one took me a minute to figure out.

It will require the Display Suite module to pull it all together.
- Display Suite
- Display Suite UI
- Display Suite Extras (I think this is required? I can't remember)

You will want to edit the Manage Display of the content being referenced, not the node or paragraph where the content contains the reference field.

With Display Suite, you can expose the "title" to the Manage Display area after changing the "layout" of the View Mode. I usually just pick 1 Column.

Once the layout is added, it exposes Title. Drag Title up to the visible area and hit the sprocket to edit the field. This will give you a "Link" select list, choose "no", update, save and done.