Hi again, i have a website running with 2 different languages, the problem is when I add internal links to content in RTE: when the page is rendered in the links are missing the language part, so every time one click it fall back to the main language. Am I doing something wrong?
I'm using a modified version of PropertyTranslation to render grids (I posted the code in a previous topic here), but as the original PropertyTranslation the renderer used by GetGridHtml calls TemplateUtilities.ParseInternalLinks. The internal links are rendered, but without the add of the currently selected language, that's why it falls back to the main language of the site
Excuse me, I was not related to your previous post. Unfortunately I have no experience with grids. Since yesterday was a bit more but certainly less than you. If I find something next week I tell (this was my week vacation)
What the luck be with you !, Claudio. This week I've been looking at the grids and are really complex. Perhaps this package will be useful for you: Skybrud.Umbraco.GridData
Unfortunately the only example is for read-only access , to index with Examine the RTEs within a grid.
Here's a quick and dirty solution (when I'll have time I'll try to make something more clean). Just replace the ParseInternalLinks with a modded version that add the current language. I made it for the grid system, but the same logic could be applied to the PropertyTranslation.
In my case i made the change to Views\Partials\Grid\Editors\Rte.cshtml which now is:
@model dynamic
@using Umbraco.Web.Templates
@using System.Text.RegularExpressions
@using Umbraco.Web
@Html.Raw(ParseInternalLinksTranslated(Model.value.ToString()))
@helper ParseInternalLinksTranslated(string text){
string selectedLanguage = RenderPage("~/macroScripts/SelectedLanguage.cshtml").ToString().Trim();
var urlProvider = UmbracoContext.Current.UrlProvider;
var tags = Regex.Matches(text, @"href=""[/]?(?:\{|\%7B)localLink:([0-9]+)(?:\}|\%7D)", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
foreach (Match tag in tags)
{
if (tag.Groups.Count > 0)
{
var id = tag.Groups[1].Value;
var newLink = urlProvider.GetUrl(int.Parse(id));
text = text.Replace(tag.Value, "href=\"/" + selectedLanguage + newLink);
}
}
@Html.Raw(text)
}
adding language to internal links in rte
Hi again, i have a website running with 2 different languages, the problem is when I add internal links to content in RTE: when the page is rendered in the links are missing the language part, so every time one click it fall back to the main language. Am I doing something wrong?
Are you using the propertyTranslation Macro?
I'm using a modified version of PropertyTranslation to render grids (I posted the code in a previous topic here), but as the original PropertyTranslation the renderer used by GetGridHtml calls TemplateUtilities.ParseInternalLinks. The internal links are rendered, but without the add of the currently selected language, that's why it falls back to the main language of the site
Excuse me, I was not related to your previous post. Unfortunately I have no experience with grids. Since yesterday was a bit more but certainly less than you. If I find something next week I tell (this was my week vacation)
If you are entering the URLs yourself, then you would also need to add the corresponding language parameter, e.g. http://some.link/page?lang=en
Ok, so there's no way to have the language automatically added when selecting link using the content tree?
It's a good idea for further development but, at the moment, sadly no...
Ok thank you! I thought I was doing something wrong! I'll try to find a solution :)
What the luck be with you !, Claudio. This week I've been looking at the grids and are really complex. Perhaps this package will be useful for you: Skybrud.Umbraco.GridData Unfortunately the only example is for read-only access , to index with Examine the RTEs within a grid.
Here's a quick and dirty solution (when I'll have time I'll try to make something more clean). Just replace the ParseInternalLinks with a modded version that add the current language. I made it for the grid system, but the same logic could be applied to the PropertyTranslation.
In my case i made the change to Views\Partials\Grid\Editors\Rte.cshtml which now is:
is working on a reply...