Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • ds 191 posts 223 karma points
    Sep 01, 2011 @ 22:20
    ds
    1

    Hi again Dimitri,

    I have a problem with language selector. Lets say I set English and Greek in dictionary item and default language is english. After changing the language to Greek, you could see pages displayed in greek but if you would click a subpage even though greek page is shown, the subpage you selected is displayed again in English.

    Secondly if you would ever put the language selector in the page, the blank line is displayed under it. I also tried to validated my page against W3C Markup Validation Service, I get dozens of error related to language selector.

    Any help much appreciated

     

  • dimi309 244 posts 578 karma points
    Sep 02, 2011 @ 04:14
    dimi309
    0

    Hello ds!

    Regarding the first issue, the reason that this happens is that your links to the subpages probably do not have the language parameter appended to them. For example if you create a menu that lists all subpages of a page it is not enough to just list the urls, for example http://mysite.com/products/ . It needs to list them with the language parameter e.g. http://mysite.com/products/?lang=el

    (or lang=en, etc depending on the language)

    You can pick up the language code from the very same parameter that is added to the url automatically once you select a language from the drop down.

    If you use the Translated Navigation macro (which is included in the package) to create your menu, this will already be done automatically for you. However it is most probable that you will want to create your own menus and submenus at some point. In that case I would suggest that you have a look at the source code of TranslatedNavigation (the corresponding xslt or cshtml script, depending on which version you use) and try to implement you menu or link generation code in the same way as far as the language parameter is concerned.

    Regarding the errors produced by the Markup Validation Service, I have just ran a test myself and I see what you are saying. Thank you for bringing this to my attention. I am preparing a new version of the package to be released in a few days. The new version will list each language in its own language in the drop down (sorry for the recursion :)) for example "english", "français", etc. So I will try to correct the structure of the drop down as well, so that it gets successfully validated by w3c.

    Cheers

    Dimitri

  • dimi309 244 posts 578 karma points
    Sep 02, 2011 @ 21:27
    dimi309
    0

    Hi!

    The new version I have mentioned above has just been released and is available for download. I have run the markup validation on it and it seems to be ok.

     



  • ds 191 posts 223 karma points
    Sep 02, 2011 @ 22:25
    ds
    0

    Hi Dimitri!,

    I will upload the new version but before doing it, should I delete all related TranslationFolders I created on nodes first? If yes, Uninstall old version and install new version?

    Secondly, I placed second Translated Navigation on sub-nodes and it works properly now:) Lucky me. But I have something hard-coded in the the following. Dictionary items works properly until you click a link and it is displayed again default language but I do not know How I can add translated navigation feature to this hard-coded code snippet.

                <div class="headerTopSignIn">                            
                    <asp:LoginView ID="LoginView1" runat="server">
                        <AnonymousTemplate>
                            <span class="input"><umbraco:Item field="#You are not logged-in:" runat="server"></umbraco:Item> <asp:LoginStatus ID="LoginStatus1" LoginText="Giri Yap" runat="server" /> <umbraco:Item field="#Or" runat="server"></umbraco:Item> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="/Register.aspx"><umbraco:Item field="#Register" runat="server"></umbraco:Item></asp:HyperLink></span>
                        </AnonymousTemplate>
                        <LoggedInTemplate>
                            <span class="input"><umbraco:Item field="#Hello" runat="server"></umbraco:Item> <asp:LoginName ID="LoginName1" runat="server" /> <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="/ControlPanel.aspx"><umbraco:Item field="#Control Panel" runat="server"></umbraco:Item></asp:HyperLink> | <asp:LoginStatus ID="LoginStatus2" LogOutText="Çk" runat="server" /></span>
                        </LoggedInTemplate>
                    </asp:LoginView>          
                </div>          
                <div class="headerTopList">
                    <ul>
                      <li><a href="/iletiim.aspx"><umbraco:Item field="#Contact us" runat="server"></umbraco:Item></a></li>
                      <li><a href="/sss.aspx"><umbraco:Item field="#FAQ" runat="server"></umbraco:Item></a></li>
                      <li><a href="/virtualpage.aspx"><umbraco:Item field="#Virtual Fair" runat="server"></umbraco:Item></a></li>
                      <li><a href="/kariyer.aspx"><umbraco:Item field="#BODTO Career" runat="server"></umbraco:Item></a></li>
                    </ul>
                </div>
                <div class="headerSearch">
                  <asp:Panel id="searchPanel" runat="server" DefaultButton="searchButton" >
                      <asp:TextBox id="searchBox" runat="server"/>
                      <asp:Button id="searchButton" runat="server" OnClick="Search_Click" Text="Ara"/>
                  </asp:Panel>

     

    Thirdly I have a xslt code snippet which displays subnodes from a node but due to lack knowledge of xslt, I have no idea how to give again translated feature to that.

    <xsl:for-each select="umbraco.library:GetXmlNodeById('1092')/*[@isDoc] [@isDoc and string(umbracoNaviHide) != '1']">
        <div class="writers">
          <img src='{writerPicture}' />
            <xsl:for-each select="* [@isDoc]">         
                <xsl:sort order="descending" select="@createDate"/>
                <xsl:if test="position()=1">            
                    <a href="{umbraco.library:NiceUrl(@id)}" >
                      <span>
                        <xsl:value-of select="writerCaption"/>
                      </span>
                    </a>       
                </xsl:if>
            </xsl:for-each>
            <br/>
            <xsl:value-of select="writerName"/>
        </div>
    </xsl:for-each>

     

  • dimi309 244 posts 578 karma points
    Sep 03, 2011 @ 09:37
    dimi309
    0

    Hi ds!


    When upgrading the package you do not need to delete your translations or any of your work. Unless you have modified the files installed by the package itself (in which case you should keep track of your changes to apply them to the new version), whenever you upgrade, all you need to do is uninstall the old Polyglot package version and then install the new one. I would also suggest logging out and back into Umbraco after doing so, but that's all.


    About the second question, instead of writing for each link <a href="/iletiim.aspx"><umbraco:Item field="#Contact us" runat="server"></umbraco:Item> directly into the template, I would suggest that you create your own macro, that takes the url and dictionary item name  parameters, appends the language parameter to the url and outputs the a href link. The xslt would look like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:dimi.polyglot="urn:dimi.polyglot"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets dimi.polyglot ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:include href="../xslt/LanguageParameter.xslt" />
    <xsl:param name="currentPage"/>

    <xsl:template match="/">
      <xsl:param name="url" select="macro/url" />
      <xsl:param name="dictionaryItem" select="macro/dictionaryItem" />
      
      <a href="{concat($url, '?lang=', $langISO)}"><xsl:value-of select="umbraco.library:GetDictionaryItem($dictionaryItem)"/></a>

    </xsl:template>

    </xsl:stylesheet>

    Finally, about the third question, you need to do the following:
    In your xslt script, right above the <xsl:param name="currentPage"/> tag, enter <xsl:include href="../xslt/LanguageParameter.xslt" />
    Replace <a href="{umbraco.library:NiceUrl(@id)}" > with <a href="{concat(umbraco.library:NiceUrl(@id), ‘?lang=’, $langISO)}" >

    You would then need to get the translated texts for writerName and writerCaption or fall back to the corresponding values of the basic page. You can check the xslt for the Translated Navigation macro to see how this is done. For example this is the script for translating the title of each page:

    <xsl:variable name="title">
                <xsl:choose>
                  <xsl:when
    test="child::*[name() = concat($currentPageTypeAlias, '_TranslationFolder')]/*[name() = concat($currentPageTypeAlias, '_Translation') and language = $langISO]/* [name() = $TitlePropertyAlias and not(@isDoc)] != '' and
    string-length(child::*[name() = concat($currentPageTypeAlias, '_TranslationFolder')]/*[name() = concat($currentPageTypeAlias, '_Translation') and language = $langISO]/* [name() = $TitlePropertyAlias and not(@isDoc)]) != 0">
                    <xsl:value-of disable-output-escaping="yes"
                                  select="child::*[name() = concat($currentPageTypeAlias, '_TranslationFolder')]/*[name() = concat($currentPageTypeAlias, '_Translation') and language = $langISO]/* [name() = $TitlePropertyAlias and not(@isDoc)]" />
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:choose>
                      <xsl:when test="string-length(child::*[name() = concat($TitlePropertyAlias, '_', $langISO) and not(@isDoc)]) = 0">
                        <xsl:value-of disable-output-escaping="yes" select="child::* [name() = $TitlePropertyAlias and not(@isDoc)]" />
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:value-of disable-output-escaping="yes"
                                      select="child::*[name() = concat($TitlePropertyAlias, '_', $langISO) and not(@isDoc)]" />
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:variable>

    I know that this might seem to be a bit too much if you are not very familiar with xslt but trying to practice writing xslt a bit really helps when developing in Umbraco. Also, if you don't like xslt (some people don't :)) and are using Umbraco 4.7 you might want to consider switching to Razor. There is also a Razor version of the Polyglot package available for download at http://polyglot.codeplex.com . I find Razor a lot easier to work with.

    Regards,

    Dimitri

  • dimi309 244 posts 578 karma points
    Sep 03, 2011 @ 11:57
    dimi309
    0

    Actually ds, about your third question I am preparing a function that will greatly simplify placing translated fields in your macros. I will make it available in a couple of days.

  • ds 191 posts 223 karma points
    Sep 03, 2011 @ 21:53
    ds
    0

    Hi Dimitri,

    I have just had a chance to check my posts. I will try your suggestion and let you know about the results.

  • ds 191 posts 223 karma points
    Sep 03, 2011 @ 23:30
    ds
    0

    Dimitri,

    I installed the version of Polyglot_1.12.zip as recommended download on codeplex and whole structure and website displays properly but your suggestion to my second and third questions, there is not any LanguageParameter.xslt file in that package. Moreover PolyglotXslt_1.12.zip has that file. If I would use it, the translated menu is mixed totaly. Which one I should use it?

  • dimi309 244 posts 578 karma points
    Sep 04, 2011 @ 04:23
    dimi309
    0

    Hello ds!

    Since you are working with xslt scripts, PolyglotXslt_1.12.zip was the package to use. Polyglot_1.12.zip does not contain LanguageParameter.xslt but LanguageParameter.cshtml, because Polyglot_1.12.zip is the razor version of the package. cshtml scripts are razor scripts and they can be used by other razor scripts but not by xslt scripts.

    In any case I have some good news :) I had more free time in my hands today than I thought so I have released yet another version of the package. So, don't download PolyglotXslt_1.12.zip, but PolyglotXslt_1.2.zip.

    In order to change or upgrade the Polyglot package, you always just need to uninstall the existing version which you have and install the new one.

    Version 1.2 contains a new script, PropertyReferenceTranslation.xslt , which greatly simplifies the answer to your third question. So, you can try to resolve the second question the way I have descibed, but for the third one there is much less code involved.

    So about the third question just ignore what I said before and please try the following:

    In your xslt script, right above the <xsl:param name="currentPage"/> tag, enter:

    <xsl:include href="../xslt/LanguageParameter.xslt" />

    <xsl:include href="../xslt/PropertyReferenceTranslation.xslt" />

    Replace <a href="{umbraco.library:NiceUrl(@id)}" > with <a href="{concat(umbraco.library:NiceUrl(@id), ‘?lang=’, $langISO)}" >

    Replace <xsl:value-of select="writerCaption"/> with the following:

    <xsl:call-template name="PropertyReferenceTranslation">
                  <xsl:with-param name="nodeId" select="@id" />
                  <xsl:with-param name="Property" select="'writerCaption'" /> <!-- Note the single quotes (') inside the double quotes(") -->
                  <xsl:with-param name="langISO" select="$langISO" />
    </xsl:call-template>

    Replace <xsl:value-of select="writerName"/> with the following:

    <xsl:call-template name="PropertyReferenceTranslation">
                  <xsl:with-param name="nodeId" select="@id" />
                  <xsl:with-param name="Property" select="'writerName'" /> <!-- Note the single quotes (') inside the double quotes(") -->
                  <xsl:with-param name="langISO" select="$langISO" />
    </xsl:call-template>

    I hope that this helps!

    By the way, many thanks for all your feedback. You have really helped me improve the package! :)

    Regards,

    Dimitri

     

  • ds 191 posts 223 karma points
    Sep 04, 2011 @ 21:10
    ds
    0

    Hi Dimitri,

    I have followed your suggestion but I have some problems and questions.

    1) After installing version PolyglotXslt_1.2.zip, my whole level 1 nodes are displayed in Translated Navigation. With the razor version, the link worked as expected. Because I have not changed anything except uninstalling old version and install that latest version. What might cause it?

    2) Regarding my second question the code snippet you supplied does not give me expected output

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:include href="../xslt/LanguageParameter.xslt" />
    <xsl:param name="currentPage"/>

    <xsl:template match="/">
      <xsl:param name="url" select="macro/url" />
      <xsl:param name="dictionaryItem" select="macro/dictionaryItem" />
      
      <a href="{concat($url, '?lang=', $langISO)}"><xsl:value-of select="umbraco.library:GetDictionaryItem($dictionaryItem)"/>a>

    I have been still trying to get expected result but till then I need your guidance litte bit further.

    3) Regarding my third question, the file you mention should be PropertyTranslation instead of PropertyReferenceTranslation.

    Also after adding

    <xsl:include href="../xslt/LanguageParameter.xslt" />

    <xsl:include href="../xslt/PropertyReferenceTranslation.xslt" /> right above <xsl:param name="currentPage"/>

    I get the warning of The variable or parameter 'currentPage' was duplicated with the same import precedence.

    so I am stuck at all three stages, dimitri,

  • dimi309 244 posts 578 karma points
    Sep 04, 2011 @ 23:56
    dimi309
    0

    Hi ds,

    Regarding the numbered questions:

    1) I am not sure I understand the problem. Could you tell me for example exactly what sort of items the xslt version displays and what items were being displayed when you were using the razor version?

    2) Could you write to me an example of what is the output you expect and what is the output that is actually displayed? Do you pass the url and the dictionary item alias as parameters to the macro? Please note that, if you haven't already done so, you need to declare 2 parameters on the macro that corresponds to the xslt you create, one called "url" and the other one called "dictionaryItem" and pass the appropriate values there when you call the macro

    3) Actually no. PropertyReferenceTranslation is the script you need to use here. PropertyTranslation works in connection to macros in templates. PropertyReferenceTranslation contains the template you will be calling when you write for example

    <xsl:call-template name="PropertyReferenceTranslation">
                  <xsl:with-param name="nodeId" select="@id" />
                  <xsl:with-param name="Property" select="'writerCaption'" /> <!-- Note the single quotes (') inside the double quotes(") -->
                  <xsl:with-param name="langISO" select="$langISO" />
    </xsl:call-template>

    The warning you get is becaue you probably have included PropertyTranslation and not PropertyReferenceTranslation in your script. Please let me know if you believe that I am not understanding something.

    Regards,

    Dimitri

  • dimi309 244 posts 578 karma points
    Sep 05, 2011 @ 08:01
    dimi309
    0

    ds,

    About the first issue I have just discovered that there was a bug in TranslatedNavigation in v1.2. Could you try downloading and using PolyglotXslt_1.21.zip ?

    Sorry about that.

    Regards,

    Dimitri

  • ds 191 posts 223 karma points
    Sep 05, 2011 @ 08:40
    ds
    0

    Dimitri,

    Still the same bug continuous but I have not had a chance to check second and third questions. I will let you know as well

  • dimi309 244 posts 578 karma points
    Sep 05, 2011 @ 09:32
    dimi309
    0

    ds,

    About the first problem, probably the bug which I corrected is not related to the issue you are facing. I have tested the package on a site of my own and it seems to work fine, so I assume that we have a different setup. Could you please describe the problem in a bit more detail, maybe with an example or some information about how your nodes are structured? 

    Regards,

    Dimitri

  • ds 191 posts 223 karma points
    Sep 05, 2011 @ 09:43
    ds
    0

    Dimitri,

    I attached a view of my menu right now in the following. I checked over all the steps again and it seems me OK cause when I select another languages and sub-menus, the polyglot works smoothly.

    Also my node structure in the following,

    Also on my master template, I have such structure as you described in the documentation but other codes omitted for clarity

    <body class="t">
    <umbraco:Macro Alias="SetPageCulture" runat="server"></umbraco:Macro>
    <div id="mainmenu">
    <umbraco:Macro UlCssId="topNavigation" Level="1" NaviHideProperty="" CurrentItemCssClass="" TitlePropertyAlias="title" Alias="TranslatedNavigation" runat="server"></umbraco:Macro>
    </div>
    </body>

    As I said after sorting this problem out, I will check your answers my second and third questions

  • dimi309 244 posts 578 karma points
    Sep 05, 2011 @ 10:06
    dimi309
    0

    ds,

    Is the problem that you use a "hide from navigation" property or something like that to hide some nodes from the menu but they still appear nevertheless?

    If so, when you call the macro, could you use NaviHideProperty="umbracoNaviHide" instead of NaviHideProperty="" ?

    If that resolves the issue, it is still a bug. I intended the package to assume umbracoNaviHide is the property unless something else is passed there, but you can use this method to circumvent the issue until I fix it.

    Regards,

    Dimitri

  • ds 191 posts 223 karma points
    Sep 05, 2011 @ 10:13
    ds
    0

    Dimitri,

    It is exactly a bug. I knew that default NaviHideProperty is umbracoNaviHide so I left it blank but following works now

    <umbraco:Macro UlCssId="topNavigation" Level="1" NaviHideProperty="umbracoNaviHide" CurrentItemCssClass="" TitlePropertyAlias="title" Alias="TranslatedNavigation"runat="server"></umbraco:Macro>

    now it is time to check my other problems. I will let you know about my other questions.

    Thanks for the feedback so far

  • dimi309 244 posts 578 karma points
    Sep 05, 2011 @ 19:14
    dimi309
    0

    You're welcome ds!

    In the meantime, I have released version 1.22 of the package, which fixes the umbracoNaviHide issue.

    Regards,

    Dimitri

  • ds 191 posts 223 karma points
    Sep 05, 2011 @ 20:01
    ds
    0

    Dimitri,

    I managed to make it work regarding my second and third questions. Lucky me again:)  Does Polyglot works well with search function? cause I have noticed that it does not now.

    Please see attached file, The search results page displays it but without meaningful node name and you can not reach the page as you are expected.

  • ds 191 posts 223 karma points
    Sep 05, 2011 @ 20:02
    ds
    0

    Sorry this is a duplicate post, admin might delete this one

  • dimi309 244 posts 578 karma points
    Sep 05, 2011 @ 21:34
    dimi309
    0

    ds,

    This is a discussion about using the package with xslt search:

    http://our.umbraco.org/projects/backoffice-extensions/polyglot/polyglot-package-feedback,-bug-reports,-assistance,-etc/22683-Xslt-search

    You can find information about the matter there. In order for the redirection to work (if you do not want to customise your search results, even though I think it's better) all the translation document types need to have their template set to the Translation template, which is installed together with the package. This is also useful for previewing translations, as is mentioned in the documentation. If the template had not been set when the translation nodes were created you will probably need to re-save them in order for this to work.

    The same information applies when searching using Examine.

    Best regards,

    Dimitri

  • ds 191 posts 223 karma points
    Sep 06, 2011 @ 10:56
    ds
    0

    Dimitri,

    I would try to customise the search result, The only disadvantage I see that you get the output as "en" or "gr" as you have already seen above.

    Besides it, I try to set dictionary items for Validation Controls like RequiredFieldValidator, RegularExpressionValidator on page Load

    I managed to do like in the following

            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Request.IsAuthenticated)
                {
                    FormsAuthentication.RedirectToLoginPage();
                }
                txtSubmit.Text = umbraco.library.GetDictionaryItem("Save");
                RequiredFieldValidator1.ErrorMessage = umbraco.library.GetDictionaryItem("Job Title Error");
                RequiredFieldValidator2.ErrorMessage = umbraco.library.GetDictionaryItem("Job Description Error");
                RequiredFieldValidator3.ErrorMessage = umbraco.library.GetDictionaryItem("Job Required Qualifications Error");
            }

    But with CreateUserWizard, I could not manage to work it

        <asp:CreateUserWizard ID="cwMember" runat="server" LoginCreatedUser="False" DisableCreatedUser="True"
            OnCreatingUser="cwMember_CreatingUser" OnCreatedUser="cwMember_CreatedUser" CreateUserButtonText="Create"
            OnCreateUserError="cwMember_CreateUserError">
            <WizardSteps>
                <asp:CreateUserWizardStep ID="cuwStep1" runat="server">
                    <ContentTemplate>
                        <table>
                            <tr>
                                <td colspan="3" class="label">
                                    <asp:Label ID="lblValidate" runat="server"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    <asp:Label ID="UsernameLabel" runat="server" AssociatedControlID="Username">UserName:</asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="Username" runat="server"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:RequiredFieldValidator ID="UsernameRequired" runat="server" SetFocusOnError="True" ControlToValidate="Username"
                                        ForeColor="Red" ValidationGroup="cwMember"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
              </ContentTemplate>
                </asp:CreateUserWizardStep>
                <asp:CompleteWizardStep ID="cuwStep2" runat="server">
                    <ContentTemplate>
                    </ContentTemplate>
                </asp:CompleteWizardStep>
            </WizardSteps>
        </asp:CreateUserWizard>

    Is there another way to set dictionary item at createuserwizard?

  • dimi309 244 posts 578 karma points
    Sep 06, 2011 @ 15:59
    dimi309
    0

    Hello ds!

    About the search results, in order to get the proper title, you could do the following for each found node:

    - check the retrieved node's type

    if it ends in _Translation retrieve the id of the parent of its parent and store somewhere the language property of the retrieved node (fr, en, etc)

            if it ends in _TranslationFolder ignore it and don't output it

            otherwise keep its id and assume that the language is your default language

            get the url for the node with the id which you have found above

            use PropertyReferenceTranslation to retrieve the title in the proper language (using the id and the language found above)

           return the title, with a hyperlink pointing to [url you have found]?lang=[language code you have found]

    I did it this way once and it worked quite well. This way there is no need for the redirection of the Translation template either, so user experience and search engine optimisation are improved.

    I have to admit, I am not sure what CreateUserWizard is :) I don't see any dictionary items in there, so I am not sure how to help you. I'll take two wild guesses:

    - If you have a problem with Umbraco dictionary items not displaying in the proper language please make sure that you call the "Set Page Culture" macro (installed by the Polyglot package) at the top of all of your templates (basically, most likely, at the top of your master template if you are using one).

    - If this is a user control and you cannot get the dictionary item tags to work in it, how about something like:

    <%= umbraco.library.GetDictionaryItem("Job Title Error") %>

    I'm not sure if this helps you, but I hope so.

    Best regards,

    Dimitri

     

  • ds 191 posts 223 karma points
    Sep 07, 2011 @ 11:05
    ds
    0

    Hi Dimitri,

    Would you mind providing code samples for search function I could take advantage of?

    I also sorted it out by doing like that for Validation controls.

    <asp:RequiredFieldValidator ID="UsernameRequired" runat="server" SetFocusOnError="True" ControlToValidate="Username" 
                                        ForeColor="Red" ValidationGroup="cwMember"><umbraco:Item field="#RegisterUsernameRequired" runat="server"></umbraco:Item></asp:RequiredFieldValidator>

    Regards

  • dimi309 244 posts 578 karma points
    Sep 07, 2011 @ 19:57
    dimi309
    0

    Hello ds,

    For example if you are using XSLTSearch version 3.0.3, in the script XSLTsearch.xslt you could do the following.

    Add the following namespace at the top where the rest of the namespaces are declared in a similar manner:



    xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions"



    Add the following line around line 35, right above the currentPage parameter declaration:



    <xsl:include href="../xslt/PropertyReferenceTranslation.xslt" />



    Around line 350 replace this:



    <a href="{umbraco.library:NiceUrl(@id)}" class="xsltsearch_title">
                        <xsl:value-of select="@nodeName"/>
                      </a>



    with this (assuming that you call the title of each of your nodes 'title'):



    <xsl:variable name="translationTitle">
                      <xsl:choose>
                        <xsl:when test="Exslt.ExsltRegularExpressions:test(name(), '_Translation$') = 1">                 
                          <xsl:call-template name="PropertyReferenceTranslation">
                            <xsl:with-param name="nodeId" select="parent::*/parent::*/@id" />
                            <xsl:with-param name="Property" select="'title'" /> <!-- Note the single quotes (') inside the double quotes(") -->
                            <xsl:with-param name="langISO" select="./language" />
                          </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
                          <xsl:value-of select="./title"/>
                        </xsl:otherwise>
                      </xsl:choose>
                      </xsl:variable>
                     
                      <xsl:variable name="translationUrl">
                      <xsl:choose>
                        <xsl:when test="Exslt.ExsltRegularExpressions:test(name(), '_Translation$') = 1">                 
                          <xsl:value-of select="concat(umbraco.library:NiceUrl(parent::*/parent::*/@id), '?lang=', ./language)" />
                        </xsl:when>
                        <xsl:otherwise>
                          <xsl:value-of select="umbraco.library:NiceUrl(@id)" />
                        </xsl:otherwise>
                      </xsl:choose>
                      </xsl:variable>
                     
                      <a href="{$translationUrl}" class="xsltsearch_title">
                        <xsl:value-of select="$translationTitle"/>
                      </a>



    This should give you a head start. You might still need to do certain things like for example excluding the TranslationFolder nodes from the search or filtering the results by selected language but unfortunately I don't have any code for that at the moment. TranslationFolder nodes have not appeared in any of my searches anyway. Usually I have noticed that search results match the language of the query so I have not done any filtering also because I needed a unified result set. Just the above would usually suffice.


    Cheers,

    Dimitri

  • ds 191 posts 223 karma points
    Sep 07, 2011 @ 20:04
    ds
    0

    I am using Lucene Examiner on my website but I would have a look at what you suggested, Dimitri.

  • dimi309 244 posts 578 karma points
    Sep 07, 2011 @ 20:14
    dimi309
    0

    I see... I don't have any code with me for that, but you can follow the same logic using the Umbraco API.

    Unfortunately in that case you would also need to translate the titles in your own code. Maybe taking a look at the script PropertyTranslation.cshtml from the Razor version can give you some ideas as Razor is closer to C#.

    Regards,

    Dimitri

  • ds 191 posts 223 karma points
    Sep 07, 2011 @ 20:24
    ds
    0

    I have passed the hard part by using your packet and it works smoothly now. I would work on customizing search function little bit later.

  • dimi309 244 posts 578 karma points
    Sep 07, 2011 @ 22:07
    dimi309
    0

    Cool! Good to hear that things are going well!

    Good luck with the rest of the work!

    Cheers,

    Dimitri

Please Sign in or register to post replies

Write your reply to:

Draft