Just out of curiosity - what was the real problem here? Have you renamed the Image Media Type using the Turkish I, or is it happening because your keyboard layout use the turkish letter (so your XPaths are using it by default)?
Where does the code you've changed run? (E.g., does it run when you save a Media Type?)
I'd like to understand this, as XML is perfectly capable of using almost any character set for elements, so the turkish I should not really be an issue...
actual problem is i writed nothing in turkish , when solving xpath ;
privatestaticXPathNodeIterator getMediaDo(int MediaId, bool Deep)
{
Media m = newMedia(MediaId);
if (m.nodeObjectType == Media._objectType)
{
XmlDocument mXml = newXmlDocument();
mXml.LoadXml(m.ToXml(mXml, Deep).OuterXml);
XPathNavigator xp = mXml.CreateNavigator();
string xpath = UmbracoSettings.UseLegacyXmlSchema ? "/node" : String.Format("/{0}", Casing.SafeAliasWithForcingCheck(m.ContentType.Alias));
return xp.Select(xpath);
}
returnnull;
}
Casing.SafeAliasWithForcingCheck(m.ContentType.Alias) --> this tries to solve '/Image' but in turkey;
publicstaticstring SafeAlias(string alias)
{
StringBuilder safeString = newStringBuilder();
int aliasLength = alias.Length;
for (int i = 0; i < aliasLength;i++ )
{
string currentChar = alias.Substring(i, 1);
if (VALID_ALIAS_CHARACTERS.Contains(currentChar.ToLower()))
{
if (safeString.Length == 0 && INVALID_FIRST_CHARACTERS.Contains(currentChar.ToLower()))
{
currentChar = "";
}
else
{
if (i < aliasLength - 1 && i > 0 && alias.Substring(i - 1, 1) == " ")
currentChar = currentChar.ToUpper();
safeString.Append(currentChar);
}
}
}
currentChar.ToLower() converts I to '' not i so it is not an allowed char (VALID_ALIAS_CHARACTERS) so it converts /Image to /mage hehe so i cant query and /Image type :D so I changed it to; currentChar.ToLower(new System.Globalization.CultureInfo("en-US"))
and I am not using any turkish chars becouse I have no Turkish customer :D (all are Dutch or American :) )
for my thought safeAliasculture must be a parameter in umbracoconfig :D
GetMedia in Site
i have a macro;
<xsl:param name="currentPage"/>
<xsl:variable name="mediaId" select="number($currentPage/ancestor-or-self::Section/stockImage)"/>
<xsl:template match="/">
<xsl:if test="$mediaId > 0">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 'false')" />
<xsl:if test="$mediaNode/umbracoFile">
<img src="{$mediaNode/umbracoFile}" alt="[image]" width="241px"/>
</xsl:if>
</xsl:if>
</xsl:template>
like this it is working in visualizer but not working in the site? when I addd this;
<div>node:
<xsl:value-of select="$currentPage/@nodeName"/><br />
section nodename:
<xsl:value-of select="$currentPage/ancestor-or-self::Section/@nodeName"/><br />
media id:
<xsl:value-of select="$mediaId"/><br />
media:
<xsl:copy-of select="umbraco.library:GetMedia($mediaId, 'false')"/><br />
</div>
to my macro
nodename,section node and media id is correct but getMedia is not working? Any friend knows why?
H I solved the problem;
if (VALID_ALIAS_CHARACTERS.Contains(currentChar.ToLower()))
in turkish language it converts /Image to /mage but umbraco local is in default english so visualizer is working :D
I changed the code to this;
for now :D if this happens someone else, I can send new release binaries to him (if the one doesnt wantto edit code himself :D )
Have a nice day
Hi doruk,
Just out of curiosity - what was the real problem here? Have you renamed the Image Media Type using the Turkish I, or is it happening because your keyboard layout use the turkish letter (so your XPaths are using it by default)?
Where does the code you've changed run? (E.g., does it run when you save a Media Type?)
I'd like to understand this, as XML is perfectly capable of using almost any character set for elements, so the turkish I should not really be an issue...
/Chriztian
Oh hi,
actual problem is i writed nothing in turkish , when solving xpath ;
is working on a reply...