Technical support This forum is closed.
Version 1.x > Technical support > AliasPath problems View modes: 
User avatar
Member
Member
cpaul - 8/25/2005 10:37:07 PM
   
AliasPath problems
I have a structure like this

-Master Category (Page)
--Blog (Page)
---Article1 (Article)

-Master Category2 (Page)
--Blog2 (Page)
---Article12 (Article)

In a CMSViewer shown on the Master Category page, I'm trying to choose all the articles found in the Blog node below the current one, but it isn't working.

The following works (but I don't want to use that way):
1. Leave SelectNodesPath blank (not good because it would find articles outside of the Blog node.
2. Explicitly code absolute path to blog node (not good because the template won't work for other brances)

The following doesn't:
1. ~/Blog/%
2. Blog/%
3. ./Blog%

I had thought that number 1 was the correct way to specify this, but I guess not.

Any advice?

User avatar
Member
Member
kpatton - 8/26/2005 3:57:22 AM
   
Re: AliasPath problems
Hi,

~/Master Category/Blog/% is the correct way to specify the SelectNodesPath for your example.

Keith

User avatar
Guest
admin - 8/26/2005 11:34:23 AM
   
Re: AliasPath problems
Hi Chip,

The SelectNodesPath method can use only absolute URLs. Since version 1.7, there's a handy method for such situations: Functions.GetPathLevel.

Your code in the code behind will look like this:

CMSViewer.SelectNodesPath = Functions.GetPathLevel(Functions.GetAliasPath, 1) &"/blog/%"

Functions.GetPathLevel(Functions.GetAliasPath, 1) returns "/Master Category" or "/Master Category2" according to your location on the web site.

Please note that you will need to rename the alias "Blog2" to "Blog".

Should you need more details, please feel free to contact me.

Thank you.

Best Regards,

User avatar
Member
Member
cpaul - 8/26/2005 9:37:19 PM
   
Re: AliasPath problems
I'm wary of upgrading to 1.7 shortly before the site goes live... if I copied the code from the 1.7 Functions would it work, or does it rely on something in the 1.7 libraries?

User avatar
Member
Member
cpaul - 8/26/2005 9:45:48 PM
   
Re: AliasPath problems
I'm just putting this in my page load and it works:
TreeNode currentDocument = Functions.GetCurrentDocument();
string aliasPath = ((string) currentDocument.GetValue("AliasPath"));
aliasPath += "/Blog/%";
cmsBlogList.SelectNodesPath = aliasPath;

User avatar
Guest
admin - 8/26/2005 10:38:31 PM
   
Re: AliasPath problems
OK, I'm glad to see that you were able to resolve this.

You can also simply the code like this:

cmsBlogList.SelectNodesPath = Functions.GetAliasPath() + "/Blog/%";

You can copy the function GetPathLevel from version 1.7, from the functions.cs file as well.

Best Regards,

User avatar
Member
Member
JeremyThake - 12/5/2005 5:16:24 AM
   
Re: AliasPath problems
I'm using 1.7b and can't see this function. I did do the upgrade. I've also created a new 1.7b install with the demo corporate site and it's not in there either.

Basically I've got the same type of problem.

I've got a Page called Events with a NamePath of '/Events' and an AliasPath of '/News (1) (1)' . Under this I have a CMS item of Type of Event that i have created. I then have also two Event Dates items below this.
In my preview control for an Event I have a repeater to display the Event Dates. But when I created 3 test Events with different event dates, each event gets the same list...which is all the Event Dates.

I've tried hard coding the SelectNodesPath in the code behind for preview.ascx e.g. to '~/News (1) (1)/Getting Into Gear/%' but do not get any results.

The issue also is that on the page I am repeating the Events one after the other. From reading the API it say: "Path to the nodes to be selected. If you omit this value, the control automatically uses the current alias path from the "aliaspath" querystring parameter with "/%" at the end.". So if I left it blank they would all have the same path.

Can anyone help?

User avatar
Guest
admin - 12/5/2005 7:05:32 PM
   
Re: AliasPath problems
Hi Jeremy,

Thank you for your post. Could you please write me which function you couldn't find? Was it Functions.GetAliasPath() ?

Could you please write me what kind of output you're trying to achieve? Is it a hierarchical repeater? It would be helpful if you could send me some code and/or screenshot to petr.palas@kentico.com.

Thank you very much.

Best Regards,

User avatar
Member
Member
JeremyThake - 12/9/2005 2:41:29 AM
   
Re: AliasPath problems
The Functions.GetPathLevel() isn't in the Fuctions.cs file at all.



The output I'm trying to achieve is this:



I have an event item added to a Page Menu item. Under the event I have n number of EventDate items under that.



I want to be able to output the events, but also for each event output the EventDates with it.



<h2><%# DataBinder.Eval(Container, "DataItem.Title") %></h2>

<p><%# DataBinder.Eval(Container, "DataItem.Description") %></p>

<b>Event Dates</b>

<table>

<TR>

<TD>Day</TD>

<TD>Date</TD>

<TD>Time</TD>

<TD>Rating</TD>

</TR>

<cc1:cmsrepeater id="EventsDatesRepeater" runat="server" SelectNodesOrderBy="Date DESC" SelectNodesClassName="cms.EventsDates"

SelectNodesPathType="AliasPath" TransformationName="cms.EventsDates.default" />

</table>



So basically I wanted to then filter the cmsrepeater to only show EventsDates that are under that particular event. But when I do a repeater like this:



<cc1:cmsrepeater id="EventsRepeater" runat="server" SelectNodesOrderBy="EventId DESC" SelectNodesClassName="cms.Events"

SelectNodesPathType="AliasPath" TransformationName="cms.Events.default" />



For each event I get back all the EventDates under each event. The screen shot within CMS desk shows how they’ve been added (there is also some other items in there e.g. Adult Members which are EventCosts for different members which will be similar output to EventDates).





Thanks again, how is 1.8 coming along?




User avatar
Member
Member
JeremyThake - 12/20/2005 6:57:12 AM
   
RE: KB0015 - Displaying Hierarchical (Nested) Repeater
Petr pointed me in the direction of the Knowledge base article

I’ve also just had time to look at the hierarchical repeaters. The KB is based on the child elements having a reference id to the parent element which would mean in the form adding this template attribute to it. Is there no way of being able to see that it is a child node of the Event from the tree and add the relation that way?

I get this error when trying to bind to the repeater even trying to call a GetChildRows() method:

CS0117: 'object' does not contain a definition for 'Row'

Not quite sure why that is....
<asp:repeater id="rptEvent" runat="server">
<ItemTemplate>
<h2><%# DataBinder.Eval(Container, "DataItem.Title") %></h2>
<p><%# DataBinder.Eval(Container, "DataItem.Description") %></p>
<b>Event Cost(s)</b>
<table>
<TR>
<TD>Type</TD>
<TD>Cost</TD>
</TR>
<asp:Repeater id="rptEventsCosts" runat="server" datasource='<%# Container.DataItem.Row.GetChildRows("relEventsCosts") %>'>
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "cost") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "cost") %></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</ItemTemplate>
</asp:repeater>

the .cs code is:

//create a new TreeProvider instance
TreeProvider tree = Functions.GetTreeProvider();
//read all documents of type "cms.menuitem" and "mobilestore.phone"
DataSet ds = tree.SelectNodes("/events/%",
TreePathTypeEnum.AliasPath, "cms.events;cms.eventscosts".Split(';')
, "");
//add parent-child relation among tables
ds.Relations.Add("relEventsCosts",
ds.Tables["cms.events"].Columns["eventid"],
ds.Tables["cms.eventscosts"].Columns["eventid"]);
//set data source for the parent repeater
rptEvent.DataSource = ds.Tables["cms.events"];
//bind data
rptEvent.DataBind();

User avatar
Member
Member
JeremyThake - 12/20/2005 9:47:15 AM
   
Re: RE: KB0015 - Displaying Hierarchical (Nested) Repeater
Is there an easy way to debug what a SelectNodesPath should be to see whether it's setting it correctly?


User avatar
Guest
admin - 12/20/2005 5:21:47 PM
   
Re: RE: KB0015 - Displaying Hierarchical (Nested) Repeater
You can only see the returned DataSet with two tables using the Watch window in Visual Studio.

Best Regards,

User avatar
Guest
admin - 12/20/2005 5:20:47 PM
   
Re: RE: KB0015 - Displaying Hierarchical (Nested) Repeater
Hi Jeremy,

Thank you for your message. Your code seems to be correct except these lines:

<td><%# DataBinder.Eval(Container.DataItem, "cost") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "cost") %></td>

They should sound like:

<td><%# DataBinder.Eval(Container.DataItem, "[""cost""]") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "[""cost""]") %></td>

I'm not 100% sure if this is the real reason of this error, but it should move us one step further.

Generally, the hieararchical repeaters are very flexible and you can use them to display any data that is somehow related.

You can display the documents based on their parent-child relation in the tree view of documents by matching them by (parent's) NodeID = (child's) ParentNodeID.

Please let me know if this helped and if not, please send me the full stack trace.

Thank you very much.

Best Regards,