Tip #1 : Finding child pages based upon a parent page

Tip #1 : Finding child pages based upon a parent page

Posted on February 17, 2007 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

 

The scenario

Well, except from the fact that one of the pillars of good parenthood is the ability to tell your own children from all the other kids, there are actually other (more practical and less formal) reasons why you may need to get the reference to all the child pages of any given page made with Sitefinity.

Let’s imagine following scenario. You ran a website for a local car dealership. The dealership struck a deal with a monthly car fan magazine to be published online on their website. So, you go and create a page for the car magazine. This page then contains pages that each represent a monthly issue. Inside of these monthly issue pages, you then have pages like news, car tests, articles etc.

What you’d like to do is to show on the right side of the magazine front page description and link to all the cover stories from each issue.

Take a look at the screenshot to get an idea what am I talking about (click on the thumbnail to enlarge it).

Finding child pages based upon a parent page

Implementation

First create the page structure like described in the scenario : Magazine > Issue #1 > News, Articles… Create two issue pages just to see the point of the example.

For each “magazine issue” page set the page title to the cover story title and in description type the brief introduction of the cover story. Take a look at the screenshot to get an idea (click on the thumbnail to enlarge it).

Page properties

It is important to set these values to reflect the cover story of the issue, since we will use the CmsPage.Title and CmsPage.Description properties to create our User Control with the cover stories.

Create CoverStories.ascx User Control

Once, you are done with that we’ll create a User Control that will display all Cover stories on the right side of magazine front page. The approach we’ll take here is to get the current node of the sitemap (magazine front page) and then loop through all of it immediate children (issue pages), extract page title and page description and create controls with those value. Take a look at the code bellow :

Open code in new window

Now, all that’s left is to upload the user control and add it to our magazine page. Consult the Developer Manual if you are unsure how to add User Control to Sitefinity page.

Hopefully, you’ll find some use of this )

progress-logo

The Progress Team

View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments

Comments are disabled in preview mode.
Topics

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Loading animation