Skip to content

Geta Tags is a library that adds tagging functionality to Optimizely content.

License

Notifications You must be signed in to change notification settings

Geta/geta-optimizely-tags

Repository files navigation

Geta Tags for Optimizely

Quality Gate Status Platform Platform

Description

Geta Tags is a library that adds tagging functionality to Optimizely content.

Features

  • Define tag properties
  • Query for data
  • Admin page for managing tags
  • Tags maintenance schedule job

See the editor guide for more information.

How to get started?

Start by installing NuGet package (use Optimizely NuGet):

dotnet add package Geta.Optimizely.Tags

Geta Tags library uses tag-it jQuery UI plugin for selecting tags. To add Tags as a new property to your page types, you need to use the UIHint attribute like in this example:

[UIHint("Tags")]
public virtual string Tags { get; set; }

[TagsGroupKey("mykey")]
[UIHint("Tags")]
public virtual string Tags { get; set; }

[CultureSpecific]
[UIHint("Tags")]
public virtual string Tags { get; set; }

Register tags in Startup.cs using folllowing service extension

services.AddGetaTags();

Then, call UseGetaTags in the Configure method:

app.UseGetaTags();

Also, you have to add Razor pages routing support.

app.UseEndpoints(endpoints =>
{
    endpoints.MapRazorPages();
});

Use ITagEngine to query for data:

IEnumerable<ContentData> GetContentByTag(string tagName);
IEnumerable<ContentData> GetContentsByTag(Tag tag);
IEnumerable<ContentData> GetContentsByTag(string tagName, ContentReference rootContentReference);
IEnumerable<ContentData> GetContentsByTag(Tag tag, ContentReference rootContentReference);
IEnumerable<ContentReference> GetContentReferencesByTags(string tagNames);
IEnumerable<ContentReference> GetContentReferencesByTags(IEnumerable<Tag> tags);
IEnumerable<ContentReference> GetContentReferencesByTags(string tagNames, ContentReference rootContentReference);
IEnumerable<ContentReference> GetContentReferencesByTags(IEnumerable<Tag> tags, ContentReference rootContentReference);

Customize Tag-it behaviour

You can customize the Tag-it.js settings by using the GetaTagsAttribute. The following settings can currently be customized

  • allowSpaces - defaults to false
  • allowDuplicates - defaults to false
  • caseSensitive - defaults to true
  • readOnly - defaults to false
  • tagLimit - defaults to -1 (none)
[CultureSpecific]
[UIHint("Tags")]
[GetaTags(AllowSpaces = true, AllowDuplicates = true, CaseSensitive = false, ReadOnly = true)]
public virtual string Tags { get; set; }

Local development setup

Use Foundation project in the solution for testing. Follow Foundation project's setup guide.

Package maintainer

https://github.com/marisks

Changelog

Changelog