Copied to clipboard

Flag this post as spam?

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


  • Ryan Green 63 posts 83 karma points
    Oct 02, 2012 @ 15:07
    Ryan Green
    0

    Use XSLTsearch with additional parameters

    I am using altTemplates to redirect requests to mobile version of the pages. But with XLST, if I add the ?altTemplate= .... within the <form action="/search.aspx?altTemplate= ....method="post"> it no longer passes the parameters. Is there something that I am doing wrong.

    How can I reformat the form tag to allow it to pass the altTemplate parameter as well as whatever is being passed.

    I would prefer not to do it in the XSLT at all, since I am using it on other content nodes as well. 

     

    Thanks for any help....

    Ryan


  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Oct 02, 2012 @ 15:13
    Chriztian Steinmeier
    0

    Hi Ryan,

    There is an alternate altTemplate syntax (I know - double up on the alts :-) - you might be able to use that:

    Instead of /page.aspx?altTemplate=mobile you can do /page/mobile.aspx to get the same behavior (and a better URL)

    Will that do? 

    /Chriztian

  • Ryan Green 63 posts 83 karma points
    Oct 02, 2012 @ 15:42
    Ryan Green
    0

    That works AWESOME, but I needed to move the search code onto my mobile template as well. Not a problem, but now it shows up the search field again. Is there a way to hide the search field by turning off a parameter?

        <umbraco:Macro runat="server" Alias="XSLTsearch"
          macroAlias="XSLTsearch"
          source="-1"
          searchFields="@nodeName,pageTitle,content"
          previewFields="content,pageTitle"
          previewType="beginning"
          searchBoxLocation="bottom"
          resultsPerPage="25"
          previewChars="255"
          showPageRange="1"
          showOrdinals="0"
          showScores="0"
          showStats="1">
        </umbraco:Macro

    Also, all the URL's clicked on in the search results, then show up with the non-mobile formatted versions of the page. I would like to pass it along if possible.

  • Ryan Green 63 posts 83 karma points
    Oct 02, 2012 @ 15:52
    Ryan Green
    0

    Ok, solved that problem, I see there is a variable "NONE" for the search bar location.

     I am still looking into the URL issue.

     

  • Ryan Green 63 posts 83 karma points
    Oct 02, 2012 @ 16:13
    Ryan Green
    0

    Found this portion of the XSLT:

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

    Changed it to this:

    <!-- page name and url -->
    <href="{umbraco.library:NiceUrl(@id)}?altTemplate=mobile" class="xsltsearch_title">
    <xsl:value-of select="@nodeName"/>
    </a>

    And it works. But the only problem I have (which I think is the last one), is that my mobile template name is different on sites that I manage all within the Umbraco install. So, I would like to not have it hardcoded. Is there any way to accomplish this?

  • Ryan Green 63 posts 83 karma points
    Oct 02, 2012 @ 16:29
    Ryan Green
    0

    Ok, the other problem is, when using the desktop browser it still loads the mobile template, because it is hard coded. There must be a way to check to see if the search results page has the word "mobile" in the URL. If it does, than load for a page URL:

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

    If it doesn't contain "mobile", load this

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

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Oct 04, 2012 @ 17:01
    Douglas Robar
    0

    I think I'd do something like the following, which looks at the request URL for the word 'mobile' as you've described:

    <xsl:choose>
        <xsl:when test="contains(umbraco.library:RequestServerVariables('URL'), 'mobile')">
            <a href="{umbraco.library:NiceUrl(@id)}?altTemplate=mobile" class="xsltsearch_title">
                <xsl:value-of select="@nodeName"/>
            </a>
        </xsl:when>
        <xsl:otherwise>
            <a href="{umbraco.library:NiceUrl(@id)}" class="xsltsearch_title">
                <xsl:value-of select="@nodeName"/>
            </a>
        </xsl:otherwise>
    </xsl:choose>
    

     

    cheers,
    doug. 

     

  • Graham Carr 277 posts 389 karma points
    Oct 17, 2012 @ 16:54
    Graham Carr
    0

    Hi Ryan,

    I am currently trying to get AltTemplates working on my Umbraco sites mobile view, I am needing to render the same content structure but via different mobile templates. Can you post the solution/method you used to ensure that the mobile site redirects to the mobile templates and not the desktop version templates.

    Cheers,

    Graham

Please Sign in or register to post replies

Write your reply to:

Draft