Episerver localizing language for editor UI (content editors) - episerver

1) Localizing content language(for web site visitors) and localizing editor UI language (for content editors). Are these two implemented differently in Episerver?
There are two ways to localize.
2.1) Xml
What I do not understand is how to get the localized string when there are multiple languages mentioned here?
2.2) Localization service API
This is clear. But can this be used in localizing editor UI language (for content editors)?
The example for #2.1
[ContentType(
Description = "This text can you have in XML instead"
)]
public class StandardPage : PageData
{
[Display(
GroupName = SystemTabNames.Content,
Name = "This text can you have in XML instead ",
Description = " This text can you have in XML instead "
)]
public virtual ContentArea MainContentArea { get; set; }
}
<language name="en">
<contenttypes>
<standardpage>
<description>A description of the page type</description>
<properties>
<maincontentarea>
<caption>Name text from XML</caption>
<help>Description text from XML</help>
</ maincontentarea >
</properties>
</standardpage>
</contenttypes>
</language>

Not sure what you're asking, but:
The same localization APIs are used for both the Episerver UI and public-facing websites
XML files are one of the options for the localization APIs.
The XML you posted would localize the MainContentArea property of the StandardPage page type (if placed in an XML language file)

Related

Episerver -Validate content reference for image type

I have a content reference of type UIHint of image that accepts all the image types including .ico.
I need to validate this field so that the user can only upload file of type .ico
Right now even with the regex to only accept.ico file,the validation fails.
Could someone point out what is wrong with this.
I have validated the regex that should only accept.ico file but the validation fails
[Display(GroupName = Global.GroupNames.SiteSettings, Name = "Favicon", Description = "", Order = 20)]
[UIHint(UIHint.Image)]
[RegularExpression("[^\\s]+(.*?)\\.(ico)$", ErrorMessage = "Only .ico extension allowed")]
public virtual ContentReference Favicon { get; set; }
Kindly guide me in the right direction
Since .ico files probably aren't intended to be rendered on the site like other images (?) I'd create a separate content type called IconImage for the .ico file extension and then use an AllowedTypes attribute on your ContentReference property, specifying IconImage as the only allowed type.
If you already have a lot of icon files uploaded, i.e. mapped to an existing content type shared with other types of images, I'd probably create a separate validator (class implementing IValidate<T>) for applicable content type(s) to validate the ContentReference property.

How do I get DNN Search results to display links to articles with a 2sxc app?

I have a 2sxc app that is a list of resources. It has a listing and each item goes to a details view that has a unique URL based on the title. (The URL field is a field in the content type). Something like this domain.com/resources/details/my-amazing-resource.
When a user searches the site for "amazing", the core DNN search results module displays the results of the app, including the "My Amazing Resource" item, but it doesn't actually link to domain.com/resources/details/my-amazing-resource. It just links to domain.com/resources/.
How can I make it so the search results actually point to the unique URL of the item in the app? Is this possible? Would DNNSharp Search Boost be better for this than the core DNN search module?
Its been over a year since I tinkered with it, but what it sounds like you are looking for requires coding. Dnn Search will get what it can from the 2sxc module automatically, but if you need to customize or improve what is being returned, then you need to CustomizeSearch() or CustomizeData() - I am not sure I have seen any decent examples, but I do know the FAQs App does this and must have a working example in it of some kind. Here is a place to stat in the 2sxc Docs,
CustomizeSearch().
I suggest examples in the Blog or News App.
Using Jeremy and Daniel's suggestions, I ultimately updated my _resourcelist.cshtml file to have code that looks like this:
#inherits ToSic.Sxc.Dnn.RazorComponent
#using ToSic.Razor.Blade;
#using ToSic.Eav.Run;
#using ToSic.Sxc.Dnn.Run;
#using ToSic.Sxc.Search;
#functions
{
/// <summary>
/// Populate the search - ensure that each entity has an own url/page
/// </summary>
/// <param name="searchInfos"></param>
/// <param name="moduleInfo"></param>
/// <param name="startDate"></param>
public override void CustomizeSearch(Dictionary<string, List<ISearchItem>> searchInfos, IContainer moduleInfo, DateTime beginDate)
{
foreach (var si in searchInfos["Default"])
{
// tell the search system what url it should use in the result
si.QueryString = "resource/" + AsDynamic(si.Entity).Link;
}
}
}

