Piranha.core: Add quick links to edit content

Created on 13 Dec 2019  Â·  13Comments  Â·  Source: PiranhaCMS/piranha.core

I'd like to propose a feature: when logged in to the Manager and browsing the site (not in preview mode), any post or page should have an "edit this"-link. Using it, it will launch the Manager with that page or post in edit mode.

This makes it much more easy to fix content while browsing the site as an admin. Quickly tap link and edit. In addition with a link from within the Manager to return to the site.

While the preview mode in Manager is an excellent tool, it focus more on continous editing and content production. This new feature would complement it by adding a quick "oh, must fix that - in and fix - out and continue" workflow.

(Another option would be in place edit in frontent but that seems like a much more comprehensive thing to do, if it is feasable or relevant at all.)

help wanted module request

Most helpful comment

I made a simple solution
In the page/post cshtml I added something like this:

<header>
   <h1>@Model.Data.Title</h1>
   <div class="post-meta">
      @Model.Data.Published.Value.ToString("yyyy-MM-dd")<span class="sep">&#8285;</span><a href="@archive.Permalink/category/@Model.Data.Category.Slug">@Model.Data.Category.Title</a>
      @if (User.Identity.IsAuthenticated)
      {
         <span class="sep">&#8285;</span>
         await Html.RenderPartialAsync("Partial/_Admin", Model.Data);
      }
   </div>

and the _Admin.cshtml looks like

@{
    var url = "";
    if (Model.TypeId.Contains("Page"))
    {
        url = $@"/manager/page/edit/{Model.Id}";
    }
    else
    {
        url = $@"/manager/post/edit/{Model.Id}";
    }
}
<a href="@url" target="_blank" title="Redigera"><i class="fas fa-edit"></i></a>

It adds a link to the manager for the page/post (edit icon), when logged in
bild

I don't need more right now...

All 13 comments

As we have no control over how the user application is built we really can't provide any functionality for this, however we can add this to the project templates so you get this feature out of the box when creating a new project. Any thoughts on this?

I think that is a quite reasonable solution. Since Piranha could be seen more of a framework with CMS features rather than a full blown CMS, I understand the limitations that comes with this - at least at a general level.

Providing such a feature to the templates is a good way. I guess there are both existing and future features and functions that is "just" presented like this: as examples in the templates. It's up to the developer of the site to use them.

This feature is a good combination with the "authored by" functionality and while the latter is not implemented quickly, it is good to have it in mind I believe.

As always it very simple to achieve.. If you're running 8.0 you could add this to your _Layout

Add to the top of the file
~ csharp
@using Microsoft.AspNetCore.Authorization
@inject IAuthorizationService Auth
~

Add where you like it
~ csharp
@if ((await Auth.AuthorizeAsync(User, Piranha.Manager.Permission.Admin)).Succeeded)
{
if (WebApp.CurrentPost != null)
{
Edit Post
}
else if (WebApp.CurrentPage != null)
{
Edit Page
}
}
~

And you could of course add more fine-grained permissions checks for each content type

When I read the proposed solution I can't think but: "doh, of course!"
Adding this to a template would be neat but nothing I would prioritize myself until "authored by" is in place.
I suggest keeping this ticket as you labeled it, a possible enhancement to the core templates.

That was a breeze to add and while more fine tuned links would be easy to add in a similar way, they won't be nescessary in my case.

Now I just "need" to deteermine a good css for it. =)

This would be a perfect issue for someone to create a module with embedded views and resources that can be added to web applications!

I made a simple solution
In the page/post cshtml I added something like this:

<header>
   <h1>@Model.Data.Title</h1>
   <div class="post-meta">
      @Model.Data.Published.Value.ToString("yyyy-MM-dd")<span class="sep">&#8285;</span><a href="@archive.Permalink/category/@Model.Data.Category.Slug">@Model.Data.Category.Title</a>
      @if (User.Identity.IsAuthenticated)
      {
         <span class="sep">&#8285;</span>
         await Html.RenderPartialAsync("Partial/_Admin", Model.Data);
      }
   </div>

and the _Admin.cshtml looks like

@{
    var url = "";
    if (Model.TypeId.Contains("Page"))
    {
        url = $@"/manager/page/edit/{Model.Id}";
    }
    else
    {
        url = $@"/manager/post/edit/{Model.Id}";
    }
}
<a href="@url" target="_blank" title="Redigera"><i class="fas fa-edit"></i></a>

It adds a link to the manager for the page/post (edit icon), when logged in
bild

I don't need more right now...

@goranhell neat! That solution is something that should be considered for the templates as mentioned earlier, I think!

@tidyui "create a module with embedded views and resources that can be added to web applications" - could you elaborate? Do you mean like an embedded "mini-manager" when tapping an edit link of a page (as opposed to be directed to the actual manager like mentioned and showed here?)

@jensbrak I wasn’t really thinking along the lines of in-front edit. More of a good looking toolbar embedded as a razor component with style sheets and everything so you just need to register the module and then add the component to your layout 😊

Then we could add more tools to it besides “Edit content”, there could be options to add a new page after or beneath the page you’re looking at for example. Publish drafted pages directly from the preview and so on.

Here's another spin on the idea @jensbrak. Maybe we could add a "View site" button in the manager menu like in Ghost. Then it would be easy to add context buttons to perform actions related to the current page/post being viewed.

SkÀrmavbild 2020-06-12 kl  14 36 22

I believe that is an excellent idea.
I've missed that functionality to go from manager to the site myself. It
seems like a rather logical way to go about it.

On Fri, Jun 12, 2020 at 2:39 PM HÄkan Edling notifications@github.com
wrote:

Here's another spin on the idea @jensbrak https://github.com/jensbrak.
Maybe we could add a "View site" button in the manager menu like in Ghost.
Then it would be easy to add context buttons to perform actions related to
the current page/post being viewed.

[image: SkÀrmavbild 2020-06-12 kl 14 36 22]
https://user-images.githubusercontent.com/781266/84503406-6e247900-acba-11ea-8836-6612ddc115f1.png

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/PiranhaCMS/piranha.core/issues/947#issuecomment-643248839,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AMRYUW54E7GPMS57Y4DTOOLRWIOYDANCNFSM4J2JYPZQ
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gerardvanderkruijs picture gerardvanderkruijs  Â·  4Comments

w0ns88 picture w0ns88  Â·  6Comments

baibhavs picture baibhavs  Â·  3Comments

mtlc1402 picture mtlc1402  Â·  5Comments

tidyui picture tidyui  Â·  6Comments