November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
The code is terrible cluttered. Look, what I want to do is use a repeater inside a EpiServer:PageList but I cant get it to work.
Think I solved it with DataSource='<%#Container.CurrentPage["ImageGallaryControl"]%>' on the repeater =)
Yes it is definitely possible to nest repeaters or pagelists but as you noticed you have to set the datasource of the nested repeater in one way or the other (in markup as you did is the simplest way as long as it's sufficient and you don't need to do more advanced operations to set the data source.
If you want to manipulate the colleciton of pages in other ways than what the built in filter proerties allow you to do (RequiredAccess, PublishStatus etc) there are several ways. The simplest in this case is probably to use the code behind to get your root node (read the property you would otherwise set in PageListProperty), load its child pages using the language selector you want and set the DataSource property of the PageList.
Iam not quite following you. =)
In the front end code, the PageList should not have a PageLinkProperty then, correct? That is removed.
In the code behind I should type something like:
VaraFavoriterRepeater.DataSource = CurrentPage.PageLink.???
// VaraFavoriterRepeater is the PageList (just to confuse things ;))
First, use the property to get the root page, then compile the list of pages in a way that is appropriate for your requirements. If you would use PageLinkProperty="RootLink" in codefront, in codebehind you could do this:
PageLink rootLink = CurrentPage["RootLink"] as PageReference;
if (rootLink != null)
{
VaraFavoriterRepeater.DataSource = DataFactory.Instance.GetChildren(rootLink, new LanguageSelector(CurrentPage.LanguageBranch));
}
I haven't tried this so I'm not sure the language selection is correct or does what you want it to do, but basically you could do whatever you wanted with the collection returned by GetChildren before setting it to the datasource property of the PageList, so you could manually remove the pages you don't want in there if all else fails.
// Front end. PageLinkProperty is set to PageLink, so the children of that page is repeated.
EPiServer:PageList ID="VaraFavoriterRepeater" PageLinkProperty="PageLink"
// Back end. There is no type PageLink? You write a variable named rootLink that is of type PageLink, is that correct? In the Page_Load event?
This makes rootLink a pagereference: var rootLink = CurrentPage.PageLink as PageReference; I try from there
It worked =))
- No PageLinkProperty in code front because that seams to override it and all is displayed.
- In code behind:
var rootLink = CurrentPage.PageLink as PageReference;
if (rootLink != null)
{
VaraFavoriterRepeater.DataSource = DataFactory.Instance.GetChildren(rootLink, new LanguageSelector(CurrentPage.LanguageBranch));
}
You don't need to cast CurrentPage.PageLink to a PageReference, it already is. I assumed you had a property where you pointed to the page you wanted to list the children of. If you want to use the current page you can skip a lot of code and just use the below since you don't even need the null check:
VaraFavoriterRepeater.DataSource = DataFactory.Instance.GetChildren(CurrentPage.PageLink, new LanguageSelector(CurrentPage.LanguageBranch));
Yes, reviewing the code I figured that out. All's well. Have a nice weekend Magnus! Thanks big time
One other thing ... To give the best service to our editors, I want the PageLink to appear here
rel='lightbox[<%# (Container.DataItem as EPiServer.SpecializedProperties.LinkItem).Text %>]'
This is the nested repeater on the parent page. As you remember I set the datasource to the Container.CurrentPage["ImageGallaryControl"]% so Container.CurrentPage.PageLink doesnt work. Anyway to fix it?
Another thing by the way CurrentPage.PageLink in inline code gives the page id? Correct? Why is that? It doesnt mather for my solution (hard to explain), but Iam just courius.
The inline syntax always outputs strings (unless it is data binding syntax in a server attribute) which is why you see the ID, it is simply the ToString representation of the PageReference.
The reason you can't use Container.CurrentPage.PageLink in the repater is twofold: First, the Container.CurrentPage property is unique to the EPiServer controls, the standard controls like repater have no knowledge of PageDatas and other EPiServer objects. Second, since you use a LinkCollection as source there wouldn't even be an unambiguous PageData since a LinkCollection can point to other things than pages.
If the links in the linkcollection are pages you can get the corresponding PageData. You can find inspiration of how here:
http://joelabrahamsson.com/entry/convert-a-linkitemcollection-to-a-list-of-pagedata
I suggest you implement a method in the codebehind which takes the LinkItem as input and outputs the ID as a string or whatever you wanted in the rel-attribute. In that method you can handle the case when the LinkItem points to something else than a PageData.
Hi!
I have a Page Template (1) with this code:
Code behind:
Following this guide: http://sdk.episerver.com/library/cms5/Developers%20Guide/How%20To/Use%20Link%20Collection%20property.htm
It works great.
However, this PageTemplate should be used for child pages. A parent page should then have repeater for these children. Like this Page Template (2):