Get Episerver Property though Episerver API/Database query

I have an episerver site with almost all the blocks having a common Image property as given below:
[Display(GroupName = SystemTabNames.Content, Name = "Image", Description = "This is description link for alt", Order = 30)]
[UIHint(UIHint.Image)]
public virtual ContentReference Image { get; set; }
This property is used throughout the application. I need to generate a report to get all the references where the Description is empty.
Is there a way to get the above using episerver api or database query?
This is a new area for me & so any input would be appreciated.

API in combination with a CMS: how to store HTML?

As a learning process I'm trying to create a CMS system.
At the moment I have the following setup:
- - - API - - -
- - / - - \ - -
- MVC - - Angular
The API is communicating with the database and is used by Angular to update/insert resources.
The idea is that ALL clients (for now MVC and Angular, in the future mobile) need to use the API to have a single entry point (avoiding duplicates).
This is working perfectly fine, but, Angular is used to create for instance pages for my CMS. These pages contain HTML.
It's easy to read and display the HTML for my MVC application, but what for mobile applications?
How do other CMS systems/websites handle this issue? Do they parse the HTML on the client (i.e. a mobile client) and display it properly?
My Page resource (model) looks like this:
public class PageModel
{
public string Title { get; set; }
public string Html { get; set; }
public DateTime PostedOn { get; set; }
public string SidebarId { get; set; }
}
I was thinking of storing an array of Paragraphs instead of plain Html. This could work fine, I could loop over all the paragraphs and display them instead of dumping the HTML. But then, what for span/strong/em/... tags (and more important, how to store this? I'm using table storage)?
The data should be separated from any presentation logic. Maybe consider storing large text as something like MarkDown, then parse mark down to HTML for your Web sites, and into an appropriate format for a standalone app.

Silverlight 2 ArgumentException

I have a silverlight 2 app that has an ObservableCollection of a class from a separate assem/lib. When I set my ListBox.ItemsSource on that collection, and run it, I get the error code:
4004 "System.ArgumentException: Value does not fall within the expected range."
Here is part of the code:
public partial class Page : UserControl
{
ObservableCollection<Some.Lib.Owner> ooc;
public Page()
{
ooc = new ObservableCollection<Some.Lib.Owner>();
Some.Lib.Owner o1 = new Some.Lib.Owner() { FirstName = "test1" };
Some.Lib.Owner o2 = new Some.Lib.Owner() { FirstName = "test2" };
Some.Lib.Owner o3 = new Some.Lib.Owner() { FirstName = "test3" };
ooc.Add(o1);
ooc.Add(o2);
ooc.Add(o3);
InitializeComponent();
lb1.ItemsSource = ooc;
}
}
But when I create the Owner class within this same project, everything works fine.
Is there some security things going on behind the scenes? Also, I'm using the generate a html page option and not the aspx option, when I created this Silverlight 2 app.
Are you trying to use a standard class library or a "Silverlight Class Library"?
Because Silverlight 2 uses a subset of the CLR it cannot access standard class libraries that were compiled using the full CLR. To use an external assembly you must create it as a "Silverlight Class Library". This will create a project that only includes the namespaces available to Silverlight and will allow you to reference the assembly within your Silverlight project.
Check out the MSDN article ".NET Framework Class Library for Silverlight" for more info.
It may be because you're not handling a failure in SubmittedChanges(). See http://www.scottleckie.com/2010/04/code-4004-unhandled-error-in-silverlight-application/ for more info
Everything is in one project now.
Yes, but not like you just did it, instead, share, link to the file(s).
For this an old jedi mind trick of Silverlight when there is a need to share common entity code between the app and the service. This is done when the library could not be brought in due to the differences in .Net/CLR.
The trick is to include the file as a link into the other project. Here is how
In the target (Silverlight project) folder which needs the code file, right click and select Add then Existing Item... or shift alt A.
Browse to the location of the origins file(s) found and select the/those file(s).
Once the item(s) have been selected, then on the Add button select the drop down arrow.
Select Add as link to add the file(s) as a link into the folder.
Once done, there is only one copy, but built in two different places.
That will give access to the file as if the file was actually within the project's folder, but the file physically resides elsewhere...and avoids CLR issues.

Resources