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

LoginForm_Edit shape unable to override the view #15799

Closed
nbalu opened this issue Apr 21, 2024 · 11 comments
Closed

LoginForm_Edit shape unable to override the view #15799

nbalu opened this issue Apr 21, 2024 · 11 comments

Comments

@nbalu
Copy link

nbalu commented Apr 21, 2024

It seems like that with the revamped login I'm unable to override the LoginForm.Edit.cshtml.

The LoginFormCredentials.cshtml works. Not sure what's wrong with the Edit.cshtml.

image

using: 1.9.0-preview-18184

@nbalu nbalu added the bug 🐛 label Apr 21, 2024
@Piedone
Copy link
Member

Piedone commented Apr 21, 2024

There were breaking changes, see: https://docs.orchardcore.net/en/latest/docs/releases/1.9.0/#users-module Please follow that.

@nbalu
Copy link
Author

nbalu commented Apr 21, 2024

Oh I've got it, just went through the pain of discovering how the shape looks like and read through all sections.

So my key takeaways and fix me if I'm wrong here:
Login.cshtml - still used key code snippet:
@await DisplayAsync(Model) to render the corresponding shape
image

Content here:
https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.Users/Views/LoginForm.Edit.cshtml
Where ContentZone get's rendered:
@await DisplayAsync(Model.Content)
image

Still I can override the LoginFormCredentials, but how should I name my LoginForm.Edit.cshtml to replace the original content?

Sorry for being a noobie here.

@Piedone
Copy link
Member

Piedone commented Apr 21, 2024

You should be able to place a LoginForm.Edit.cshtml file into your module that depends on OrchardCore.Users to override it, or a theme but only if you configure this:

image

What exactly did you try?

Also see this that may help for future such cases: https://github.com/Lombiq/Helpful-Extensions?tab=readme-ov-file#shape-tracing-helpful-extensions

@Piedone
Copy link
Member

Piedone commented Apr 21, 2024

Related: #15701

@hishamco
Copy link
Member

@MikeAlhayek could you please chime in

@MikeAlhayek
Copy link
Member

Hisham, I think @Piedone handled it.

If someone is overriding the Login.chtml, they should adhere to these changes. If you want to override Login.cshtml then you should render the LoginForm shape somewhere in your file. Then you can also override the sub views as needed.

@nbalu are you facing issues after reading @Piedone comments above?

@nbalu2
Copy link

nbalu2 commented Apr 21, 2024

Nope, so far I haven't checked the view resolutiin yet that Zoli suggested but my issue wasn't answered/solved.

What I did was to override:
Login.cshtml - whithin I called DisplayAsyc(Model)
LoginForm.Edit.cshtml - just removed the @t("Log in") to verify it works
LoginFormCredentials.cshtml

The first and last views I'm able to replace but LoginForm.Edit.cshtml is not overriden always the built in form gets generated.

I'm playing around with orchard and based ona design I'm creating a custom OIDC "server". Which is better then starting from scartch.

Though I need to touch every html that gets renderd to be able to style things.

@MikeAlhayek
Copy link
Member

MikeAlhayek commented Apr 22, 2024

So when you call DisplayAsync(Model) in the login.cshtml you are rendering the LoginForm_Edit shape using the "LoginForm.Edit.cshtml" since it has no alternates.

The LoginForm.Edit.cshtml will the. render LoginFormCredentials.cshtml in the Content zone and other views in other zones.

If you are having any issue, I suggest that you post the views you created to override the default templates so we can help you better.

If you want to override any of the default views as @Piedone stated, you'll need to define the same views in a Theme project, or in a module that has physical reference to Orchard.User package.

@MikeAlhayek
Copy link
Member

@nbalu did you figure it out or do you still think there is an issue?

@nbalu
Copy link
Author

nbalu commented Apr 23, 2024

Hey Mike,

yes I've just solved it. But this was a wierd lesson for me:

On github the paths are:
src/OrchardCore.Modules/OrchardCore.Users/Views/Account/Login.cshtml - this is a view
src/OrchardCore.Modules/OrchardCore.Users/Views/LoginForm.Edit.cshtml - this is a shape

Within my repo:
src/OrchardCore.Webapp/Views/OrchardCore.Users/Account/Login.cshtml - this is working
src/OrchardCore.Webapp/Views/OrchardCore.Users/LoginForm.Edit.cshtml - this do not

Turns out that shape resolution works only on root level thus this worked:
src/OrchardCore.Webapp/Views/LoginForm.Edit.cshtml


And logging at least shows that there's a shape, but still misleading as I've tried to map corresponding to it:

dbug: OrchardCore.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy[0]
      Binding 'Areas/OrchardCore.Users/Views/LoginForm.Edit.cshtml' as shape 'loginform_edit' for feature 'OrchardCore.Users'

It would be nice if the logger would show which path is treated as "Alternate" source and what's not. Plus if there would be a way to encapsulate them on feature basis. Even within a single project.


My issue with this way of coding is that it will be hard to distinct with what's overriden within orchard and what's my content definition. Plus I feel like "shape" should relate to content types not for "built-in" pages. 🤷

Though I'm in the accomodation phase where I try to oppress my coding instincts before judge any framework or authoring logic of yours before being experienced enough to argue with you 😆

This was a true RFTM issue of mine. And I really appriciate the responsiveness of the community of yours. It's great to see how helpful You are and respect what you are doing here. Kudos

@nbalu nbalu closed this as completed Apr 23, 2024
@Piedone Piedone added question and removed bug 🐛 labels Apr 23, 2024
@Piedone
Copy link
Member

Piedone commented Apr 23, 2024

Awesome!

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

No branches or pull requests

5 participants