Orchard CMS - Simple Profile Package

#orchard

Posted by admin on September 01, 2019

I started to do some work on profiles for a site we were building at work, and then we decided to jump ship on to Orchard. While Profiles haven't really been asked for as a requirement at work, i noticed the Orchard team have it on there back log, and as i wanted it and I'm a developer, why wait… why not just write one!.

This solution have is very basic Profiling -

  • Forename, Middle name, Surname
  • Date Of Birth
  • Age – Derived from DOB
  • Gender
  • Occupation
  • Image Name – There is a setting to tell the url builder where to get your image from.
  • Website address
  • IsPrivate mode
  • Edit and View Mode + Anom viewing
  • Simple Profile Permissions attached to roles.

To install it

  1. Unzip The Orchard.Profiles Package to under the \Orchard.Web\Packages\Orchard.Profiles
  2. Open the Orchard.sln solution
  3. Right Click on Packages and Add existing Items Browse to and select \Orchard.Web\Packages\Orchard.Profiles\Orchard.Profile.csproj and Add
  4. Right click on the Orchard.Web solutions References and Add a project reference to Orchard.Profiles to which you have just added.
  5. Hit F5 And it should be plugged in, compiled and ready for use.

Once you Register a user, you should be able to then go to http://localhost:30320/Profile/

If you have any problems getting it working leave a comment and i would be happy to help. Here is a couple screenshots of it working…

Viewing a Profile.. Note the Url in the address bar.

image_thumb2

The Edit button that appears on the right, will only appear if you have permission to edit your profile. This can be set in the Permissions section in Orchard.

If the profile has be set to private, then the page will redirect to a ProfilePrivateResult ONLY if you are attempting to view a profile other than your own.

Editing a Profile is a little different, as i haven't plugged in all the pretty moving things.

image_thumb5

Just so you are aware, the Roles section down the bottom is only shown if a user can modify their roles, this is coming from Orchard.Roles.

The Image Name will be the image i.e. AnImage.png, A Url helper will then fully qualify this based on a setting called Image Folder, which can be modified in the Orchard Settings Section.

image_thumb7

Note the setting down the bottom.

image_thumb9

So if you add an image to Media/Profiles/Images

image_thumb11

Then you add that name to the ImageName field on the Profile Edit page then you should see something that looks like this…

Hit Save… And Hey Presto!! You have an image… granted, mine is a bit squashed!

image_thumb13

Anyways here is the code for download.

Download Code (C#) -

Orchard.Profiles - 46160.zip

This will be an ongoing piece of work, but i will update this page, and add pages for more advanced features in the future.

Let me know how you get on, and please feed back any Constructive criticism you have, as it will only make my work better for me to upload to you lot.

This code was written in C# against Orchard Change set 46160.