Skip to content

Update doc #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update doc #258

wants to merge 1 commit into from

Conversation

Florian-Merle
Copy link
Collaborator


### Opening a link in a new tab

Target blank directive can be added to link that either are top level menu items without children or children items. In other words this can be configured to item that do not have children.
Copy link
Member

@diimpp diimpp May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Target blank directive can be added to link that either are top level menu items without children or children items. In other words this can be configured to item that do not have children.
Target blank directive can be added to links that either are top-level menu items without children or children items. In other words, this can be configured to items that do not have children.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this sentence is redundant with the next one on line 98 - I think we should delete this one entirely up to line 96 and only keep the line 98 one which is much better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the doc like @stlgaits suggested

{
$menu = $this->factory->createItem('root');
// ...
$this->aaddApiDocMenuddApiDocMenu($menu);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->aaddApiDocMenuddApiDocMenu($menu);
$this->addApiDocMenu($menu);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if we're to follow existing examples, this should be named submenu instead.

Suggested change
$this->aaddApiDocMenuddApiDocMenu($menu);
$this->addApiDocSubMenu($menu);

Comment on lines 118 to 125
private function addApiDocMenu(ItemInterface $menu): void
{
$library = $menu
->addChild('api_doc', [
'route' => 'api_doc',
])
->setLabel('app.ui.api_doc')
->setLabelAttribute('icon', 'tabler:api')
->setLinkAttribute('target', '_blank') // Opens the link in a new tab
;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private function addApiDocMenu(ItemInterface $menu): void
{
$library = $menu
->addChild('api_doc', [
'route' => 'api_doc',
])
->setLabel('app.ui.api_doc')
->setLabelAttribute('icon', 'tabler:api')
->setLinkAttribute('target', '_blank') // Opens the link in a new tab
;
}
private function addApiDocSubMenu(ItemInterface $menu): void
{
$apiDoc = $menu
->addChild('api_doc', [
'route' => 'api_doc',
])
->setLabel('app.ui.api_doc')
->setLabelAttribute('icon', 'tabler:api')
->setLinkAttribute('target', '_blank') // Opens the link in a new tab
;
}

}
```

>>>>>>> Stashed changes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>>>>>> Stashed changes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

{% tabs %}
{% tab title="YAML" %}
{% code title="config/packages/sylius_bootstrap_admin_ui.yaml" lineNumbers="true" %}
```yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be cool to have php example as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, and maybe a small screeenshot of the browser tab as well to make it extra explicit?

{% endcode %}
{% endtab %}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

return $menu;
}

private function addApiDocMenu(ItemInterface $menu): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I would prefer some other example external submenu/url name than api doc, something in line with books and library from test app and other example snippets.

WDYT @loic425 @stlgaits

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good point to try to remain in userland - possibly an external link to the bookstore's website / blog or to something related to the books ecosystem like Goodreads new releases for instance (e.g. https://www.goodreads.com/book/popular_by_date/2025/5?ref=nav_brws_newrels) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to a link to the website homepage. This is not in the test app, but we've got something similar in Sylius/Sylius

{% tabs %}
{% tab title="YAML" %}
{% code title="config/packages/sylius_bootstrap_admin_ui.yaml" lineNumbers="true" %}
```yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, and maybe a small screeenshot of the browser tab as well to make it extra explicit?


### Opening a link in a new tab

Target blank directive can be added to link that either are top level menu items without children or children items. In other words this can be configured to item that do not have children.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this sentence is redundant with the next one on line 98 - I think we should delete this one entirely up to line 96 and only keep the line 98 one which is much better.


Target blank directive can be added to link that either are top level menu items without children or children items. In other words this can be configured to item that do not have children.

This can be configured by setting a link attribute on a menu item:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This can be configured by setting a link attribute on a menu item:


### Opening a link in a new tab

Target blank directive can be added to link that either are top level menu items without children or children items. In other words this can be configured to item that do not have children.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Target blank directive can be added to link that either are top level menu items without children or children items. In other words this can be configured to item that do not have children.

You can make a link open in a new browser tab by adding the `target="_blank"` link attribute to menu items. This can be applied to top-level menu items without children, or to child items themselves. In other words, it only works for items that do not have submenus.

To configure this behavior, set the target link attribute on the menu item as shown below:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% code title="src/Menu/MenuBuilder.php" lineNumbers="true" %}

}
}
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% endcode %}

return $menu;
}

private function addApiDocMenu(ItemInterface $menu): void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good point to try to remain in userland - possibly an external link to the bookstore's website / blog or to something related to the books ecosystem like Goodreads new releases for instance (e.g. https://www.goodreads.com/book/popular_by_date/2025/5?ref=nav_brws_newrels) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants