Coder Social home page Coder Social logo

dystudio / etch.orchardcore.contentpermissions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from etchuk/etch.orchardcore.contentpermissions

0.0 1.0 0.0 28 KB

Module for Orchard Core to enable configuring access at a content item level.

License: MIT License

C# 80.01% HTML 19.99%

etch.orchardcore.contentpermissions's Introduction

Etch.OrchardCore.ContentPermissions

Module for Orchard Core to enable configuring access at a content item level.

Build Status

Build Status NuGet

Orchard Core Reference

This module is referencing the RC1 build of Orchard Core (1.0.0-rc1-10004).

Installing

This module is available on NuGet. Add a reference to your Orchard Core web project via the NuGet package manager. Search for "Etch.OrchardCore.Fields", ensuring include prereleases is checked.

Alternatively you can download the source or clone the repository to your local machine. Add the project to your solution that contains an Orchard Core project and add a reference to Etch.OrchardCore.ContentPermissions.

Usage

Enabled the "Content Permissions" feature, which will make a new "Content Permissions" part available. Attach this part to the desired content types, which will add a new "Security" tab to the content editor. From this tab the content item permissions can be enabled, which will display all the roles in the CMS. Select the roles that can access the content item and publish. Below are different ways of handling when the user isn't associated to one of the roles specified on the part.

Redirection

Users can be redirected to a specific URL that can be defined in the settings for the content permissions part.

Display Alternative Content

Users can be displayed an alternative by customising the view template, as shown below. This enables the ability to restrict whether users can see specific widgets on a page.

Liquid

Example of how to check users permission and display alternative content with Liquid template.

{% if Model.ContentItem | user_can_view %}
	<p>Awesome content that you have permission to view.</p>
{% else %}
	<p>Unfortunately you're not able to view this content.</p>
{% endif %}

Razor

Example of how to check users permission and display alternative content with Razor template.

@inject Etch.OrchardCore.ContentPermissions.Services.IContentPermissionsService ContentPermissionsService

@if (ContentPermissionsService.CanAccess(Model.ContentItem))
{
    <p>Awesome content that you have permission to view.</p>
}
else
{
    <p>Unfortunately you're not able to view this content.</p>
}

etch.orchardcore.contentpermissions's People

Contributors

dalenewman avatar peterkeating avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.