Copied to clipboard

Flag this post as spam?

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


  • Mohamed magdy 3 posts 23 karma points
    Mar 27, 2011 @ 17:19
    Mohamed magdy
    0

    SEO Macro in Razor

    could any one help me in creating an seo script using razor

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 27, 2011 @ 17:27
    Kim Andersen
    0

    Hi Mohammed

    I think you need to describe a little bit more detailed what you want the macro to do. You just want to output a title, and some meta tags or whats your plan?

    /Kim A

  • Mohamed magdy 3 posts 23 karma points
    Mar 27, 2011 @ 17:46
    Mohamed magdy
    0

    actually i need to convert this xslt to razor .

    <?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"

      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

     

     

      <xsl:output method="xml" omit-xml-declaration="yes"/>

     

      <xsl:param name="currentPage"/>

      <xsl:variable name="title" select="umbraco.library:Replace(umbraco.library:Replace(umbraco.library:StripHtml($currentPage/title),'&#xD;',''),'&#xA;','')" />

      <xsl:variable name="description" select="umbraco.library:Replace(umbraco.library:Replace(umbraco.library:StripHtml($currentPage/description),'&#xD;',''),'&#xA;','')" />

      <xsl:variable name="bodyText" select="umbraco.library:Replace(umbraco.library:Replace(umbraco.library:StripHtml($currentPage/bodyText),'&#xD;',''),'&#xA;','')" />

      <xsl:variable name="keywords" select="umbraco.library:Replace(umbraco.library:Replace(umbraco.library:StripHtml($currentPage/keywords),'&#xD;',''),'&#xA;','')" />

      <xsl:variable name="noIndex" select="$currentPage/noIndex" />

     

      <xsl:template match="/">

     

        <!-- start writing XSLT -->

        <title>

          <xsl:choose>

            <xsl:when test="$title !=''">

              <xsl:value-of select="$title" disable-output-escaping="yes"/>

            </xsl:when>

            <xsl:otherwise>

              <xsl:value-of select="$currentPage/@nodeName"/>

            </xsl:otherwise>

          </xsl:choose>

        </title>

     

        <meta name="description">

          <xsl:attribute name="content">

            <xsl:choose>

              <xsl:when test="$description !=''" >

                <xsl:value-of select="$description" disable-output-escaping="yes"/>

              </xsl:when>

              <xsl:otherwise>

                <xsl:value-of select="umbraco.library:TruncateString($bodyText, '160', '')"/>

              </xsl:otherwise>

            </xsl:choose>

          </xsl:attribute>

        </meta>

     

        <meta name="keywords">

          <xsl:attribute name="content">

            <xsl:value-of select="$keywords" disable-output-escaping="yes"/>

          </xsl:attribute>

        </meta>

     

        <xsl:if test="$noIndex = '1'">

          <meta name="robots" content="noindex" />

        </xsl:if>

     

      </xsl:template>

     

    </xsl:stylesheet>

     

     

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Mar 28, 2011 @ 15:55
    Bo Damgaard Mortensen
    0

    Hi Mohamed,

    I think you should be off with a good starting point in using Razor by having a look at the videos at umbraco.tv. These can be found here: http://umbraco.com/help-and-support/video-tutorials/umbraco-fundamentals at the bottom of the page. It will require a subscription to watch them though, but there's lots of good stuff going on there at umbraco.tv :-)

    All the best,

    Bo

Please Sign in or register to post replies

Write your reply to:

Draft