<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Adding different CSS classes when using the EPiServer PageTree control</title>
	<atom:link href="http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=adding-different-css-classes-when-using-the-episerver-pagetree</link>
	<description></description>
	<lastBuildDate>Mon, 06 Sep 2010 06:28:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Alex Judd</title>
		<link>http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/comment-page-1/#comment-239</link>
		<dc:creator>Alex Judd</dc:creator>
		<pubDate>Wed, 31 Mar 2010 16:29:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.frederikvig.com/?p=1101#comment-239</guid>
		<description>Sorry Frederik - messing up your blog! - here it is without the &#039;less than, percent, hash&#039; opening tag and &#039;percent, greater than&#039; end tags

.aspx front code

&lt;pre&gt;
AddCssClassToPrimaryNavigationLi(Container.Indent, Container.CurrentPage.Property[&quot;PagePeerOrder&quot;].ToWebString())
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Sorry Frederik &#8211; messing up your blog! &#8211; here it is without the &#8216;less than, percent, hash&#8217; opening tag and &#8216;percent, greater than&#8217; end tags</p>
<p>.aspx front code</p>
<pre>
AddCssClassToPrimaryNavigationLi(Container.Indent, Container.CurrentPage.Property["PagePeerOrder"].ToWebString())
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Judd</title>
		<link>http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/comment-page-1/#comment-238</link>
		<dc:creator>Alex Judd</dc:creator>
		<pubDate>Wed, 31 Mar 2010 16:27:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.frederikvig.com/?p=1101#comment-238</guid>
		<description>Code was eaten by the page above so let&#039;s try posting the .aspx code again in a pre tag

.aspx code

&lt;pre&gt;
    &lt;li &gt;
&lt;/pre&gt;

.aspx.cs code

&lt;pre&gt;
        /// 
        /// Adds first and last classes to the list items
        /// 
        /// 
        /// Returns the css class in XHTML tag format
        /// 
        /// Current level of navigation passed in using the Container.Index value
        /// The EPiSERVER Advanced Sort Index of the page
        protected string AddCssClassToPrimaryNavigationLi(int level, string sortIndex)
        {
            int mySortIndex;
            string myReturnValue;
            if (int.TryParse(sortIndex, out mySortIndex))
            {
                switch (mySortIndex)
                {
                    case 100:
                        return string.Format(&quot;class=\&quot;first\&quot;&quot;);
                        break;
                    case 999:
                        return string.Format(&quot;class=\&quot;last\&quot;&quot;);
                        break;
                    default:
                        myReturnValue = string.Empty;
                        break;
                }
            }
            else
            {
                myReturnValue = string.Empty;
            }

            return myReturnValue;
        }
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Code was eaten by the page above so let&#8217;s try posting the .aspx code again in a pre tag</p>
<p>.aspx code</p>
<pre>
    &lt;li &gt;
</pre>
<p>.aspx.cs code</p>
<pre>
        ///
        /// Adds first and last classes to the list items
        ///
        ///
        /// Returns the css class in XHTML tag format
        ///
        /// Current level of navigation passed in using the Container.Index value
        /// The EPiSERVER Advanced Sort Index of the page
        protected string AddCssClassToPrimaryNavigationLi(int level, string sortIndex)
        {
            int mySortIndex;
            string myReturnValue;
            if (int.TryParse(sortIndex, out mySortIndex))
            {
                switch (mySortIndex)
                {
                    case 100:
                        return string.Format("class=\"first\"");
                        break;
                    case 999:
                        return string.Format("class=\"last\"");
                        break;
                    default:
                        myReturnValue = string.Empty;
                        break;
                }
            }
            else
            {
                myReturnValue = string.Empty;
            }

            return myReturnValue;
        }
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Judd</title>
		<link>http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/comment-page-1/#comment-237</link>
		<dc:creator>Alex Judd</dc:creator>
		<pubDate>Wed, 31 Mar 2010 16:24:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.frederikvig.com/?p=1101#comment-237</guid>
		<description>Hi Frederik

Very proudly solved it on my own :-) 

Here&#039;s the code used, and basically I expose the &#039;PagePeerOrder&#039; property from the CurrentPage (the one that you can set in the EPiSERVER Editor tool in the Advanced tab for the page), and use this to check whether the page is my first page (PagePeerOrder set to 100 the same as EPiSERVER does with the first page by default) or my last page (with PagePeerOrder set to 999 so that it will always be the last page).



&lt;li &gt;



        /// 
        /// Adds first and last classes to the list items
        /// 
        /// 
        /// Returns the css class in XHTML tag format
        /// 
        /// Current level of navigation passed in using the Container.Index value
        /// The EPiSERVER Advanced Sort Index of the page
        protected string AddCssClassToPrimaryNavigationLi(int level, string sortIndex)
        {
            int mySortIndex;
            string myReturnValue;
            if (int.TryParse(sortIndex, out mySortIndex))
            {
                switch (mySortIndex)
                {
                    case 100:
                        return string.Format(&quot;class=\&quot;first\&quot;&quot;);
                        break;
                    case 999:
                        return string.Format(&quot;class=\&quot;last\&quot;&quot;);
                        break;
                    default:
                        myReturnValue = string.Empty;
                        break;
                }
            }
            else
            {
                myReturnValue = string.Empty;
            }

            return myReturnValue;
        }

