Copied to clipboard

Flag this post as spam?

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


  • Carlos 338 posts 472 karma points
    Jan 17, 2012 @ 20:04
    Carlos
    0

    How to put XSLT search inside of an XSLT file.

    How would I go about adding the XSLTsearch Macro into an XSLT file? With all of the properties.

    It should be easy I am sure, but I am drawing a blank.

    Any help is greatly appreciated.

     

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 17, 2012 @ 20:12
    Jan Skovgaard
    0

    Hi Carlos

    Depending on what you're trying to do you can use either xsl:import or xsl:include. You can also use the umbraco.library:RenderMacro() extension to call a macro within a XSLT file.

    Hope this helps.

    /Jan

  • Carlos 338 posts 472 karma points
    Jan 17, 2012 @ 20:37
    Carlos
    0

    Jan,

    Awe yes the old RenderMacro.  I can't include because the XSLT search requires or adds properties. From my understanding I can't put properties in the import or include.

    If I do do the RenderMacro and it has the multiple properties, how would I include the multiple properties.

    I am going off of this example of using the RenderMacro in the XSLT file.

    http://our.umbraco.org/wiki/reference/umbracolibrary/rendermacrocontent

    My macro for my XSLT with properties are as below

        <umbraco:Macro Alias="XSLTsearch-TeacherPrograms" runat="server"
       macroAlias="XSLTsearch-TeacherPrograms"
         source="-1"
          searchFields="gradeLevelRange,contentType,programTypeList"
          previewFields="bodyText,metaDescription"
          previewType="beginning"
          searchBoxLocation="none"
          resultsPerPage="5"
          previewChars="255"
          showPageRange="0"
          showOrdinals="0"
          showScores="0"
          showStats="0">
        
        </umbraco:Macro>

  • Carlos 338 posts 472 karma points
    Jan 17, 2012 @ 21:10
    Carlos
    0

    Help please???

    This is what I did to get my Macro try to render in my XSLT

    <xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO Alias=&quot;XSLTsearch-TeacherPrograms&quot;
       macroAlias=&quot;XSLTsearch-TeacherPrograms&quot;
         source=&quot;-1&quot;
          searchFields=&quot;gradeLevelRange,contentType,programTypeList&quot;
          previewFields=&quot;bodyText,metaDescription&quot;
          previewType=&quot;beginning&quot;
          searchBoxLocation=&quot;none&quot;
          resultsPerPage=&quot;5&quot;
          previewChars=&quot;255&quot;
          showPageRange=&quot;0&quot;
          showOrdinals=&quot;0&quot;
          showScores=&quot;0&quot;
          showStats=&quot;0&quot; &gt;
        
        &lt;/?UMBRACO_MACRO&gt;')" /> 

     

    However, it does not work because on the front end it is spitting out Error parsing XSLT file: \myFile.xslt

     

    Any ideas?

  • Carlos 338 posts 472 karma points
    Jan 17, 2012 @ 21:10
    Carlos
    0

    Do I need runat server in the UMBRACO_MACRO?  or does that even matter?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 17, 2012 @ 22:51
    Jan Skovgaard
    0

    Hi Carlos

    Argh yes, I forgot about the parameters that needs to be passed to xsltsearch. But can't you do the opposite? Include the other macro in the xsltSearch macro instead?

    If not you should look into perhaps importing xslt search in your other xslt file. In order to do that you should remove the $currentpage from xslt search and then copy the elements within the xsl:template match="/" template into the xsl:template match="/" template in the xslt file wher you import xslt search. When that is done you should remove the xsl:template match="/" from the xslt search xslt file.

    This is from the top of my head, so I'm not sure if it'll work or not but I think it's worth the try.

    /Jan

  • Carlos 338 posts 472 karma points
    Jan 18, 2012 @ 17:53
    Carlos
    0

    Thanks for the response. I am just going to use a work around in the template itself using the Node Factory and getting the doctype.  Just writing an IF statement to add the macro to the page if it of a certain doctype.  The whole thing with adding it to the XSLT just seems a bit too much work.  

    Looking forward to working with Razor soon so we can start to not run into issues with Macros inside XSLT.  Kind of a pain.

    Thanks

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 18, 2012 @ 21:51
    Jan Skovgaard
    0

    Hi Carlos

    Ah, yes that's probably a better solution in this case - indeed Razor has some benefits over XSLT and vice versa :)

    /Jan

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Feb 23, 2012 @ 21:23
    Lee Kelleher
    0

    Hi Carlos,

    Bumping up an old thread.

    You've probably already solved your problem, but for future reference - it is possible to include XSLTsearch within separate XSLT file - I wrote a blog post about this very thing a few days ago: http://leekelleher.com/2012/02/21/manipulate-xsltsearch/

    Cheers, Lee.

  • Carlos 338 posts 472 karma points
    Feb 23, 2012 @ 21:30
    Carlos
    1

    Thanks Lee,

    I did figure out my issue. But your solution does help with anyone else trying to do the same thing.


    I did mine a bit differently.

    With 4.7.1 looks like and 5.0 coming out. XSLT search may see the way of the past.  Razor is good and XSLT is good too. Both very powerful.

    Trying to learn Razor has been a bit of a challenge since I am not used to any ASP.net. Mainly XHTML, HTML5 and XML.  XSLT was easy to pick up.

    But Razor is oh so much less code.

Please Sign in or register to post replies

Write your reply to:

Draft