Skip to content

Commit

Permalink
Multi-targeting for v9, v10, and v11
Browse files Browse the repository at this point in the history
  • Loading branch information
callumbwhyte committed Jan 11, 2023
1 parent a50eb9c commit bd99d82
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ Click and drag an item to change it's position within the navigation; drop it wh

## Getting started

This package is supported on Umbraco 9+.
This package is supported on Umbraco v9, v10, and v11

### Installation

Meganav is available from Our Umbraco, NuGet, or as a manual download directly from GitHub.
Meganav is available via [NuGet](https://www.nuget.org/packages/Our.Umbraco.Meganav/).

#### Our Umbraco repository
To install with the .NET CLI, run the following command:

You can find a downloadable package on the [Our Umbraco](https://our.umbraco.com/packages/website-utilities/meganav/) site.
$ dotnet add package Our.Umbraco.Meganav

#### NuGet package repository

To [install from NuGet](https://www.nuget.org/packages/Our.Umbraco.Meganav/), run the following command in your instance of Visual Studio.
To install from within Visual Studio, use the NuGet Package Manager UI or run the following command:

PM> Install-Package Our.Umbraco.Meganav

Expand Down
12 changes: 9 additions & 3 deletions src/Our.Umbraco.Meganav/Our.Umbraco.Meganav.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFrameworks>net5.0;net6.0;net7.0</TargetFrameworks>
<Version Condition="'$(BUILD_BUILDNUMBER)' == ''">1.0.0.0</Version>
<Version Condition="'$(BUILD_BUILDNUMBER)' != ''">$(BUILD_BUILDNUMBER)</Version>
<Description>A flexible, draggable link picker for constructing site navigation menus in Umbraco</Description>
Expand All @@ -22,7 +22,13 @@
<None Include="..\..\README.md" Pack="true" PackagePath="docs" />
<None Include="..\..\docs\img\logo.png" Pack="true" PackagePath="docs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Umbraco.Cms.Web.Common" Version="[9.0.0,10.0.0)" />
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Umbraco.Cms.Infrastructure" Version="[9.0.0,10.0.0)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Umbraco.Cms.Infrastructure" Version="[10.0.0,11.0.0)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Umbraco.Cms.Infrastructure" Version="[11.0.0,13.0.0)" />
</ItemGroup>
</Project>
7 changes: 5 additions & 2 deletions src/Our.Umbraco.Meganav/PropertyEditors/MeganavValueEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Editors;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
Expand All @@ -16,15 +17,17 @@ namespace Our.Umbraco.Meganav.PropertyEditors
internal class MeganavValueEditor : DataValueEditor
{
private readonly IContentService _contentService;
private readonly IPublishedUrlProvider _publishedUrlProvider;
private readonly IUmbracoContextFactory _umbracoContextFactory;

public MeganavValueEditor(IContentService contentService, IUmbracoContextFactory umbracoContextFactory, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer)
public MeganavValueEditor(IContentService contentService, IPublishedUrlProvider publishedUrlProvider, IUmbracoContextFactory umbracoContextFactory, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer)
: base(localizedTextService, shortStringHelper, jsonSerializer)
{
View = "/App_Plugins/Meganav/backoffice/propertyeditors/editor.html";
ValueType = "JSON";

_contentService = contentService;
_publishedUrlProvider = publishedUrlProvider;
_umbracoContextFactory = umbracoContextFactory;
}

Expand Down Expand Up @@ -80,7 +83,7 @@ private void EnrichEntities(IUmbracoContext umbracoContext, IEnumerable<MeganavE

entity.Published = content.IsCulturePublished(culture ?? "") || content.Published;

entity.Url = umbracoContext.Content.GetById(content.Id)?.Url(culture);
entity.Url = umbracoContext.Content.GetById(content.Id)?.Url(_publishedUrlProvider, culture);
}

if (entity.Children != null)
Expand Down
11 changes: 8 additions & 3 deletions src/Our.Umbraco.Meganav/ValueConverters/MeganavValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@
using Our.Umbraco.Meganav.PublishedContent;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Web;
using Umbraco.Extensions;

namespace Our.Umbraco.Meganav.ValueConverters
{
internal class MeganavValueConverter : PropertyValueConverterBase
{
private readonly IPublishedUrlProvider _publishedUrlProvider;
private readonly IVariationContextAccessor _variationContextAccessor;
private readonly IUmbracoContextFactory _umbracoContextFactory;
private readonly PublishedElementFactory _publishedElementFactory;

private MeganavConfiguration _config;

public MeganavValueConverter(IUmbracoContextFactory umbracoContextFactory, PublishedElementFactory publishedElementFactory)
public MeganavValueConverter(IPublishedUrlProvider publishedUrlProvider, IVariationContextAccessor variationContextAccessor, IUmbracoContextFactory umbracoContextFactory, PublishedElementFactory publishedElementFactory)
{
_publishedUrlProvider = publishedUrlProvider;
_variationContextAccessor = variationContextAccessor;
_umbracoContextFactory = umbracoContextFactory;
_publishedElementFactory = publishedElementFactory;
}
Expand Down Expand Up @@ -119,10 +124,10 @@ private IEnumerable<MeganavItem> BuildItems(IUmbracoContext umbracoContext, IEnu

if (string.IsNullOrWhiteSpace(entity.Title) == true)
{
item.Title = content.Name(culture);
item.Title = content.Name(_variationContextAccessor, culture);
}

item.Url = content.Url(culture);
item.Url = content.Url(_publishedUrlProvider, culture);

item.Content = content;
}
Expand Down

0 comments on commit bd99d82

Please sign in to comment.