I hope someone can help me with this, as I am still very new to Drupal and don't know how to proceed. I have used the Display Suite, Node Comments, and Read More Link modules to construct the teaser and full-node builds of my story node. I am pleased with the results, except for the Author and Post Date information. Below you can see what the teaser looks like and bellow that you can see what I want.

Story Title
Admin
08/05/2010 - 21:40
Story Body Story Body Story Body Story Body Story Body Story Body Story Body
Story Body Story Body Story Body Story Body Story Body Story Body ... read more »
* 1 comment

Story Title
Submitted by Admin on Thursday, August 5, 2010:
Story Body Story Body Story Body Story Body Story Body Story Body Story Body
Story Body Story Body Story Body Story Body Story Body Story Body ... read more »
* 1 comment

To that end, I installed the Submitted By module, but the text and tokens that I entered into the "story" content type do not replace the Author and Post Date, as I had hoped. (And, in fact, I have never seen this line "Submitted by, etc." in any of my test postings, although my global theme settings should have enabled that line to appear in the "story" content type..)

Here is what the HTML looks like:

<div class="box-content clear-block">
<div class="buildmode-teaser">
<div class="node node-type-story  clear-block">
<div class="nd-region-middle-wrapper   nd-no-sidebars" ><div class="nd-region-middle"><div class="field field-title"><h1><a href="/node/6">Story Title</a></h1></div><div class="field field-author">Admin</div><div class="field field-post-date">08/05/2010 - 21:40</div><div class="field field-body"><p>Story body, etc.<span class="read-more"><a href="/node/6" title="Read the whole post" rel="nofollow"><strong>... read more &raquo;</strong></a></span></p>
</div><div class="field field-links"><ul class="links inline"><li class="comment_comments first last"><a href="/node/6#comments" title="Jump to the first comment of this posting.">1 comment</a></li></ul></div></div></div>  </div> <!-- /node -->
</div> <!-- /buildmode -->
</div>

QUESTION: How do I change this? I do not see any way to change this in Display Suite and I (don't yet) have any PHP skills. I appreciate all help - thanks!

Comments

finnishtango’s picture

Title: "Submitted by" line in Display Suite » [Resolved] "Submitted by" line in Display Suite
Status: Active » Closed (fixed)

It appears that Display Suite was preventing the "Submitted by" line from being displayed. I was able to accomplish what I wanted by not using Display Suite.

pfrenssen’s picture

Title: [Resolved] "Submitted by" line in Display Suite » "Submitted by" line in Display Suite
Version: 6.x-1.3 » 7.x-2.x-dev
Component: Documentation » Code
Category: support » feature
Status: Closed (fixed) » Active

I needed this today and I could not find how to display a proper submitted by-line using DS. There are the 'Author' and 'Post Date' fields but these don't really cut it. In core the submitted by-line is generated in template_preprocess_node(), so this is not available as a field in DS.

I ended up creating a custom field, with a bit of help from the Date module:

/**
 * Implements hook_ds_fields_info().
 */
function MODULE_ds_fields_info($entity_type) {
  $fields = array();

  $fields['submitted_by'] = array(
    'title' => t('Submitted by'),
    'field_type' => DS_FIELD_TYPE_FUNCTION,
    'ui_limit' => array('*|*'),
    'function' => '_MODULE_ds_field_submitted_by',
  );

  return array('node' => $fields);
}

/**
 * Render a "Submitted by"-line.
 */
function _MODULE_ds_field_submitted_by($field) {
  $date = new DateObject($field['entity']->created);
  $date_options = array(
    'start_date' => $date,
    'end_date' => $date,
    'interval_display' => 'raw time ago'
  );
  $timeago = '<span class="date-time-ago">' . t('!time ago', array('!time' => theme('date_time_ago', $date_options))) . '</span>';

  $account = user_load($field['entity']->uid);
  $username = theme('username', array('account' => $account));

  return t('Submitted !timeago by !username', array('!timeago' => $timeago, '!username' => $username));
}

Wouldn't it be a good idea to provide this too in DS? We are already providing custom fields for other node metadata such as the node title, 'read more'-link etc. It would be a nice addition, especially if some degree of customization would be provided.

swentel’s picture

makes sense yeah, but I don't want to depend on the date module for this one :)

pfrenssen’s picture

Assigned: Unassigned » pfrenssen

No of course not ;) This was just something I bashed out quickly to meet a client request. I'll make a more fitting implementation.

alexweber’s picture

@pfrenssen any progress on this?

I recently had the exact same problem and ended up creating a custom code field in DS which solved it for me but it just feels hacky.

pfrenssen’s picture

Ouch I should not make false promises :) I have actually not done any further work on this, but thanks for putting it on my radar again.

pfrenssen’s picture

Assigned: pfrenssen » Unassigned
Status: Active » Needs review
StatusFileSize
new3.2 KB

Here's a patch. It adds a "Submitted By" field which supports standard date formats + a "time ago" format which is the default. I added a test as well.

Note: the 'Node Display' test throws a warning on PHP 5.4 atm, but this is due to a bug in core: #1525176: Using array_diff_assoc() for multilevel arrays in DrupalDefaultEntityController->cacheGet().

swentel’s picture

Issue tags: +RC blocker

tagging

swentel’s picture

Status: Needs review » Fixed
Issue tags: -RC blocker

Thanks fixed!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

murrayw’s picture

Status: Closed (fixed) » Active

I have reopened this ticket because I believe the accepted patch introduces a problem.

Creating the submitted_by field in DS clobbers the settings made using the submitted_my module.
http://drupal.org/project/submitted_by

Take a look at submitted_by_field_extra_fields().

For me the bug manifests itself as:
- the incorrect formatter displaying in the display view modes. ie. DS field has taken over
- a missing submitted by field when rendered.

When I comment out the patch, I get my old submitted_by field back.

I'm not sure what the best way forward is with this, given that the new DS field will be in use. I would suggest that the submitted_by module should have priority :) Maybe this new field could be renamed. Or even better, removed. The submitted_by module is already performing this task in a more flexible way as it allows the use of tokens.

pfrenssen’s picture

That's unfortunate. Indeed if people have the Submitted By module enabled it is obvious that they would like this to manage their submitted by-lines.

There is a difference in implementation. DS is using its own pseudo-field system, while Submitted By adds a regular Field API field using hook_field_extra_fields(). We could check whether the 'submitted_by' field exists, but I think it is maybe cleaner to just skip our code when the Submitted By-module is enabled.

pfrenssen’s picture

Status: Active » Needs review
StatusFileSize
new1.47 KB

Here's a patch. Can you check if this solves your problem?

murrayw’s picture

Thanks! That patch works for me. Nice solution.

swentel’s picture

Status: Needs review » Fixed

Alright, committed and pushed, thanks!

swentel’s picture

Version: 7.x-2.x-dev » 8.x-2.x-dev
Status: Fixed » Patch (to be ported)

Moving to 8.x though

swentel’s picture

Status: Patch (to be ported) » Closed (fixed)

Ported (as in, changed the machine name to ds_submitted_by)

Colin @ PCMarket’s picture

Though this patch fixes the submitted by byline text problem with DS on the node itself it seems that the problem still exists when using DS in the node comments as my byline text in comments seems to be ignored.

samwillc’s picture

I'm getting same type of problem. I cannot override the submitted by line in my template.php when I add this field via DS. If I add the same field to the node and don't use DS, my changes are respected.