... I&#039;m sure there might be a nicer way to do it, but this works so should hopefully be a good reference for anyone else following Frederik&#039;s great posts and my less great comments on them :-)

Alex</description>
		<content:encoded><![CDATA[<p>Hi Frederik</p>
<p>Very proudly solved it on my own <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<p>Here&#8217;s the code used, and basically I expose the &#8216;PagePeerOrder&#8217; property from the CurrentPage (the one that you can set in the EPiSERVER Editor tool in the Advanced tab for the page), and use this to check whether the page is my first page (PagePeerOrder set to 100 the same as EPiSERVER does with the first page by default) or my last page (with PagePeerOrder set to 999 so that it will always be the last page).</p>
<p>&lt;li &gt;</p>
<p>        ///<br />
        /// Adds first and last classes to the list items<br />
        ///<br />
        ///<br />
        /// Returns the css class in XHTML tag format<br />
        ///<br />
        /// Current level of navigation passed in using the Container.Index value<br />
        /// The EPiSERVER Advanced Sort Index of the page<br />
        protected string AddCssClassToPrimaryNavigationLi(int level, string sortIndex)<br />
        {<br />
            int mySortIndex;<br />
            string myReturnValue;<br />
            if (int.TryParse(sortIndex, out mySortIndex))<br />
            {<br />
                switch (mySortIndex)<br />
                {<br />
                    case 100:<br />
                        return string.Format(&#8220;class=\&#8221;first\&#8221;");<br />
                        break;<br />
                    case 999:<br />
                        return string.Format(&#8220;class=\&#8221;last\&#8221;");<br />
                        break;<br />
                    default:<br />
                        myReturnValue = string.Empty;<br />
                        break;<br />
                }<br />
            }<br />
            else<br />
            {<br />
                myReturnValue = string.Empty;<br />
            }</p>
<p>            return myReturnValue;<br />
        }</p>
<p>&#8230; I&#8217;m sure there might be a nicer way to do it, but this works so should hopefully be a good reference for anyone else following Frederik&#8217;s great posts and my less great comments on them <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frederik Vig</title>
		<link>http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/comment-page-1/#comment-234</link>
		<dc:creator>Frederik Vig</dc:creator>
		<pubDate>Tue, 30 Mar 2010 18:08:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.frederikvig.com/?p=1101#comment-234</guid>
		<description>Hi Alex
Could you post the markup you&#039;re going for?

Frederik</description>
		<content:encoded><![CDATA[<p>Hi Alex<br />
Could you post the markup you&#8217;re going for?</p>
<p>Frederik</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Judd</title>
		<link>http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/comment-page-1/#comment-233</link>
		<dc:creator>Alex Judd</dc:creator>
		<pubDate>Tue, 30 Mar 2010 15:17:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.frederikvig.com/?p=1101#comment-233</guid>
		<description>Hi Frederik - Excellent again :-)

Container.Indent works nicely for nested levelled navigation - but any suggestions if you wanted to change the style using a similar method within the ItemTemplate to change the style on the first and last items?

My guessed approach would be something like this (pseudo code)

[Code Behind]

if (Container.Position == 1 &#124;&#124; Container.Position == Container.MaxCount) { ...code here to return different class information for css }</description>
		<content:encoded><![CDATA[<p>Hi Frederik &#8211; Excellent again <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Container.Indent works nicely for nested levelled navigation &#8211; but any suggestions if you wanted to change the style using a similar method within the ItemTemplate to change the style on the first and last items?</p>
<p>My guessed approach would be something like this (pseudo code)</p>
<p>[Code Behind]</p>
<p>if (Container.Position == 1 || Container.Position == Container.MaxCount) { &#8230;code here to return different class information for css }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deane</title>
		<link>http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/comment-page-1/#comment-213</link>
		<dc:creator>Deane</dc:creator>
		<pubDate>Fri, 12 Mar 2010 07:51:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.frederikvig.com/?p=1101#comment-213</guid>
		<description>Nicely done.  Very, very handy.</description>
		<content:encoded><![CDATA[<p>Nicely done.  Very, very handy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Green</title>
		<link>http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/comment-page-1/#comment-203</link>
		<dc:creator>David Green</dc:creator>
		<pubDate>Sun, 28 Feb 2010 18:02:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.frederikvig.com/?p=1101#comment-203</guid>
		<description>Hi Frederik

Thank you very much for your blog post. It has worked perfectly.
The Container.Indent value in the IndentTemplate is very useful.

Regards

David Green</description>
		<content:encoded><![CDATA[<p>Hi Frederik</p>
<p>Thank you very much for your blog post. It has worked perfectly.<br />
The Container.Indent value in the IndentTemplate is very useful.</p>
<p>Regards</p>
<p>David Green</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->