Skip to content
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

Documentation: "Customize Admin Branding" code sample is unclear #16198

Closed
ccnicholls99 opened this issue May 30, 2024 · 8 comments
Closed

Documentation: "Customize Admin Branding" code sample is unclear #16198

ccnicholls99 opened this issue May 30, 2024 · 8 comments

Comments

@ccnicholls99
Copy link

DocLink: https://docs.orchardcore.net/en/latest/reference/modules/Admin/
Section: Customize Admin branding, code sample.

Code Sample includes the use of @Site.SiteName but does not give reference on how to access the symbol "@Site". I was able to work it out by digging through past issues and code but, there goes another 30 minutes of my life ;-)

Expected behavior

One way I found (perhaps there is a better way?) was just add these lines to the view...
`@inject OrchardCore.Settings.ISiteService SiteService

@{
var Site = await SiteService.GetSiteSettingsAsync();
}
`
These lines added to the Code sample might save future explorers some time.

Screenshots

image

Copy link
Contributor

Thank you for submitting your first issue, awesome! 🚀 We're thrilled to receive your input. If you haven't completed the template yet, please take a moment to do so. This ensures that we fully understand your feature request or bug report. A core team member will review your issue and get back to you.

If you like Orchard Core, please star our repo and join our community channels.

@Piedone
Copy link
Member

Piedone commented May 30, 2024

You shouldn't really need to do that. The default shape template does the same as the code sample in the docs. Site is a property on the view and thus available by default.

Probably you need this line in your theme's _ViewImports.cshtml (see the built-in one)?

@inherits OrchardCore.DisplayManagement.Razor.RazorPage<TModel>

@ccnicholls99
Copy link
Author

OK. Nice thanks for the heads-up, I was there was something I was missing.

Although if I put that in _ViewImports.cshtml then every other Razor Page in my project backed by a model will throw an error. If I put it in just the _Layout.cshtml instead, then it appears to work without issue.

Either way, it would be helpful to have the above advice in the documentation page I highlighted.

@Piedone
Copy link
Member

Piedone commented May 30, 2024

Sorry, I'm confused about what exactly you're doing. Can you share the code?

Because I don't understand how you're using Razor Pages. Or by "Razor Page" do you mean a Razor view template? Do you have a custom Admin theme as explained here? You shouldn't need a _Layout file there, and that's definitely not the recommended approach.

@ccnicholls99
Copy link
Author

All I am trying to point out is that the code sample presented in the documentation page is missing the details on how to get a reference to the Symbol @Site.Sitename. I think you could clarifiy this by adding one or two lines of extra code to the sample...(razor example) to make it obvious where the @Site symbol is coming from...

@* ...In a custom Admin theme: Site variable is automatically available using... *@
@inherits OrchardCore.DisplayManagement.Razor.RazorPage<TModel>
@* ...from a random layout or view...inject the SiteService...*@
@inject OrchardCore.Settings.ISiteService SiteService
@{  var Site = await SiteService.GetSiteSettingsAsync(); }

[rest of Code Sample]

@Piedone
Copy link
Member

Piedone commented Jun 3, 2024

OK, thanks for explaining. Though neither should really be needed:

  • If you're in an (admin) theme, then this inherits is already implied (at least if you generated the theme with the OC codegen templates or followed the docs). So the Site property should be available.
  • In other cases, while indeed you need to resolve ISiteService to access the site settings, that's not about customizing the admin branding anymore. For that, you need an admin theme.

So I'm just confused about what exactly are you doing and thus unclear about which part of the documentation needs to be updated.

Copy link
Contributor

It seems that this issue didn't really move for quite a while despite us asking the author for further feedback. Is this something you'd like to revisit any time soon or should we close? Please reply.

@github-actions github-actions bot added the stale label Jun 23, 2024
Copy link
Contributor

Closing this issue because it didn't receive further feedback from the author for very long. If you think this is still relevant, feel free to reopen it with the requested details.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants