Copied to clipboard

Flag this post as spam?

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


  • John 3 posts 23 karma points
    May 31, 2010 @ 20:43
    John
    0

    Filtering Content By Member Groups

    Hi all,

    Apologies in advance for my lack of knowledge, simply not a .NET developer here trying to fumble my way through some things. I've got a good handle of working within Umbraco at this poing, but am faced with something beyond my abilities...

    I've got a "Guide" setup within the content area. Inside this are a bunch of content folders organized by categories (i.e. "power washers"). I've got the whole thing working the way I want to. If you go to the category page, it pulls all of the content I want and it even sorts the way I want ("Featured Advertisers" first).

    What I need to do now is to check to see if a user is logged in (got that part figured out) and display more content -ONLY- if they are in one of 4 member groups I have created ("ActiveMembers").

    I've tried this approach:http://forum.umbraco.org/yaf_postst9591_Getting-Members-Groups-From-Member-ID-in-XSLT.aspx

    I believe I got the .dll compiled correctly, followed the steps, but once I call the function in the XSLT, it fails...

    That post is a couple years old and I'm hoping there's an easier method for an idiot like me to see what Group a logged in user is in.

    Any help would be GREATLY appreciated. Thanks.

     

     

  • skiltz 501 posts 701 karma points
    May 31, 2010 @ 21:28
    skiltz
    1

    In a usercontrol (.NET) you would normally do something like. 

    if (HttpContext.Current.User.IsInRole("ActiveMembers"))
    {
    //dostuff here
    }
  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    May 31, 2010 @ 21:34
    Dirk De Grave
    0

    Call probably fails because you haven't registered the xslt extension in xsltExtensions.config (well, it would help if you could tell us a bit more about the exact error message you receive)

    Can't find the wiki reference atm, best I could find is this post on how to configure the extension

     

    Hope this helps.

    Regards,

    /Dirk

  • John 3 posts 23 karma points
    Jun 01, 2010 @ 00:26
    John
    0

    Ok, sorry I was a little vague.

    So here's specifically what i've done:

    1. Compile the code from that post into a DLL, which all seems to go well. I did change the namespace from "bctllc.xsltext" to "xsltmembers"

    2. Uploaded .dll into BIN folder

    3. Update xsltExtensions.config to include:

        <ext assembly="/bin/xsltmembers" type="xsltmembers.members" alias="getxsltmembers" />

    4. In my existing XSLT, added the following at the top:

        xmlns:xsltmembers="urn:getxsltmembers"

    and added "xsltmembers" to the exlude portion...

    5. I add this line, to get the logged in user's ID:

     <xsl:variable name="currentlogin" select="umbraco.library:GetCurrentMember()/@id"/><br/>

    6. This all saves correctly, without errors... but then I try to add this code (from the original post):


    <xsl:for-each select="xsltmembers:GetMemberGroupsForMember($currentlogin)/group">
            <xsl:value-of select="@id"/><xsl:value-of select="."/>
    </xsl:for-each>

    I get this error:

    System.OverflowException: Value was either too large or too small for an Int32.
    at System.Convert.ToInt32(Double value)
    at System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
    at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
    at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
    at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
    at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging) in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\umbraco\presentation\umbraco\webservices\codeEditorSave.asmx.cs:line 124

     

     

  • John 3 posts 23 karma points
    Jun 01, 2010 @ 00:33
    John
    0

    Ok, what's weird is if I hard code in a member ID like this:

    <xsl:for-each select="xsltmembers:GetMemberGroupsForMember(2780)/group">

    It works fine...

    So what's wrong with this?:

     <xsl:variable name="currentlogin" select="umbraco.library:GetCurrentMember()/@id"/>

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies