Copied to clipboard

Flag this post as spam?

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


  • Roger 195 posts 474 karma points
    Jan 27, 2014 @ 14:18
    Roger
    0

    List pages where memberID = memberID

    Hi,

    I have a group of members that once logged in, need to be able to see a list of pages based on their logged in memberID.

    The document type has a property 'venueOwner' of the type member picker.

    I just need to be able to list all the pages (venue, children of venues node) that match the memberID to venueOwner

    (i think i need to have a filter on the sectionNode variable?)

    <xsl:template match="/">
       
    <xsl:variable name="sectionNode" select="$currentPage/ancestor-or-self::*/Venues/Venue"/>

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$sectionNode">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

  • Chriztian Steinmeier 2741 posts 8406 karma points MVP 6x admin c-trib
    Jan 27, 2014 @ 14:36
    Chriztian Steinmeier
    1

    Hi Roger,

    Yes - you can either apply the filter to the sectionNode variable, or you can set the filter in the for-each - depends on where you think it makes sense to "read" that these are filtered nodes.

    Something along the lines of:

    <xsl:template match="/">
        <xsl:variable name="member" select="umbraco.library:GetCurrentMember()" />
        <xsl:variable name="sectionNode" select="$currentPage/ancestor-or-self::*/Venues/Venue" />
    
        <ul>
            <xsl:for-each select="$sectionNode[venueOwner = $member/@id]">
                <li>
                    <a href="{umbraco.library:NiceUrl(@id)}">
                        <xsl:value-of select="@nodeName"/>
                    </a>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:template>
    

    /Chriztian

  • Roger 195 posts 474 karma points
    Jan 27, 2014 @ 15:47
    Roger
    100

    Thats exactly what we have. Works great now, thanks for reply :)

  • Roger 195 posts 474 karma points
    Jan 27, 2014 @ 16:54
    Roger
    0

    Hi Chriztian,

    Just a quick one, thats all working now but we need to compare the values of the memberID and venueOwner in a usercontrol update form. If the values are the same then display the panel with the form fields.

    We can get the current value of the venueOwner: var vo = currentPage.GetProperty("venueOwner");

    Whats the best way to compare the venueOwner and the CurrentMemberID in order to display the panel?

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using umbraco.NodeFactory;
    using umbraco.cms.businesslogic.web;
    using umbraco.businesslogic;

    public partial class UserControls_UpdateVenue : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                // populate the text fields
                Node currentPage = Node.GetCurrent();
                pageName.Text = currentPage.Name;
                bodyText.Text = currentPage.GetProperty("bodyText").Value;

                var vo = currentPage.GetProperty("venueOwner");       

            }

        }
        protected void update_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {

                // Get the Document object via the nodefactory
                Document currentPage = new Document(Node.GetCurrent().Id);

                // Update the name of the page (text property)
                currentPage.Text = pageName.Text;

                // Update the bodyText property
                currentPage.getProperty("bodyText").Value = bodyText.Text;

                // Publish
                currentPage.Publish(currentPage.User);

                // Refresh runtime cache
                umbraco.library.PublishSingleNode(currentPage.Id);

                // redirect
                Response.Redirect(umbraco.library.NiceUrl(currentPage.Id), true);

            }
        }
    }

Please Sign in or register to post replies

Write your reply to:

Draft