Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • trfletch 598 posts 604 karma points
    Feb 16, 2011 @ 21:50
    trfletch
    0

    Custom section node names repeating themselves

    Hi,

    I am running a site with Umbraco 4.5.2 and I have managed to create a custom section that has three nodes which display some aspx pages. All seems to be ok when I first go into the custom section, it creates the nodes as follows:

    Adverts
       - Advertisers
       - Campaigns
       - Reporting

     

    The issue comes when I click on another section such as the media section, then I come back to my custom section, it then displays the names as follows:

    Adverts
       - AdvertisersCampaignsReporting
       - AdvertisersCampaignsReporting
       - AdvertisersCampaignsReporting

    All the nodes work correctly still it is just the names that have gone funny, if I click on a different section again and then come back I get:

    Adverts
       - AdvertisersCampaignsReportingAdvertisersCampaignsReportingAdvertisersCampaignsReporting
       - AdvertisersCampaignsReportingAdvertisersCampaignsReportingAdvertisersCampaignsReporting
       - AdvertisersCampaignsReportingAdvertisersCampaignsReportingAdvertisersCampaignsReporting

     

    If I was to then refresh my browser it would return to normal until I start moving between sections again, does anyone know what could be causing this? I have very little asp.net knowledge so it is likely that there is something wrong with my code which is as follows:

    using

     

     

    System;

    using

     

     

    System.Collections.Generic;

    using

     

     

    System.Linq;

    using

     

     

    System.Web;

    using

     

     

    umbraco.cms.presentation.Trees;

    namespace

     

     

    Portal.Ads

    {

     

     

    public class loadAdsTree:BaseTree

    {

     

     

    public loadAdsTree(string application) :

     

     

    base(application) { }

     

     

    protected override void CreateRootNode(ref XmlTreeNode rootNode)

    {

    rootNode.Icon = FolderIcon;

    rootNode.OpenIcon = FolderIconOpen;

    rootNode.NodeType =

     

    "init" + TreeAlias;

    rootNode.NodeID =

     

    "init";

    }

     

    public override void Render(ref XmlTree Tree)

    {

     

     

    // Create tree node to allow Advertisers editing

     

     

    var advertisers = XmlTreeNode.Create(this);

    advertisers.Text =

     

    "Advertisers";

    advertisers.Icon =

     

    "docPic.gif";

    advertisers.Action =

     

    "javascript:openAdvertisers()";

     

     

    // Add the node to the tree

    Tree.Add(advertisers);

     

    // Create tree node to allow Campaign editing

     

     

    var campaigns = XmlTreeNode.Create(this);

    campaigns.Text =

     

    "Campaigns";

    campaigns.Icon =

     

    "docPic.gif";

    campaigns.Action =

     

    "javascript:openCampaigns()";

     

     

    // Add the node to the tree

    Tree.Add(campaigns);

     

    // Create tree node to allow Report creation

     

     

    var reporting = XmlTreeNode.Create(this);

    reporting.Text =

     

    "Reporting";

    reporting.Icon =

     

    "docPic.gif";

    reporting.Action =

     

    "javascript:openReporting()";

     

     

    // Add the node to the tree

    Tree.Add(reporting);

    }

     

     

    public override void RenderJS(ref System.Text.StringBuilder Javascript)

    {

    Javascript.Append(

     

    @"

    function openAdvertisers() {

    parent.right.document.location.href = '/advertisers.aspx';

    }

    "

     

     

    );

     

     

    Javascript.Append(

     

    @"

    function openCampaigns() {

    parent.right.document.location.href = '/campaigns.aspx';

    }

    "

     

     

    );

     

    Javascript.Append(

     

    @"

    function openReporting() {

    parent.right.document.location.href = '/reporting.aspx';

    }

    "

     

     

    );

    }

     

    }

    }


  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Feb 17, 2011 @ 08:29
    Sebastiaan Janssen
    0

    Yeah, I pinged someone about this a while back, but it looks like it hasn't been fixed yet, make sure to create a codeplex issue for this. It seemed to happen to me after I installed Contour, but that isn't necessarily related.

  • Martin Lingstuyl 202 posts 379 karma points
    Feb 17, 2011 @ 12:13
    Martin Lingstuyl
    0

    I read somewhere that it has to do with unique (parsable) NodeIDs from your treeNodes.

    Lets say I create the following node

    XmlTreeNode sNode = XmlTreeNode.Create(this);
    sNode.NodeID = "1";
    sNode.NodeType = "nodetype1";
    sNode.Text = "Node Test 1"
    sNode.Icon = "style.png";
    sNode.Action = "javascript:openNode(1)";
    TreeService sTreeService = new TreeService(-1, TreeAlias, ShowContextMenu, IsDialog, DialogMode, app, "node" + 1);
    sNode.Source = sTreeService.GetServiceUrl();
    Tree.Add(sNode);

     

    And then lets say I have another list of nodes (or subnodes from a node) of which by chance one has the same NodeId (for example because it uses a databasetabel rowID):

    xNode.NodeID = tableRow.id ;

    Then the names will go funny.

    So you should try to use absolutely unique NodeID's.

    -----

    You could also use random text as a nodeID, for example:

    sNode.NodeID = "nodeID1";

    The problem would then be that you cannot use the Delete button in the menu. (of course you should first create an iTaskReturnUrl class to use the delete function) The problem in my understanding is that the nodeID gets parsed to an integer (the ParentID integer in your iTaskReturnUrl class). If that fails, the button wont know which node you want to delete.

     

    So, thats as far as i have come. Its definitely a bug. You can circle around it by using absolutely unique numbers for nodeId's, but of course, this is not always easy, for example when you're iterating multiple database tables with the nodeId's being their primary key records.

     

     

  • Martin Lingstuyl 202 posts 379 karma points
    Feb 17, 2011 @ 12:14
    Martin Lingstuyl
    0

    In your case I see you havent used NodeId's at all.

    try adding that. (according to my code above)

  • Marc Aarts 14 posts 35 karma points
    Mar 07, 2011 @ 14:40
    Marc Aarts
    0

    I solved the deleting problem by giving stripping off the text to make the node unique in the delete event like this:

                if (ParentID == 0)
                {
                    ParentID = int.Parse(Alias.Replace("ai-", ""));
                }

    After setting the NodeID like this:

    node.NodeID = String.Format("ai-{0}", Convert.ToString(dataReader["a_id"]));

    The 'Alias' property contains a string representation of my node.NodeID.

    I am not aware of any unwanted side-effects so far.

  • Martin Lingstuyl 202 posts 379 karma points
    Mar 08, 2011 @ 10:53
    Martin Lingstuyl
    1

    Ah, found that out too, last month.

    If you use an integer, it will get saved in the ParentID property.

    If you use a string like you just did, it will get saved in the Alias property.

    so lets put this topic to solved.

  • Anders Brohäll 295 posts 561 karma points c-trib
    Mar 06, 2012 @ 18:25
    Anders Brohäll
    0

    I ran into the same problem, solving it like thanks to your posts.


    int idAddition = 0;
    .....
    xmlTreeNode.NodeID = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture) + (idAddition += 1);
  • Martin Lingstuyl 202 posts 379 karma points
    Mar 06, 2012 @ 18:30
    Martin Lingstuyl
    0

    Ah this is also a smart approach.
    You mean that in this way the NodeID will be different every second, and therefore the nodenames will not repeat?!

     

    Too bad umbraco 5 is totally different :-)

    Martin

  • Eric Schrepel 161 posts 226 karma points
    Jun 11, 2013 @ 23:11
    Eric Schrepel
    0

    I have this problem after upgrading to Umbraco 6.1.1 (assembly version 1.0.4901.15961 build 4 as of June 9, 2013). Simply browsing the Media folder (in the Umbraco UI), node names get longer and longer throughout a session, tacking on versions of themselves. See attached screencap, where under "accord", nodes should just be:

    accord
        2002059Council
        20020206100
        2002061Council 
    ... 

     

  • Martin Lingstuyl 202 posts 379 karma points
    Jun 12, 2013 @ 22:03
    Martin Lingstuyl
    0

    hi eric,

     

    dit you take my advice in the earlier posts? it still works for me, also in umbraco 6.

    could you post your node definition code and itaskreturnurl class?

     

    martin

  • Eric Schrepel 161 posts 226 karma points
    Jun 12, 2013 @ 23:48
    Eric Schrepel
    0

    Martin you're a level beyond me for sure; we just use the default Umbraco UI, I haven't written node definition code or classes. So within the normal unaltered UI, the media nodes repeat like that. It's something that just started happening after upgrading to Umbraco 6, and has hung along through 6.1.1.

    I think my question's more likely a bug report for that upgrade package or something; I know it was supposed to be fixed in the 6.1.1 build 4 package, but hasn't resolved yet.

Please Sign in or register to post replies

Write your reply to:

Draft