Copied to clipboard

Flag this post as spam?

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


  • Eirik 25 posts 75 karma points
    Apr 23, 2012 @ 23:07
    Eirik
    0

    Adding custom section to Umbraco 4.7.1.1

     

    Hi all,

    I have developed a custom section to the admin dashboard for the first time. I am following the tutorial in the UmbracoTV, but I got one problem. The title of the node under the rootnode in the new section is appending text. Every time I go to another section and back, the text pf tje node is appended with the same text like this.

    ยท        

     

     

     

     

    Also, I dont want my nodes to be added under new folders. The nodes should be directly under "Training" like in the example in UmbracoTV. I feel that I follow the example in UmbracoTV to the point, but still no success.

    My code looks like this:

    namespace EirikTest.CustomTree

    {

        public class loadTraining : BaseTree

        {

            public loadTraining(string application) :

                base(application) { }

            protected override void CreateRootNode(ref XmlTreeNode rootNode)

            {

                rootNode.Icon = FolderIcon;

                rootNode.OpenIcon = FolderIconOpen;

                rootNode.NodeType = TreeAlias;

                rootNode.NodeID = "init";

            }

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

            {

                Javascript.Append(

                    @"

                            function openCourses()

                            {

                               parent.right.document.location.href = 'training/editCourses.aspx';

                            }

                    ");

           }

     

            public override void Render(ref XmlTree tree)

            {

                XmlTreeNode courses = XmlTreeNode.Create(this);

                courses.NodeID = "1";

                courses.Text = "Kurs/Seminarer";

                courses.Action = "javascript:openCourses()";

                courses.Icon = "docPic.gif";

                tree.Add(courses);

     

                //XmlTreeNode calendar = XmlTreeNode.Create(this);

                //calendar.NodeID = "2";

                //calendar.Text = "Kalender";

                //calendar.Action = "javascript:openCalendar()";

                //calendar.Icon = "docPic.gif";

                //tree.Add(calendar);

            }

        }

    }

    I added the new section in umbracoApp and umbracoAppTree. In the UmbracoAppTree the row looks like this:

    False

    True

    0

    training

    eiriktest

    eiriktest

    folder.gif

    folder_o.gif

    EirikTest.CustomTree

    loadTraining

    NULL

    Thank you for your help :-)

     

    Best regards,

    Eirik

     

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 24, 2012 @ 02:22
    Tom Fulton
    0

    Hi,

    This is a known issue, but you can fix it by adding an ID to your nodes before adding them to the tree.  See this post:  http://our.umbraco.org/forum/developers/extending-umbraco/11345-Custom-tree-and-section-Text-duplicate-issue#comment41930

    Hope this helps,
    Tom 

  • Eirik 25 posts 75 karma points
    Apr 24, 2012 @ 07:29
    Eirik
    0

    Thanks for you reply.

    I dont have any ID-property. I have only NodeId. However, I added a unique string to to .NodeID, but still the same result.

                System.Guid uniqueId;

                uniqueId = System.Guid.NewGuid();

                var courses = XmlTreeNode.Create(this);

                courses.NodeID = uniqueId.ToString();

                courses.Text = "Kurs/Seminarer";

                courses.Action = "javascript:openCourses()";

                courses.Icon = "docPic.gif";

                courses.Menu = null;

                tree.Add(courses);

    Also, why doesnt my acutal nodes "Kurs/Seminarer" appear directly under Training, but under EirikTestEirikTest....

    Thanks !

    • Training
      • EiriktestEiriktest
        • Kurs/Seminarer
      • EiriktestEiriktest
  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 24, 2012 @ 14:40
    Tom Fulton
    0

    Hi,

    You should go ahead and add an ID property (in addition to the NodeID) to fix this issue.

    I think the reason it shows under Eriktest is because that your app tree's name.  Are you wanting to load nodes dynamically directly under the root?

    Also if it helps here are a few tutorials.  The first one really helped me.  It's also helpful to look through the built-in trees in the Umbraco source:

    http://www.robertgray.net.au/2011/5/10/creating-a-custom-content-tree-in-umbraco.aspx

    http://www.geckonewmedia.com/blog/2009/8/3/how-to-create-a-custom-section-in-umbraco-4  (this might be older)

    -Tom

  • Eirik 25 posts 75 karma points
    Apr 24, 2012 @ 15:34
    Eirik
    0

    Thanks for your reply Tom,

    but this is exactly what I dont understand. I am just following the example in UmbracoTV, and that example works like a charm. How can I add the ID-property? when I write this statement;  var courses = XmlTreeNode.Create(this); there is a limited set of properties already connected. this example from UmbracoTV works perfectly:

    while(reader.Read())

                {

                    XmlTreeNode xNode = XmlTreeNode.Create(this);

                    xNode.NodeID = reader.GetInt("id").ToString();

                    xNode.Text = reader.GetString("wrongWord");

                    xNode.Icon = "doc3.gif";

                    xNode.Action = "javascript:openCorporateCompliance(" + reader.GetInt("id").ToString() + ")";

                    tree.Add(xNode);

     

                }

    Basically I want one main node and 3 nodes under it. Like this:

    Training

    -> Courses

    -> Locations

    -> Calendar

     

    The courses, locations and calendar will point to ASPX's where I will include all logic. 

     

    Thanks :-)

  • Eirik 25 posts 75 karma points
    Apr 24, 2012 @ 22:37
    Eirik
    0

    Hi again,

    after spending hours of investing this issue, I still dont have a clue about this. I just wanted to add some information to my issue as I am seeking desperately for help. 

    I downloaded the sample project from UmbracoTV, and copied the code from the loadCorporateCompliance.cs file.

    The only difference now between my class and the class form the UmbracoTV-project is the name of the class, project and namespace.

    This is how it looks like in the umbracoAppTree-table in the database:

    from the UmbracoTV-project:

    False True 0 new corporateCompliance corporateCompliance folder.gif folder_o.gif UmbracoTV.CustomTree loadCorporateCompliance NULL

    From my project

    False True 0 training abc abc folder.gif folder_o.gif EirikTest.CustomTree loadTraining NULL

    This is still not working: The result form my class in the admin of Umbraco is:

    Training

    ->AbcAbcAbcAbc

    -> umbracoumbracoumbracoumbraco

    -> denmarkdenmarkdenmarkdenmark

    ->AbcAbcAbcAbc

    ->umbracoumbracoumbracoumbraco

    ->denmarkdenmarkdenmarkdenmark

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 25, 2012 @ 15:19
    Tom Fulton
    0

    Hi Eirik,

    I see what you mean, those posts must be from an old version because the property is NodeID now.

    I took a quick look but I've been unable to reproduce the issue (although I've seen it before...)

    I am wondering if you have some extra entry in your database or code somewhere though, as I'm not sure where the "Training" root node is coming from.  According to your example "Eiriktest" should be the first node.  And I'm not sure why you have two of them (even in your second example) - you should only have one?

    Can you maybe try pasting again any custom records from both tables and your complete code?

    -Tom

  • Eirik 25 posts 75 karma points
    Apr 25, 2012 @ 20:28
    Eirik
    0

    Thank you Tom for following me up :-) I REALLY appreciate it.

    I changed the name of some of the nodes so that might have caused a confusion. 

    I will give you all what you need here. I just wanted to add that I also refreshed the cache several times by changing the web.config and also recompiled to be safe.

    Table:

    umbracoApp

    9 training training.gif Training NULL

    umbracoAppTree

    False True 0 training abc abc folder.gif folder_o.gif EirikTest.CustomTree loadTraining NULL

    The name of the project is EirikTest.CustomTree

    There is one class called loadTraining.cs. The code is there (copy of UmbracoTV-example except the name of the namespace and classname. the table where I am fetching the data from (corporateCompliance) is the same as from the UmbracoTV-example.

    namespace EirikTest.CustomTree

    {

        public class loadTraining : BaseTree

        {

            public loadTraining(string application) :

                base(application) { }

            protected override void CreateRootNode(ref XmlTreeNode rootNode)

            {

                rootNode.Icon = FolderIcon;

                rootNode.OpenIcon = FolderIconOpen;

                rootNode.NodeType = TreeAlias;

                rootNode.NodeID = "init";

            }

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

            {

                Javascript.Append(

                    @"

                            function openCorporateCompliance(id)

                            {

                               parent.right.document.location.href = 'plugins/editCorporateCompliance.aspx?id=' + id;

                            }

                    ");

            }

            public override void Render(ref XmlTree tree)

            {

                IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from corporateCompliance");

                while (reader.Read())

                {

                    XmlTreeNode xNode = XmlTreeNode.Create(this);

                    xNode.NodeID = reader.GetInt("id").ToString();

                    xNode.Text = reader.GetString("wrongWord");

                    xNode.Icon = "doc3.gif";

                    xNode.Action = "javascript:openCorporateCompliance(" + reader.GetInt("id").ToString() + ")";

                    tree.Add(xNode);

                }

            }

        }

    }

    I am also adding the content of the web.config of the EirikTest.CustomTree project.

    <?xml version="1.0"?>

    <configuration>

      <appSettings/>

      <connectionStrings/>

      <system.web>

        <compilation debug="false" targetFramework="4.0"/>

        <authentication mode="Windows"/>

        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>

      </system.web>

    </configuration>

     

    The result from this code in the umbraco admin is included below. If I to another section and back, the Abc and the child nodes adds another value to the string.

    Training

         AbcAbcAbcAbc

             umbracoumbracoumbracoumbraco

             denmarkdenmarkdenmarkdenmark

         AbcAbcAbcAbc

             umbracoumbracoumbracoumbraco

             denmarkdenmarkdenmarkdenmark


Please Sign in or register to post replies

Write your reply to:

Draft