-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Added using statement to the Razor Helper usage example #17040
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ Many extensions methods are available in Razor with `@Orchard`. | |
If you want to use an extension method in a view, you can inject an `IOrchardHelper` named `Orchard` at the top of your file: | ||
|
||
```csharp | ||
@using OrchardCore | ||
@inject OrchardCore.IOrchardHelper Orchard | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did end up adding mine to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, the But otherwise yeah, you could clarify with e.g.: // You can also put this into a _ViewImports.cshtml file so it's applied to all templates.
@using OrchardCore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah, I misunderstood. I will remove the |
||
``` | ||
|
||
|
@@ -52,6 +53,7 @@ In `OrchardCore.DisplayManagement.Razor`, there is a RazorPage that already has | |
If you want to use an Orchard helper in a controller, you can inject an instance in the constructor: | ||
|
||
```csharp | ||
using OrchardCore; | ||
private IOrchardHelper _orchard; | ||
|
||
public MyClass(IOrchardHelper orchard) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is right if it's not in the
_ViewImports.cshtml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not there by default.