Download & Extend

Cross-link content type settings from node add/edit form

Project:Drupal core
Version:8.x-dev
Component:node.module
Category:task
Priority:normal
Assigned:rootwork
Status:needs review
Issue tags:#SprintWeekend, Needs issue summary update, Needs usability review, Novice, SettingsAPI, UBUserTesting2009, Usability

Issue Summary

Motivation

Some users go to the content section, rather than the structure section, looking for options to edit content types.

Proposed resolution

On the node/add page, add links to edit the content types as well, for users who have the right permissions. This provides another way of navigating to admin/structure/types/manage/[node-type]

Remaining tasks

Summary of API changes
Needs review

User interface changes

Adds links to admin/structure/types/manage/[node-type] for each node type on the node/add page

Screenshot of UI before patch:
UI-before-patch

Latest screenshot of UI after patch (from comment #50):
ui-after-patch.png

Related Issues

Original report by catch

Many users go to the node/add and node/edit forms looking for settings (submitted information, input formats). We should consider adding links there to the admin screens for those form elements when users have the relevant permissions.

Comments

#1

Issue tags:+UBUserTesting2009

Fixing tag.

#2

Issue tags:-UBUserTesting2009

This might be good for the novice queue.

#3

Issue tags:+Novice, +UBUserTesting2009

Sorry, I screwed up the tags.

#4

Assigned to:Anonymous» lucaswoj

Hey, I'm completely new to Drupal development, but this looks like a great starter project. I'll see if I can get a patch done by tonight.
- Lucas

#5

First open source patch!

The method I use to do this is arguably a little hack-ey, but because of the way that drupal handles the node/add page, its the easiest and most efficient way. The node/add page stores the content types as menu items, and displays them back without any knowledge of the content type its describing. For me to provide a link to edit the content type, I have to reverse engineer the URL that goes with the menu item.

AttachmentSizeStatusTest resultOperations
contenttypeslink.patch1.27 KBIdleFailed: Failed to apply patch.View details | Re-test

#6

Status:active» needs review

#7

Status:needs review» needs work

The last submitted patch failed testing.

#8

Status:needs work» needs review

Fixed patch. Relative filename problems...

#9

Not sure why this failed to attach the first time

AttachmentSizeStatusTest resultOperations
contenttypeslink.patch1.25 KBIdleFailed: 10818 passes, 0 fails, 6 exceptionsView details | Re-test

#10

Status:needs review» needs work

The last submitted patch failed testing.

#11

Fixed errors with declaring variables. That will teach me to run my server in E_ALL...

AttachmentSizeStatusTest resultOperations
contenttypeslinkf.patch1.32 KBIdleFailed: Failed to apply patch.View details | Re-test

#12

Please, please be the last try. I have to manually change the file path because diff is being mean to me.

AttachmentSizeStatusTest resultOperations
contenttypeslinkf.patch1.31 KBIdlePassed: 11624 passes, 0 fails, 0 exceptionsView details | Re-test

#13

Status:needs work» needs review

#14

Status:needs review» needs work

Hey lucaswoj, your code is not adhering to the Drupal coding standards. If you look at the patch, you'll see that you're using tabs instead of spaces. It would be great if you could re-roll the patch with Drupal's coding standards in mind.

#15

Status:needs work» needs review

I'm sorry, I thought my IDE was already configured for spaces... I guess I've never really worried about it before.

For the 5th time, here we go....

AttachmentSizeStatusTest resultOperations
contenttypes-final.patch1.31 KBIdleUnable to apply patch contenttypes-final.patchView details | Re-test

#16

this worked for me.

#17

Status:needs review» needs work
Issue tags:+Usability

Thanks for your patch. It almost works as advertised - here are some remarks:

Inconsistency:
The patch indicates that line 25 replaces line 23, but they're identical so the patch should not indicate changes.

23:  -      $output .= '<dt>' . l($item['title'], $item['href'], $item['localized_options']) . '</dt>';
24:  -      [...]
25:  +      $output .= '<dt>' . l($item['title'], $item['href'], $item['localized_options']) . '</dt>';

Markup error:
On line 28 of your patch you're adding:

28: +      $output .= '</dt>';

but you really wanted to close the DD element opened on line 26, so line 28 should be:

28: +      $output .= '</dd>';

Usability:
The patch adds an 'Edit Content Type' link to the end of each Content Type definition on /node/add. However I only noticed that link after clicking around trying to find the changes introduced by the patch.

Wouldn't it make more sense to add the edit link next to the Content Type title? See attached screenshot.

Entities / wrapper:

27: +      $output .= isset($item['edit_href']) ? '&nbsp;<small>('.l(t('Edit Content Type'), $item['edit_href']).')</a></small>' : '';

I personally don't like the addition of a non-breaking space entity and wrapping the "Edit Content Type" link in small tags. The entity clutters up the code and by using the small tags we make assumptions on how this link should be displayed.

Adding a meaningful css class name is more versatile and less imposing.

AttachmentSizeStatusTest resultOperations
CreateContentEditCTLink.png191 KBIgnoredNoneNone

#18

Status:needs work» needs review

Thanks for the thoughtful feedback jpoesen. I think this updated patch fixes all of your concerns.

AttachmentSizeStatusTest resultOperations
cross-link-edit-node-type.patch1.93 KBIdleFailed: 11624 passes, 0 fails, 6 exceptionsView details | Re-test

#19

Status:needs review» needs work

The last submitted patch failed testing.

#20

Version:7.x-dev» 8.x-dev

This has unfortunately missed the string freeze for 7.

#21

Issue tags:+SettingsAPI

Yes, please.

#22

Assigned to:lucaswoj» Brian Altenhofel
Status:needs work» needs review

I was bored this evening, so here's a patch that brings #18 to D8, along with a clarification that the link is to edit the content type, rather than a link to bring up a view or something that would list all nodes of that type available for editing.

AttachmentSizeStatusTest resultOperations
content-type-edit-384150-22.patch1.57 KBIdleFAILED: [[SimpleTest]]: [MySQL] 34,177 pass(es), 0 fail(s), and 8 exception(es).View details | Re-test

#23

Status:needs review» needs work

The last submitted patch, content-type-edit-384150-22.patch, failed testing.

#24

Retry...

AttachmentSizeStatusTest resultOperations
content-type-edit-384150-24.patch1.62 KBIdlePASSED: [[SimpleTest]]: [MySQL] 34,196 pass(es).View details | Re-test

#25

Status:needs work» needs review

#26

Status:needs review» needs work

Coding standards
http://drupal.org/coding-standards

else if
should be:
elseif

$output .= $item['edit_href'] ? '<span class="node-type-edit">['
  . l(t('Edit content type'), $item['edit_href']) . ']</span>' : '';

Use one line dot concatenation or the operator .=

Same here:

$output .= '<dt>' . l($item['title'], $item['href'],
  $item['localized_options']);

better:

$output .= '<dt>' . l($item['title'], $item['href'], $item['localized_options']);

#27

Status:needs work» needs review

Better adherence to coding standards. (Sorry, got wrapped up in "80 characters per line".)

AttachmentSizeStatusTest resultOperations
content-type-edit-384150-27.patch1.6 KBIdlePASSED: [[SimpleTest]]: [MySQL] 34,118 pass(es).View details | Re-test

#28

Status:needs review» needs work

+++ b/core/modules/node/node.pages.inc
@@ -38,6 +38,12 @@ function node_add_page() {
+    //Generate links to edit content type if user has proper permissions

Based on other patches I've looked at recently, my understanding is that comments are supposed to have a space after the "//" and have sentence formatting, e.g.

// Generate links to edit content type if user has proper permissions.

Note that I applied the patch (in D8) and am not seeing anything come up on the node/add page while logged in as super-admin. I cleared the cache and that had no effect either.

#29

Drush wasn't working for clearing the caches so I changed the theme to clear the theme registry and now I see the links.

+++ b/core/modules/node/node.pages.inc
@@ -58,7 +64,11 @@ function theme_node_add_list($variables) {
+      if (isset($item['edit_href'])) {
+        $output .= $item['edit_href'] ? '<span class="node-type-edit">[' . l(t('Edit content type'), $item['edit_href']) . ']</span>' : '';

I think it would be good to add a space between the content type name and the "[", e.g.

$output .= $item['edit_href'] ? ' <span class="node-type-edit">[' . l(t('Edit content type'), $item['edit_href']) . ']</span>' : '';

#30

Also, there is no node.css anymore, that bit probably needs to be moved into node.admin.css

#31

Status:needs work» needs review

Updated patch.

Also noticed that the links don't appear when using the Seven theme. Tried applying the patch, creating a new empty database, then installing Drupal, used another browser that had not accessed my dev environment, and still didn't see them on Seven. That *should* rule out caching issues.

AttachmentSizeStatusTest resultOperations
content-type-edit-384150-31.patch1.64 KBIdlePASSED: [[SimpleTest]]: [MySQL] 35,356 pass(es).View details | Re-test

#32

Ahh... there's a template.php override in Seven...

Here's an updated patch...

Also cleaned up the "if" surrounding the addition. When I first worked on this in December, I admit that I was just being introduced to the ...?...:... syntax at the time.

AttachmentSizeStatusTest resultOperations
content-type-edit-384150-32.patch2.3 KBIdlePASSED: [[SimpleTest]]: [MySQL] 35,349 pass(es).View details | Re-test

#33

I've cleaned up the patch so that it works with modern Drupal 8 code... the previous patch was suffering from some bit-rot. The attached patch is functionally the same as the previous patch.

I've tested the attached patch myself, but would love to see some additional review so that we can get this pushed through.

AttachmentSizeStatusTest resultOperations
content-type-edit-384150-33.patch2.79 KBIdlePASSED: [[SimpleTest]]: [MySQL] 37,058 pass(es).View details | Re-test

#34

Status:needs review» reviewed & tested by the community

Applied patch, looks good, works for core and custom content types.

#35

Status:reviewed & tested by the community» needs work

Hmm I think I'd probably place the permissions check directly in the theme function rather than overloading the node type objects. Also is the new CSS absolutely necessary in node.admin.css or could that be put in seven theme instead?

#36

Status:needs work» needs review

This patch moves the CSS to Seven theme since it is not necessary to provide a default here. It also moves the call to user_access() and generation of content type edit links to theme_node_add_list().

AttachmentSizeStatusTest resultOperations
content-type-edit-384150-36.patch2.49 KBTest request sentPASSED: [[SimpleTest]]: [MySQL] 39,834 pass(es).View details

#37

#36: content-type-edit-384150-36.patch queued for re-testing.

#38

Applied #36 to bc1da65 and rerolled it.

It seems to work.

AttachmentSizeStatusTest resultOperations
content-type-edit-384150-38.patch2.47 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch content-type-edit-384150-38.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#39

Status:needs review» needs work

The last submitted patch, content-type-edit-384150-38.patch, failed testing.

#40

Status:needs work» needs review

#38: content-type-edit-384150-38.patch queued for re-testing.

#41

#38: content-type-edit-384150-38.patch queued for re-testing.

#42

Status:needs review» needs work

did a standards review. mostly looks good.

+++ b/core/modules/node/node.pages.incundefined
@@ -59,9 +59,17 @@ function theme_node_add_list($variables) {
+      // Generate links to edit content type if the current user has proper permissions.

+++ b/core/themes/seven/template.phpundefined
@@ -44,10 +44,17 @@ function seven_node_add_list($variables) {
+      // Generate links to edit content type if the current user has proper permissions.

comments should wrap at 80 chars. See: http://drupal.org/node/1354

#43

Status:needs work» needs review

Applied #38 and rerolled it.

Hope it will work.

AttachmentSizeStatusTest resultOperations
content-type-edit-384150-43.patch2.59 KBIdlePASSED: [[SimpleTest]]: [MySQL] 52,432 pass(es).View details | Re-test

#44

Thanks @mahaprasad!

#45

screenshots embedded in the issue summary with before and after would help. Also it would help to update the issue summary using the issue summary template.

#46

Issue tags:-Needs screenshot

Did a manual test of this patch. Works well but some minor issues.

1. There are brackets appearing in the output - see screenshot

UI-after-patch.png

2. The hover state for the 'Edit content type' links doesn't work - doesn't get an underline, as it should.

Also uploading a screenshot of the UI before to add to summary.

AttachmentSizeStatusTest resultOperations
UI-before-patch.png65.95 KBIgnoredNoneNone
UI-after-patch.png144.62 KBIgnoredNoneNone

#47

Status:needs review» needs work

Does this patch include any updates to node/edit pages? Couldn't find any, only saw changes to node/add. If there are proposed changes to the edit screen as well can someone provide more detail?

#48

Assigned to:Brian Altenhofel» rootwork
Status:needs work» needs review
Issue tags:+#SprintWeekend

Updated the patch from #43 to remove the extraneous brackets and give it the right span wrapper.

AttachmentSizeStatusTest resultOperations
content-type-edit-384150-48.patch2.57 KBIdlePASSED: [[SimpleTest]]: [MySQL] 53,176 pass(es).View details | Re-test
interdiff.txt1 KBIgnoredNoneNone

#49

Here's a new screenshot of the add content page with my revised patch.

It looks like the underlines on hover still aren't appearing. I'm going to try to track down what's going on in the CSS.

AttachmentSizeStatusTest resultOperations
Screen Shot 2013-03-10 at 5.36.24 PM.png40.69 KBIgnoredNoneNone

#50

Status:needs review» needs work

Sorry, changing status back to needs work and embedding the new screenshot.

ui-after-patch.png

AttachmentSizeStatusTest resultOperations
ui-after-patch.png40.69 KBIgnoredNoneNone

#51

Status:needs work» needs review

Fixed the hover link & aligned the links in one line.

Please find the attached patch.

AttachmentSizeStatusTest resultOperations
content-type-edit-384150-51.patch3.33 KBIdlePASSED: [[SimpleTest]]: [MySQL] 53,060 pass(es).View details | Re-test

#52

Thanks @mahaprasad, @rootwork, and @pameeela! The updates make it much easier to understand the proposed change.

The proposed pattern seems pretty confusing to me, and it's different from any pattern we have elsewhere. We have two links that say "edit content type" with nothing to distinguish them aside from their spacial placement. I would have no idea which link I was supposed to click on when going to this page.

For this to work at all, I think the link texts would need to be more specific, like "Add new basic page" and "Configure basic pages" or something. Also, elsewhere when we have multiple operations related to one thing, we use the dropbutton pattern.

Tagging for the UX team to give feedback.

#53

Applied the #51 patch & tested screen shot is attached.

patch-51

AttachmentSizeStatusTest resultOperations
after-patch-51.png28.54 KBIgnoredNoneNone

#54

Status:needs review» needs work

Minor in style.css
\ No newline at end of file

#55

Status:needs work» needs review

#56

@xjm (and useability reviewers), what if the pattern was more like the screenshot in #50? I actually thought that's what the previous patch was trying to create. I agree having the two links next to each other, with one in brackets, would be confusing.

What if they were on two separate lines, with the second line saying "Edit article content type," "Edit page content type," etc.?

Another option I could see is tacking it on to the end of the help text. So then it would say something like "Use articles for time-sensitive content like news, press releases or blog posts. Edit this content type." The edit link could be in parentheses, brackets, or italicized, although I think the fact that it's a link would probably set it apart enough.

#57

@rootwork @xjm I also think this is really confusing. I frequently do training for users new to Drupal and the concept of editing content vs editing content types is already hard to grasp. I think this blurs the line even further, by eliminating the content/structure split - which I see as a small hurdle to get over up front, but from there it makes a lot of sense.

I do appreciate this as an attempt to make things less confusing, so I am keen to see what the UX team thinks!

#58

@rootwork, #50 is exactly what I found very confusing. My review is about that screenshot.

#59

I'm reading the motivation in the issue summary:

Some users go to the content section, rather than the structure section, looking for options to edit content types.

I've seen this in Usability testing the multilingual stuff.
http://groups.drupal.org/node/285978 (g.d.o post). I have not gone through all the video to make notes yet. I'll come back and provide a specific example when I find it.

But, from memory, I think where they actually went was: admin/content (not the shortcut to add content):

content.png

And then tried the edit link for a particular piece of content when attempting to configure the content type in general.

on the add content page

But back to the add content page...
the text in [ ] reminds me of the [edit] [clone] [delete] links that used to show up when hovering over a view.

Consider:
1. What about using the word *structure*.
2. Also, since this is the add content page. We do not want the main emphasis to appear to be to edit the content type. (which it is I think in the screenshots previously posted)
3. Being specific about the links, so they are not identical.. there might be some code reusable from #1810386: Create workflow to setup multilingual for entity types, bundles and fields because we had to figure out the type of things when building the label for in input items.

a. Article[ Edit Article content type structure ]
b. Article[ Edit Article content type ]
c. Article[ Edit Article structure ]
d. Add an Article[ Edit Article structure ]

this shows a and b:
emphasis.png

but I think my favorite might be:

use_edit_hover_like_blocks.png

I would mark this needs work for that. But I think we still want a Usability review to point this in an acceptable direction.

[edit: added width= on the img's because my retina display yields giant screenshots]

AttachmentSizeStatusTest resultOperations
content.png244.8 KBIgnoredNoneNone
emphasis.png173.1 KBIgnoredNoneNone
use_edit_hover_like_blocks.png50.98 KBIgnoredNoneNone

#60

nobody click here