I would now like to create individual folders (when the user accesses this section) so when they click each folder they are redirected to a specific webpage within the site. How do i do this?
How about something similar to your example link but changing the following methods? You could replace your myObjects collection with Umbraco Content objects.
public override void Render(ref XmlTree tree)
{
IEnumerable myObjects = (new MyRepository()).GetAllObjects();
foreach (MyObject o in myObjects)
{
XmlTreeNode node = XmlTreeNode.Create(this);
node.NodeID = b.Id.ToString();
node.Text = b.Name;
node.Icon = FolderIcon;
node.Action = String.Format(“openNodeUrl({0})”, b.Url);
tree.Add(node)
}
}
public override void RenderJS(ref StringBuilder Javascript)
{
Javascript.Append(@"
function openNodeUrl(url) {
window.location = url;
}
");
}
[quote]You could replace your myObjects collection with Umbraco Content objects.[\quote]
Thanks. I dont have any content objects to load (unless ive picked the wrong approach) but ideally i would like to have a few folders so when a user clicks one of these folders they are presented with a page within my site. Therefore i did the below
I have the SomeText node appearing but when clicking this folder it doesnt redirect me to a webpage within my site? So all im after now is when the SomeText folder is clicked it needs to open up a page. Thanks
Im not sure what you mean by console Logs? What i am expecting to happen is when i click this folder it would open up http://localhost/mysite/mypage.aspx. No errors are listed when clicking the Some text folder.
If you are using Google Chrome, take a look at their documentation on how to access the browser's console logs. The reason I ask is to find out whether or not there are any JavaScript errors present when clicking your folder node.
There are a few errors but non that should create this problem i would believe
body.scrollTop is deprecated in strict mode. Please use 'documentElement.scrollTop' if in strict mode and 'body.scrollTop' only if in quirks mode. DependencyHandler.axd?s=L3VtYnJhY29fY2xpZW50L0FwcGxpY2F0aW9uL05hbWVzcGFjZU1hbmFnZXIuanM7L3VtYnJhY29…:6
body.scrollLeft is deprecated in strict mode. Please use 'documentElement.scrollLeft' if in strict mode and 'body.scrollLeft' only if in quirks mode. DependencyHandler.axd?s=L3VtYnJhY29fY2xpZW50L0FwcGxpY2F0aW9uL05hbWVzcGFjZU1hbmFnZXIuanM7L3VtYnJhY29…:6
event.returnValue is deprecated.
What i noticed is the URL when i hover over the folder to be in this format:
i changed it to String.Format("openNodeUrl(\'{0}\')", "http://localhost/mysite/mypage.aspx"); which did the trick. However i have kept your code just in case i get an issue down the line - thanks
How to redirect to a webpage
I am using this link http://www.it-potato.com/2013/07/adding-a-custom-section-in-umbraco-6/ to create a custom section, which ive completed.
I would now like to create individual folders (when the user accesses this section) so when they click each folder they are redirected to a specific webpage within the site. How do i do this?
How about something similar to your example link but changing the following methods? You could replace your myObjects collection with Umbraco Content objects.
[quote]You could replace your myObjects collection with Umbraco Content objects.[\quote]
Thanks. I dont have any content objects to load (unless ive picked the wrong approach) but ideally i would like to have a few folders so when a user clicks one of these folders they are presented with a page within my site. Therefore i did the below
public override void Render(ref XmlTree tree)
{
XmlTreeNode node = XmlTreeNode.Create(this);
node.NodeID = "1";
node.Text = "Some text";
node.Icon = FolderIcon;
node.Action = String.Format("openNodeUrl({0})", "http://localhost/mysite/mypage.aspx");
tree.Add(node);
}
but doesnt work?
Does your "Some text" node appear in your custom tree? If so, are there any console errors when clicking the node?
I have the SomeText node appearing but when clicking this folder it doesnt redirect me to a webpage within my site? So all im after now is when the SomeText folder is clicked it needs to open up a page. Thanks
Are there any console logs in your browser after clicking the node?
Im not sure what you mean by console Logs? What i am expecting to happen is when i click this folder it would open up http://localhost/mysite/mypage.aspx. No errors are listed when clicking the Some text folder.
If you are using Google Chrome, take a look at their documentation on how to access the browser's console logs. The reason I ask is to find out whether or not there are any JavaScript errors present when clicking your folder node.
There are a few errors but non that should create this problem i would believe
body.scrollTop is deprecated in strict mode. Please use 'documentElement.scrollTop' if in strict mode and 'body.scrollTop' only if in quirks mode. DependencyHandler.axd?s=L3VtYnJhY29fY2xpZW50L0FwcGxpY2F0aW9uL05hbWVzcGFjZU1hbmFnZXIuanM7L3VtYnJhY29…:6
body.scrollLeft is deprecated in strict mode. Please use 'documentElement.scrollLeft' if in strict mode and 'body.scrollLeft' only if in quirks mode. DependencyHandler.axd?s=L3VtYnJhY29fY2xpZW50L0FwcGxpY2F0aW9uL05hbWVzcGFjZU1hbmFnZXIuanM7L3VtYnJhY29…:6
event.returnValue is deprecated.
What i noticed is the URL when i hover over the folder to be in this format:
http://localhost:1234/umbraco/openNodeUrl(http://www.mysite.com)
thats after the Action is set to
node.Action = String.Format("openNodeUrl({0})", "http://www.mysite.com");
and that doesnt work so internal links wont work either?
Try changing the node action to:
i changed it to String.Format("openNodeUrl(\'{0}\')", "http://localhost/mysite/mypage.aspx"); which did the trick. However i have kept your code just in case i get an issue down the line - thanks
is working on a reply...