I have the forward module set up and working (in conjunction with Referral Forward, though I don't think this is involved) and basically, the option:

Use custom display
If checked, Forward will use a custom view mode named "Forward" to build the node, if available (clear cache twice after enabling this option)

isn't having any effect. I have been trying to enable this for a few hours now, and have probably cleared the caches about 30 times over the course of the morning(!).

I have a custom display called Forward, which I have configured, and I have "proven" the forward module settings are updating, by changing the content of the e-mail etc. around in circles.. but no matter what, the default node teaser is included in the bottom of the e-mail.

I have tried switching the "include full node" option on and off in conjunction with this setting. It's slightly confusing as to whether this is required or not.

Has anyone else had trouble/success with the custom view "Forward" option on this module??

Comments

john.oltman’s picture

Assigned: Unassigned » john.oltman

It works on my test system. When you say you have a custom display defined - are you referring to the Manage Display page for the content type you are trying to forward? And you are clicking on the "Forward" button for that content type on the Manage Display page? That is where the custom display needs to be defined. Use my personal contact form to send me login credentials to your site if you want me to look at your configuration.

srlawr’s picture

Status: Active » Closed (works as designed)

Hi John, thank you for your reply, and offer to assist.

Firstly, I had followed your pointers regarding Custom view modes for the content type, so it was re-assuring to hear I was doing it right.

Secondly, I have now got to the bottom of the problem. It kicks off on line 925 of forward.module (included below). This is the logic that chooses the Forward custom view. What was happening, in my selection of test cases, was that, sometimes the Forward view of my node actually only returned an *empty* long text field (With hidden label). This is actually the correct behaviour of the site, as sometimes the forward module is being used to "send" an e-mail for a node the receiver isn't allowed to see anything about.

Because this view mode wasn't returning anything, the IF in the middle of this code block was firing, and thus the full node was then being included, giving the impression that the Forward custom view wasn't being run.

I have circumvented this by defaulting the node string to ALWAYS be at least "Sign up now to see!" so the view mode works.

<?php
if (variable_get('forward_custom_viewmode', FALSE)) {
        $view_mode = 'forward';
        field_attach_prepare_view('node', array($node->nid => $node), $view_mode);
        entity_prepare_view('node', array($node->nid => $node));
        $node->content += field_attach_view('node', $node, $view_mode, $langcode);
        $content->teaser = render($node->content);
      }
      if (empty($content->teaser)) {
        $view_mode = variable_get('forward_full_body', FALSE) ? 'full' : 'teaser';
        field_attach_prepare_view('node', array($node->nid => $node), $view_mode);
        entity_prepare_view('node', array($node->nid => $node));
        $node->content += field_attach_view('node', $node, $view_mode, $langcode);
        $content->teaser = render($node->content);
      }
?>

Thank you again. I'm not sure at the moment whether the "if (empty($content->teaser))" logic might need re-considering. I appreciate this is a fairly edge case, and the catch-all of not sending nothing is probably quite good in the majority of cases. I'll close works as intended for now, there are more important fish :)