WP Menu

While moving a client over to WordPress, we wanted to take a hard-coded menu with icons and descriptions into a WordPress-controlled menu that allowed the administrator to update the menu with ease from the WordPress control panel.

Unfortunately, this functionality is not completely offered by WordPress. While updating the Screen Options in the WordPress control panel will allow you to add the Description to your menu’s advanced properties, WordPress does not give you a way render the descriptions with your link. To solve this, I created a plugin.

To achieve this, I first had to implement a Walker_Nav_Menu object that would render each menu item how we want it. I was able to get most of this from a blog post I found online.

I then implemented a custom WP_Widget object. It contains the widget form for the WordPress control panel as well as the rendering process for the public view. The rendering processes used the Walker_Nav_Menu object to display the menu with descriptions.

You can download the source code from the Descriptive Menu Plugin page in the WordPress Plugins Directory. You can also check out our release post.

For other WordPress help please visit our WordPress Web Development Page and see what we can do for you!

Recently, I tried to build an MVC4 application using the SimpleMembershipProvider offered by the Internet Application template. Unfortunately I ran into a slew of compiling errors, run-time errors, and database connection errors once I added in my Entity Framework entities. After tracing down all the issues, I was able to get a clean-slate solution with the SimpleMembershipProvider and Entity Framework working side-by-side in MVC4. Assumptions

  1. EntityFramework has been installed.
  2. The SimpleMembershipProvider files are in the project correctly. Such as…
    1. InitializeSimpleMembershipAttribute.cs
    2. AccountController.cs
    3. AccountModels.cs

Database Setup First, make sure your table has a UserProfile table set up using the following script. Once this is set up, the membership provider will do the rest of the legwork (creating the rest of the tables it needs) for you. Kerrry1

/****** Object:  Table [dbo].[UserProfile]    Script Date: 9/20/2013 10:24:48 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[UserProfile](
	[UserId] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [varchar](75) NOT NULL,
 CONSTRAINT [PK_UserProfile] PRIMARY KEY CLUSTERED 
(
	[UserId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

Note: If you do not set the UserId as the primary key, you can get errors like this:

  1. The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588

Delete the UsersContext and Code-First Models

We will no longer need the UsersContext when we have our Entity Framework context created, so we can just remove it. We also want to remove the UserProfile code-first class to avoid errors such as #1 (Missing partial modifier on declaration of type ‘MvcApplication1.Models.UserProfile’; another partial declaration of this type exists). Kerry2

Creating the Entities and Connection String

Now, add your new entities through EntityFramework through the Add -> ADO.NET Entity Data Model wizard (IMAGE http://d.pr/i/A5sg). This will create the class files for your objects as well as generate a new connection string into the Web.config with which EntityFramework uses to create a context.

Setting SimpleMembershipProvider’s Context

If you try to build, you will get some errors such as “The type or namespace name ‘UsersContext’ could not be found (are you missing a using directive or an assembly reference?)”. Track all of these down and replace UsersContext with the name of your database context (“MyEntitiesContext” or whatever you named it). There will be 2 uses in Controllers/AccountController.cs and 2 uses in Filters/InitializeSimpleMembershipAttribute.cs.

Modifying the DefaultConnection String

The DefaultConnection string is the one used by the SimpleMembershipInitializer. You can change the name of this on (by default) line 33 of Filters/InitializeSimpleMembershipAttribute.cs: WebSecurity.InitializeDatabaseConnection(“DefaultConnection”, “UserProfile”, “UserId”, “UserName”, autoCreateTables: true); Kerry3 NOTE: You cannot use the same connection string as the Entity Framework connection string. If you do, you will see errors like this:

  1. The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588

Instead, you need to pull out the “provider connection string” value in the Entity Framework connection string, without the “App=EntityFramework” parameter. For example:

    <add name="DefaultConnection" connectionString="data source=(local);initial catalog=actest;user id=sa;password=[mypassord];MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
    <add name="MyEntities" connectionString="metadata=res://*/Models.Entities1.csdl|res://*/Models.Entities1.ssdl|res://*/Models.Entities1.msl;provider=System.Data.SqlClient;provider connection string="data source=(local);initial catalog=actest;user id=sa;password=[mypassword];MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
	

You are now free to use Entity Framework! You can download the source code at my GitHub repository. Bonus note: To resolve this error, add a primary key to your entity and re-generate the model. Unable to update the EntitySet [your_entity] because it has a DefiningQuery and no <InsertFunction> element exists in the element to support the current operation. Check out our .NET Development page for more ways we can help you!

 

Today, we released the Descriptive Menu Plugin on the WordPress.org plugin repository. This plugin allows us to display a menu with the menu item descriptions using a simple widget. It also provides an optional icon element. With simple and clean markup, you can easily style to make it look the way you need it to. Here’s an example of what we did with it:

The Widget

The Result

You can bring this functionality to your WordPress site with ease by downloading the plugin from the Descriptive Menu Widget’s WordPress Plugin repository page.

Use the following CSS selectors to style your Descriptive Menu:

#descriptive_menu-[id] This is the wrapper for the whole widget
#descriptive_menu-[id] .widget-title This is the title of the widget
#descriptive_menu-[id] .descriptive-menu This is the actual menu object
#descriptive_menu-[id] .descriptive-menu-link This is a span wrapper around the menu item anchor.
#descriptive_menu-[id] .descriptive-menu-icon This is an empty span you can use to display an icon. Add menu item classes to add specific icons for items.
#descriptive_menu-[id] .descriptive-menu-description This is the description paragraph tag.

Orchard 

There isn’t any documentation for the Vendelay Industries Module used for internet marketing. This particularly affects the SEO tool for meta keywords and description.

Happily there is a way around this issue and I’ll detail it in this blog.

Forum posts are out of date for Orchard 1.7 because they reference adding a “Content Part” to a “Content Type”. By default, this is not possible in Orchard 1.7. You must activate the built-in ContentTypes Module or the Content Type editor is hidden – in fact, it has been renamed on the menu to “Content Definition”.

Here are the steps to activate the “Meta” Module:

  1. Login to the Admin section of Orchard.
  2. Click the Modules entry in the left menu.
  3. Enable the ContentTypes Module.
  4. Then, click the new “Content Definition” entry in the left menu.
  5. Click the Page->Edit link on the Content Types tab.
  6. Click the Add Parts button.
  7. Check the box for Meta.
  8. Click the Save button.
  9. Optional: Since you don’t commonly need to modify Content Definitions, disable the ContentTypes Module.

Bonus Information

The Vandelay Module doesn’t allow Title overrides for SEO. Use the “Page Title Override” Module by Endless Mountain Solutions.

See our Orchard CMS Page for information about this great .NET-based CMS. We love it and we think you will also.

Take a look at our Web Design and Software Development Site. We can make the website you want at a price you like.