Copied to clipboard

Flag this post as spam?

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


  • Eugen 30 posts 131 karma points
    Oct 22, 2018 @ 08:05
    Eugen
    0

    Dynamically adding text to View

    Hi guys, i'm new in Umbraco CMS.I need to create a plugin that adds a user section to the backoffice. In this section there is a text field "code" and a save button. When the "code" is installed, when rendering any page, before closing the tag, a certain JS code is inserted, in which the "code" that we saved earlier takes a certain place. How can I do it?

    Thx for the help friends!

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 22, 2018 @ 08:21
    Michaël Vanbrabandt
    1

    Hi Eugen,

    First, Welcome to the Umbraco Community!

    Can you give some more details because its not totally clear about what your goal is.

    You mention, a plugin that adds a user section to the backoffice, do you mean a section like Content, Media, ... which already existst in the backoffice? Or do you mean something else with section? Also a Users section already exists.

    From what I understand you need to create a new Property in your Document Type which you place on the root node ( Home node ).

    Then in your views you can call this property like:

    Model.Content.GetPropertyValue<string>("myCodeAlias", recursive: true)
    

    This will look up the node structure and find a property called myCodeAlias.

    Then using this line, you can get the code and add it into your script.

    Hope this helps.

    /Michaël

  • Eugen 30 posts 131 karma points
    Oct 22, 2018 @ 08:30
    Eugen
    0

    Thanks for the quick reply Michaël! Custom section - I mean the new section under the "Forms" section. I think it is called "Tree"? In that column in which there are sections "Content", "Media" etc. And new section must have a dashboard which contains textfield "Code" and button "Save". It is necessary for each page, when rendering, add one JS code where a value from the "Code" textbox is inserted into a specific place. Even if the page is already added after installing the plugin.

    Thank you very much for the help!

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 22, 2018 @ 08:40
    Michaël Vanbrabandt
    1

    Hi Eugen,

    is it neccesary for creating a complete new section only for one textfield?

    Can you have a look at the solution I provided from my previous post? It does exactly what you want and you don't have to create a new section for it.

    Also this will be rendered on each page because the Code value is located on your Home root node and using the recursive search each page under Home can access this.

    Hope this helps.

    /Michaël

  • Eugen 30 posts 131 karma points
    Oct 22, 2018 @ 08:49
    Eugen
    0

    Dear Michaël. I'm afraid this is a customer requirement :( I need to write a plugin that should be easily portable between projects. In the section that creates the plug-in, the “Code” is entered and saved, and the specified actions are performed for all pages, not just for the home page.

    Thank you for your patience and help my friend. If it does not make it difficult, I need more detailed instructions on how to do this. I study Umbraco for only 2 days :(

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 22, 2018 @ 08:59
    Michaël Vanbrabandt
    1

    Hi Eugen,

    no problem.

    You can find detailed information on creating custom sections, trees and dashboard in de Documentation:

    https://our.umbraco.com/documentation/Extending/Section-Trees/

    https://our.umbraco.com/documentation/Extending/Dashboards/

    Hope this helps!

    /Michaël

  • Eugen 30 posts 131 karma points
    Oct 22, 2018 @ 09:02
    Eugen
    0

    One more question...How can i do it using plugins?)

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 22, 2018 @ 09:11
    Michaël Vanbrabandt
    1

    Hi Eugen,

    an exampel of doing this can be found here in this blogpost:

    https://24days.in/umbraco-cms/2017/similar-solutions-different-approaches/

    Hope this helps!

    /Michaël

  • Eugen 30 posts 131 karma points
    Oct 22, 2018 @ 11:07
    Eugen
    0

    Dear Michaël,

    I am now creating a plugin and in the tab "Package Actions" I want to add a new section with the contents as I described above.

    I found examples on https://our.umbraco.com/documentation/Reference/Packaging/ . But I can't adapt it to my needs. I need to create a new section with a text field and a button as we discussed before. Сan you help me with this?

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 22, 2018 @ 11:11
    Michaël Vanbrabandt
    1

    Hi Eugen,

    found another post with more in depth details from adding a new section untill displaying content:

    https://skrift.io/articles/archive/sections-and-trees-in-umbraco-7/

    Hope this helps!

    /Michaël

  • Eugen 30 posts 131 karma points
    Oct 22, 2018 @ 11:21
    Eugen
    0

    Dear Michaël, I read this article, but it does not indicate what I need. I need to perform actions similar to what is stated in the article, but only with the help of the plugin I want to create. I determined that I can achieve this by specifying the correct code in the "Package Actions" section, but I do not know how to write the code there in order to achieve what I need.

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 22, 2018 @ 11:37
    Michaël Vanbrabandt
    100

    Hi Eugen,

    then have a look at my plugin which I have created which also uses a custom section with Package Actions.

    https://github.com/Mivaweb/Notely/blob/master/src/Notely/Notely.Core/Install/PackageActions.cs

    The package actions is used to add, edit or remove things during install/uninstall of your package.

    In my plugin I edit the config xml files which contains the details about sections and dashboards so I can add my custom section.

    Hope this helps!

    /Michaël

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 22, 2018 @ 11:40
    Michaël Vanbrabandt
    1

    And then in the following directory you can find 2 classes which creates the section and trees in the backoffice:

    https://github.com/Mivaweb/Notely/tree/master/src/Notely/Notely.Web/Trees

    /Michaël

  • Eugen 30 posts 131 karma points
    Oct 22, 2018 @ 11:47
    Eugen
    0

    Oh Michael, i feel very stupid. Why the plugin that you create contains .cs files? I followed the umbraca documentation and tried to create plugins. But my plugin is an archive which contains the xml file. What am I doing wrong ? and how can I post events on the content (I mean the button in my expected dashboard)?

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 22, 2018 @ 11:52
    Michaël Vanbrabandt
    1

    Ok now I am lost...

    I think the first step you need to do is making it work by hand, so forget the Package Actions and all that stuff, first try to make your plugin work.

    1. Create a new section
    2. Create a new tree
    3. Create your plugin in the App_Plugins folder
    4. Add you view which contains the textbox and button
    5. Add angular js controller to add a click event and do someting with the value of your textbox
    6. If it all works you can go and start making a package of it to install it on other umbraco installations.

    Hope this helps!

    /Michaël

  • Eugen 30 posts 131 karma points
    Oct 22, 2018 @ 15:10
    Eugen
    1

    Dear Michaël, you really helped me. I finally understood what a full-fledged plugin for Umbraco consists of. And understood a lot of your work with Git. I created a plugin that creates custom section. I will continue to work on the content.

    Thx you

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 22, 2018 @ 17:22
    Michaël Vanbrabandt
    1

    Eugen,

    no problem, I am glad I could help you out! Keep up reading the docs and don't hesitate to ask questions on the forum.

    We are here to help you out!

    Have a nice evening!

    /Michaël

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 23, 2018 @ 11:44
    Michaël Vanbrabandt
    1

    Hi Eugen,

    don't forget to mark the solution for this thread.

    Thanks!

    Have a nice day

    /Michaël

Please Sign in or register to post replies

Write your reply to:

Draft