Problem/Motivation

We already print title_suffix and the entity attributes, but contextual links are not present in the wiki overview.
This is especially important to have edit links in the overview.

If we can't provide contextual links for technical reasons, we should provide custom edit links.

https://www.drupal.org/docs/drupal-apis/menu-api/providing-module-define...

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#9 firefox_iSbwJJk7lM.png13.06 KBthomas.frobieter
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

thomas.frobieter created an issue. See original summary.

thomas.frobieter’s picture

Issue summary: View changes

lrwebks made their first commit to this issue’s fork.

lrwebks’s picture

Status: Active » Needs work
anybody’s picture

Assigned: lrwebks » Unassigned
Priority: Normal » Minor

Don't waste too much time here, this isn't really important. Skip it, if it and leave as-is, if it takes more than 15min.

anybody’s picture

@thomas.frobieter still missing, any ideas how to fix?

lrwebks’s picture

We are already rendering the entity in full view mode, so I am unsure why the contextual links are not added automatically.

/**
   * Converts the BaseFieldDefinitions to a WikiEntry object.
   */
  public function toValueObject(): ProjectWikiValueObjectInterface {
    $view_builder = \Drupal::entityTypeManager()->getViewBuilder('project_wiki_entity_content');
    $content = $view_builder->view($this);

    return new ProjectWikiValueObject('project_wiki_entity_content', $this->get('id')->value, $this->get('langcode')->value, $this->get('category')->value, $this->get('title')->value, $content, $this->get('isDeveloperContent')->value);
  }

Maybe we need to add content_attributes?

<div {{ content_attributes.addClass(['project-wiki-entry__teaser', 'list-js-content']) }}>
        {{ content }}
      </div>
thomas.frobieter’s picture

Assigned: thomas.frobieter » Unassigned
Issue summary: View changes
StatusFileSize
new13.06 KB

I don't have anything else to add. The template is correct. See, for example:

https://api.drupal.org/api/drupal/core%21modules%21block%21templates%21b...

oder

https://api.drupal.org/api/drupal/core%21modules%21node%21templates%21no...

On the output side, a 'contextual-region' class should be added automatically through attributes (not content_attributes). And title_suffix should print the contextual menu:

Drupal Contextual Links Markup example

thomas.frobieter’s picture

Assigned: Unassigned » lrwebks
anybody’s picture

Assigned: lrwebks » Unassigned
Priority: Normal » Minor
Status: Needs work » Active

@thomas.frobieter then it sounds like it's not worth it? Maybe we'll find the reason and resultion one day?

thomas.frobieter’s picture

Assigned: Unassigned » thomas.frobieter

Maybe, but we should add a custom 'Edit' button. At the moment, you have to go to the entry details page and click on the 'Edit' tab, which is a bit annoying.

So I'll take over.

lrwebks’s picture

Assigned: thomas.frobieter » Unassigned

I think I get what's the problem here. It's not a semantic one, since even after manually adding the contextual-region class via twig does not make anything appear even though the contextual library is properly loaded on the page.

The actual issue is that we in fact are not actually rendering a real entity here, despite it looking like that. Even though we discussed it before (“it's rendered in full view mode”, etc.) that is not what is happening. The controller asks the plugin manager to gather all wiki entries from all providers, meaning both markdown and content entities. And to turn both types into a compatible format we convert them both to ProjectWikiValueObjects via their plugin definitions. These value objects are not Drupal entities though but rather simple PHP classes. So it is clear that the contextual links library does not think of the rendered output as a place to attach links to even though the contextual class is there. It simply does not know what to do with it.

So I do not see a feasible way to implement this. Either we try for something like a links.contextual.yml which could be really cumbersome to get it to work specifically for content entries, or we find out what makes the contextual links library think that some rendered content is a content entity.

lrwebks’s picture

Assigned: Unassigned » thomas.frobieter
anybody’s picture

links.contextual.yml would be too much.

We either find a way to render it "regularly" somehow or build a workaround for content entities for now.

@thomas.frobieter this is what copilot says:
https://copilot.microsoft.com/shares/WkTEFtXmdrfzbs2x3Ca31

So maybe we're just missing {{ title_suffix }} ?

thomas.frobieter’s picture

No. See #9. I'll add the custom edit link (if user has permission 'administer project_wiki_entity_content').

lrwebks’s picture

@thomas.frobieter, do you have a way to discern what kind of entry (markdown or content) is rendered in twig? Or should I add a parameter for you?

thomas.frobieter’s picture

Assigned: thomas.frobieter » anybody
Status: Active » Needs review

Done. It's already been tested and the link and permission check are working well.

anybody’s picture

Assigned: anybody » Unassigned
Status: Needs review » Reviewed & tested by the community
thomas.frobieter’s picture

Assigned: Unassigned » thomas.frobieter
Status: Reviewed & tested by the community » Needs work

@thomas.frobieter, do you have a way to discern what kind of entry (markdown or content) is rendered in twig? Or should I add a parameter for you?

Good point. I forgot about the Markdown entries, let me check this..

thomas.frobieter’s picture

We already have: provider string (29) "project_wiki_markdown_content", this should do it!

lrwebks’s picture

Glad that thinking ahead pays out at least sometimes, even if three years later... :D

thomas.frobieter’s picture

Status: Needs work » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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