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

Custom Manager Pages #25

Open
ecnerwal1234 opened this issue Mar 1, 2020 · 22 comments
Open

Custom Manager Pages #25

ecnerwal1234 opened this issue Mar 1, 2020 · 22 comments
Labels
enhancement New feature or request

Comments

@ecnerwal1234
Copy link

Are there any instructions on the best way to customize the manger? I see how to add to the menu, but are there examples of adding new content types in the admin?

@tidyui
Copy link
Member

tidyui commented Mar 3, 2020

Specify what you mean by "adding new content types"

@ecnerwal1234
Copy link
Author

Nothing terribly specific, I'm really just at the learning phase and I do best by practicing and playing around. But, what I was thinking was, I want to create some sort of custom content sections that could be pulled into different pages through custom blocks. For example, if I had a staff list, I would manage them in the admin and then add them to which ever page needs the staff to show. This way I don't have to repeat content input and if there is a change to one it will change anywhere it is shown.

@ecnerwal1234
Copy link
Author

I've been trying to see if I could make sense of how it is all set up in the source. Not really getting far in that, Is the platform built with the idea of people making custom management sections?

@tidyui
Copy link
Member

tidyui commented Mar 5, 2020

Sorry for not having the time to respond. You can add custom pages to the manager with either MVC or Razor Pages just like in any application and then add them to the menu. The only important thing to remember is that you should add them to the Manager Area, otherwise your pages won’t find the shared resources such as layout, partials and so on that is a part of the default manager.

A good example is to look at the Identity package which adds custom pages to the manager made with both MVC and Razor Pages.

https://github.com/PiranhaCMS/piranha.core/tree/master/core/Piranha.AspNetCore.Identity

Regards

@ecnerwal1234
Copy link
Author

Is there a more basic example? also when you say "add them to the manager area" do you mean the path here "Areas/Manager/Views"

@ecnerwal1234
Copy link
Author

And, thanks again for all your help. I'm really liking Piranha CMS even though it is taking me a while to fully grasp how to use it.

@tidyui
Copy link
Member

tidyui commented Mar 6, 2020

No problems! As soon as you run into things that’s unclear and needs more documentation, don’t hesitate to add an issue for it in our docs repo!

https://github.com/PiranhaCMS/piranha.core.docs

@tidyui
Copy link
Member

tidyui commented Mar 6, 2020

And when I say add to the manager area I mean.

  1. For MVC, attribute the controller with the “Manager” area and put views where you wrote.
  2. For Razor Pages, put the pages in /Areas/Manager/Pages

Regards

@tidyui
Copy link
Member

tidyui commented Mar 30, 2020

I'm transferring this issue to the documentation repo!

@tidyui tidyui transferred this issue from PiranhaCMS/piranha.core Mar 30, 2020
@tidyui tidyui added the enhancement New feature or request label Apr 10, 2020
@traustitj
Copy link

It probably won't be hard to mimic the identity part, but how do you get the manager to find it? How do you add it?

@tidyui
Copy link
Member

tidyui commented May 16, 2020

@traustitj Could you elaborate, I don't really understand what you mean 😊

@traustitj
Copy link

ok, lets say I write some easy name list management system. How do I add config so I can use it inside the management interface? Is there nothing to add in Configure and Configure services in startup.cs? How do I add a menu for the management? The add/edit/list functions. How do I get it to appear?

A small tutorial about just adding 1 string and have a list and adding inside the management system would be greatly beneficial.

@filipmatsman
Copy link
Contributor

@traustitj In the next version of the templates we have added an template for creating custom Piranha Module. This template contains an empty pages that is added to the manager menu and some permissions, an embedded file provider is also added for recourses.

I hope this will help you out a bit, you can find the sourse here:
https://github.com/PiranhaCMS/piranha.core.templates/tree/features/template-options/src/module

@traustitj
Copy link

@filipjansson Thank you. I don't need to add anything to startup.cs ?

@filipmatsman
Copy link
Contributor

@traustitj Yes, and what depends on how you want to do it.

But check out the TemplateModuleExtensions.cs class that has extensions methods for both PiranhaServiceBuilder and IServiceCollection, that do the same thing more or less.

It just gives you the option to write

services.AddPiranha(options =>
{
    ...
    options.UseManager();
    options.UseMyModule();
    ...
});

Or

services.AddMyModule();

@traustitj
Copy link

traustitj commented May 16, 2020

Hei. I get some errors. I made a clean project, added things as I think they fit, but it probably is just missing a tiny bit.
Also, I can just call any controller I want to? I know I can, just trying stick to best practices.

Here is the project
https://github.com/traustitj/piranhatestmodule

@tidyui
Copy link
Member

tidyui commented May 17, 2020

@filipjansson When the Menu item is created here:

https://github.com/PiranhaCMS/piranha.core.templates/blob/features/template-options/src/module/TemplateModule.cs#L60

It’s referencing the menu group “PiranhaModule”, but I can’t see any code creating it. Won’t this result in a NullReferenceException?

@tidyui
Copy link
Member

tidyui commented May 17, 2020

@traustitj
Copy link

@tidyui I updated my project based on your changes. But I still get an error on Menu.Items[....
If you could have a look at my project it would really be awesome and could be used for the documentation

@traustitj
Copy link

I just fixed the bug, the answer is to register a menu item first. The fix is in my repo.
Feel free to use it for helping with documentations

@filipmatsman
Copy link
Contributor

@tidyui @traustitj That is correct. I copied the codebase from another project of mine, but in that project I added the module under the Content section in the menu.

@tidyui
Copy link
Member

tidyui commented May 17, 2020

Yes @traustitj That fix was present in the changes I pushed (https://github.com/PiranhaCMS/piranha.core.templates/blob/features/template-options/src/module/Module.cs#L60). I tested the template on a new project before committing the changes

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

No branches or pull requests

4 participants