How can I make the content of the child node appear on the parent node? Options
Ewatkins
Posted: Thursday, October 30, 2008 6:22:19 PM
Rank: Aficionado

Joined: 10/8/2008
Posts: 106
Location: Virginia
Here is what I need to accomplish. I am creating a website to show homes, I have a content page called listings that allows text page children. I want to make the children of Listings be individual listings (ie: Listings is the parent and say 123 5th st. is a child a 123 P st. is another child) How can I make the children appear on listings.aspx? I want it so that the site visitor can go to /listings.aspx and see all of the listings and I can go into the back end and see all of them seperate. Please let me know how I can do this.
Ewatkins
Posted: Thursday, October 30, 2008 6:50:21 PM
Rank: Aficionado

Joined: 10/8/2008
Posts: 106
Location: Virginia
I think I need to use content picker and pick the listings I want to show on the listings page, how do I get them to show up? Listings is its own document type that has a property Content Picker. The content I want to pick from is a text page (Which contains a richtext eidtor and meta information), how can I select the property and have it shown on listings.aspx?

Also, what do I need to put in my template to show the contents of a text page? I am very new to umbraco sorry for all of the dumb questions
nwahlberg
Posted: Thursday, October 30, 2008 7:44:17 PM

Rank: Devotee

Joined: 10/20/2008
Posts: 83
Location: USA
Hi, welcome to Umbraco.

I am a fellow newbie and have gone through several trials and tribulations so far. It sounds like you basically want to provide a list of pages and link to them? The best way to accomplish this would be to create an XSLT macro to loop over the XML document nodes and print them out. So, you might want to start with reading about Umbraco's XML doc and all the various XSL capabilities. A great article that I keep going back to is:

XSLT Basics

This will tell you about the core structure and how to traverse it using XSLT logic and the like. It is very powerful.

I am just writing this off the top of my head, but your XSLT macro would probably looks something like:

Code:
<xsl:for-each select="umbraco.library:GetXmlAll()/descendant-or-self::node [
            and string(data[@alias='umbracoNaviHide'] != '1')
            ]">
        <a href="{umbraco.library:NiceUrl(@id)}">
            <xsl:value-of select="@nodeName"/><br />
        </a>
</xsl:for-each>


Then, insert the created macro in one of your templates. NOTE: Use the developer section to create the necessary XSLT and corresponding macros.

Hope this helps.

-- Nik

Level 1 Certified / www.scandiaconsulting.com
nwahlberg
Posted: Thursday, October 30, 2008 7:46:41 PM

Rank: Devotee

Joined: 10/20/2008
Posts: 83
Location: USA
You should also check out the various pre-made templates that are available when create a new XSLT file.

Cheers!

Level 1 Certified / www.scandiaconsulting.com
Ewatkins
Posted: Thursday, October 30, 2008 8:34:29 PM
Rank: Aficionado

Joined: 10/8/2008
Posts: 106
Location: Virginia
I do not want to link to the child pages, i want to display the content of the child pages on the parent page
nwahlberg
Posted: Thursday, October 30, 2008 8:46:14 PM

Rank: Devotee

Joined: 10/20/2008
Posts: 83
Location: USA
Ok, I see. You should be able to do something similar to what my XSLT snippet is showing by referencing other aliases. So, instead, it might look something like:

Code:
<?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"
    exclude-result-prefixes="msxml umbraco.library">


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

<xsl:param name="currentPage"/>

<!-- Input the documenttype you want here -->
<xsl:variable name="documentTypeAlias" select="string('NewsletterMonth')"/>

<xsl:template match="/">

<!-- The fun starts here -->
<xsl:for-each select="umbraco.library:GetXmlAll()/descendant-or-self::node [
        string(data[@alias='umbracoNaviHide'] != '1')]">
        <strong><xsl:value-of select="@nodeName"/></strong> <br />
        <xsl:value-of select="data [@alias = 'bodyText']" disable-output-escaping="yes"/>
        <hr />
</xsl:for-each>

</xsl:template>

</xsl:stylesheet>


