I have different feeds for different groups of users, some of whom are not very technically savvy. It would be nice to have a "Explanation or submission guidelines" section like Content Types have (see image). I would image it would go in the Basic Settings fieldset.

The text entered in the "Explanation or submission guidelines" section would show up at the beginning of the /feed/add/[feed type] pages, so that content editors using the feed could read the instructions before saving/uploading a new feed.

It would be different per Feed type.

Comments

andileco created an issue. See original summary.

andileco’s picture

Issue summary: View changes
megachriz’s picture

An alternative would be to add a markup field to the feed entity type (because feeds_feed entities are fieldable), but I suppose we could add a field to the basic settings as well.

Sidenote: I did notice some validation issues when trying to import as an user with less privileges using the UI. This happens when you want your users to import content that they may not create manually. I've been working on fixing this in the case that feeds are created in advance by an admin user: #2811429: Switch to feed owner during manual import..

andileco’s picture

Thanks for weighing in and the other information about the validation issues (those will be useful for me). To my knowledge, you would have to add a new module to get a Markup Field (which I've done on another site, but I didn't love). But let me know if I'm missing something! But my preference would to be have it more like how it's implemented in Core.

andileco’s picture

Hi @MegaChriz, I added a patch that is very similar to how Core does this in the Node module. However, nothing shows on the actual /feed/add/* page. I'm thinking this is because something needs to be done inside feeds_help()

in node_help(), you can find the following:

    case 'entity.node.edit_form':
      $node = $route_match->getParameter('node');
      $type = NodeType::load($node->getType());
      $help = $type->getHelp();
      return (!empty($help) ? Xss::filterAdmin($help) : '');

    case 'node.add':
      $type = $route_match->getParameter('node_type');
      $help = $type->getHelp();
      return (!empty($help) ? Xss::filterAdmin($help) : '');

However, I'm not seeing the equivalent routes in feeds.routing.yml. Do you know what I might be missing?

megachriz’s picture

I haven't tried, but I think the routes start with entity.feeds_feed. and then need to be complemented with something that is listed on the "links" section in the annotation of the \Drupal\feeds\Entity\Feed class:

 *   links = {
 *     "canonical" = "/feed/{feeds_feed}",
 *     "add-page" = "/feed/add",
 *     "add-form" = "/feed/add/{feeds_feed_type}",
 *     "delete-form" = "/feed/{feeds_feed}/delete",
 *     "edit-form" = "/feed/{feeds_feed}/edit",
 *     "import-form" = "/feed/{feeds_feed}/import",
 *     "schedule-import-form" = "/feed/{feeds_feed}/schedule-import",
 *     "clear-form" = "/feed/{feeds_feed}/delete-items"
 *   }

Feeds uses the route provider "\Drupal\Core\Entity\Routing\AdminHtmlRouteProvider" to generate the routes for the feeds_feed entity type. That derives from \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider, which says in the docblock the following:

/**
 * Provides HTML routes for entities.
 *
 * This class provides the following routes for entities, with title and access
 * callbacks:
 * - canonical
 * - add-page
 * - add-form
 * - edit-form
 * - delete-form
 * - collection
 * - delete-multiple-form
 *
 * @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider.
 */
megachriz’s picture

If I look at the implementation of DefaultHtmlRouteProvider::getRoutes() I see underscores used instead of dashes:

    if ($add_form_route = $this->getAddFormRoute($entity_type)) {
      $collection->add("entity.{$entity_type_id}.add_form", $add_form_route);
    }

    if ($canonical_route = $this->getCanonicalRoute($entity_type)) {
      $collection->add("entity.{$entity_type_id}.canonical", $canonical_route);
    }

    if ($edit_route = $this->getEditFormRoute($entity_type)) {
      $collection->add("entity.{$entity_type_id}.edit_form", $edit_route);
    }

So I assume one of the routes must be entity.feeds_feed.edit_form, not entity.feeds_feed.edit-form.

andileco’s picture

Status: Active » Needs review
StatusFileSize
new3.58 KB

OK, this patch should work. Will need to be sure to clear caches since the schema changes. Also, one needs to make sure that their admin theme is getting the block on the /feed/* pages.

dinesh18’s picture

Status: Needs review » Needs work
StatusFileSize
new146.15 KB

Looks good to me except trailing whitespace errors

explanation-submission-guidelines-3080985-8.patch:99: trailing whitespace.
      '#description' => $this->t('This text will be displayed at the top 
Checking patch config/schema/feeds.schema.yml...
Checking patch feeds.module...
Checking patch src/Entity/FeedType.php...
Checking patch src/FeedTypeForm.php...
Hunk #1 succeeded at 127 (offset -1 lines).
Checking patch src/FeedTypeInterface.php...
Applied patch config/schema/feeds.schema.yml cleanly.
Applied patch feeds.module cleanly.
Applied patch src/Entity/FeedType.php cleanly.
Applied patch src/FeedTypeForm.php cleanly.
Applied patch src/FeedTypeInterface.php cleanly.
warning: 1 line adds whitespace errors.
andileco’s picture

Status: Needs work » Needs review
StatusFileSize
new3.58 KB

OK, I think this should fix the whitespace error.

  • MegaChriz committed 6dc5835 on 8.x-3.x authored by andileco
    Issue #3080985 by andileco, Dinesh18, MegaChriz: Include an "Explanation...
megachriz’s picture

Status: Needs review » Fixed

@andileco
Looks straightforward. I tried the patch and it works. One thing I noticed is that caches need to be cleared before the help text is displayed, but this is also the case with content types in core. I tried also to fill in some javascript code to make sure it isn't executed: text is escaped like it should.

Committed #10 with one change:
I removed one extra use statement in feeds.module (see coding standards message on https://www.drupal.org/pift-ci-job/1410197).

Status: Fixed » Closed (fixed)

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