NOTE: Replace 'bodyText' with the name of your content field. Disable-output-escaping is only necessary if you have (x)HTML tags and such that need to be rendered. Also, this will give you ALL pages that live under the root node. You can also limit this by level or other attributes as well. Additionally, the 'umbracoNaviHide' filter isn't necessary. It is a defacto standard for Umbraco to use this field for omitting pages from navigation and lists like the one above (if necessary). The field would need ot be specified as part of your document type in order to be affective.

Best,
Nik



Level 1 Certified / www.scandiaconsulting.com
Ewatkins
Posted: Thursday, October 30, 2008 8:55:02 PM
Rank: Aficionado

Joined: 10/8/2008
Posts: 106
Location: Virginia
do I put that in my master page (using v4 beta 2) or what? sorry I just started using this yesterday...
nwahlberg
Posted: Thursday, October 30, 2008 10:47:02 PM

Rank: Devotee

Joined: 10/20/2008
Posts: 83
Location: USA
No worries, I know how confusing things can be at first. See if you can follow these instructions (hopefully I'll make sense):

Create an XSLT:
1. Go to Developer section
2. Right click XSLT Files and click 'Create'
3. Fill in a name for your XSLT file (ex. List Site Pages)
4. Choose template - Clean (note this is where I encourage you to play with the various templates with other XSLTs to see what they do and how you can use them to get started).
5. Check off 'Create macro' (this is what you will use to display things in your template. After you save the XSLT you can reload the tree and see a matching macro listed)
6. Paste the above snippet (replacing what is in your newly created XSLT)

Include Macro in template
1. Click Settings
2. Navigate to your template
3. Click insert macro icon (third from left)
4. Select List Site Pages
5. Click ok
6. Save template

You should now see the pages listed on any page that utilizes the template.

Good luck,
Nik

Level 1 Certified / www.scandiaconsulting.com
Ewatkins
Posted: Friday, October 31, 2008 2:34:14 PM
Rank: Aficionado

Joined: 10/8/2008
Posts: 106
Location: Virginia
Alright thanks, I put that in and it is almost there except it is showing the name of all of my pages in my umbraco and displaying the content of what I want under the name if that instance is using listingtext. how do I get it to only display the names and content of those using listingtext? somehow is it showing the names of the ones that are using body text and the content of the ones showing listingtext. how do I stop this?
Ewatkins
Posted: Friday, October 31, 2008 2:54:40 PM
Rank: Aficionado

Joined: 10/8/2008
Posts: 106
Location: Virginia
ahh crap I thought I had it right but for some reason now the listingtext is showing up on the bottom of every page not just the parent page, any ideas? I think the problem is that in my master page I have this..

<asp:ContentPlaceHolder id="body" runat="server">
<umbraco:Item field="body text" runat="server"></umbraco:Item>

<umbraco:Macro Alias="Property" runat="server"></umbraco:Macro>
</asp:ContentPlaceHolder>

The macro Property is what is holding the xslt info, did I put that in the right place? It works fine on the listing page but it is showing the contents of each individual listing on every other site, what do I need to change?

Here is the XSLT file as well:
<?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"
exclude-result-prefixes="msxml umbraco.library">


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

<xsl:param name="currentPage"/>

<!-- Input the documenttype you want here -->
<xsl:variable name="documentTypeAlias" select="string('NewsletterMonth')"/>

<xsl:template match="/">

<!-- The fun starts here -->
<xsl:for-each select="umbraco.library:GetXmlAll()/descendant-or-self::node[
string(data[@alias='umbracoNaviHide'] != '1')]">

<xsl:value-of select="data [@alias = 'listingtext']" disable-output-escaping="yes"/>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>
Ewatkins
Posted: Friday, October 31, 2008 3:45:12 PM
Rank: Aficionado

Joined: 10/8/2008
Posts: 106
Location: Virginia
I figured it out I had to create a new template for it, thanks so much
nwahlberg
Posted: Friday, October 31, 2008 6:36:07 PM

Rank: Devotee

Joined: 10/20/2008
Posts: 83
Location: USA
Great, good to hear.

-- Nik

Level 1 Certified / www.scandiaconsulting.com
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.