Copied to clipboard

Flag this post as spam?

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


  • Peter Schermers 112 posts 134 karma points
    Apr 19, 2012 @ 16:23
    Peter Schermers
    0

    How do I allow a child node just once (newbie)?

    It's probably a very basic question (though I have spent this entire day searching for a solution online, but found nothing :-( 

    I understood that the best structure for a website in Umbraco is to create a root called 'Home', and to put all other pages like 'Services', 'About us' and 'Contact us' below it (as child nodes).

    I have designed a special Contact Us page in HTML, which - of course - is different from a regular Textpage. The idea was to put this irregular page under the Home node to be displayed in the navigation bar (and to create a page for it). Okay, no problems at this point.

    But the next step I want to make is to disable users to create a Contact Us page for themselves. So I unchecked 'Contact Us' as an allowed child node in the Structure tab. But then it also dissapears from the navigation! :-( 

    What should I do to solve this?

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

    Hi,

    There isn't really a way to limit a document type to only be created once, which is what I think you are asking.

    One workaround as you say, is to go ahead and create the Contact Us page, then disable it as an allowed child from the Structure tab.  Your Contact Us page will still exist, but users won't be able to create any new one.  Note this also means if it's deleted, users won't be able to re-create it or move it back from the recycle bin, an admin will need to enable the type again and recreate/move it.

    I think you said you tried this but the node disappeared from the navigation?  That should not happen so I'm thinking something else must have been at fault.

    I've been thinking about adding support for "doctype can be created x times" in the Structure Extensions package but haven't gotten around to it yet.

    HTH,
    Tom 

  • Peter Schermers 112 posts 134 karma points
    Apr 19, 2012 @ 16:39
    Peter Schermers
    0

    Hi Tom,

    Thanks for your quick answer! Ehm... I know I am just a newbie here, but how does everyone else then make Contact Us pages? To be honest, I am truly amazed that there is no real solution for it, and that I have to use a workaround (for which I am thankful, no offense!).

    If I may be so clear: how would you create a page as Contact Us? Or do you always enable users to create more Contact Us pages?

     

    peter

  • Peter Schermers 112 posts 134 karma points
    Apr 19, 2012 @ 16:43
    Peter Schermers
    0

    Hi Tom,

    It's just amazing. Yesterday I thought of the same workaround you just gave me, and my whole Umbraco went crazy (luckily, I could fix it pretty fast). I just tried it again and all of a sudden it just works! Thank you so much for pointing it out to me! Though I still don't understand why I have to use a workaround for such a common (?) request, I am truly thankful to you! :-)

    peter

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

    Are you having trouble creating the actual page?  Or are you just wondering how to prevent your users from making multiple Contact Us pages?

    If the first, you'll most likely want to create a special Document Type called Contact Us that uses it's own template, and enable that to be created as a child of the homepage (or wherever).

    If the latter, again you can't really prevent them from creating multiple instances OOTB.  Usually if I have a document type that should only be created once, I note that in the document type's description, so when they select it in the Create dialog it will say something like "Contact Us page - a textpage with a contact form.  This page should only be created once".

    Maybe I am misunderstanding though, are you really that worried that your users might create a bunch of Contact pages? :)

    -Tom

  • Peter Schermers 112 posts 134 karma points
    Apr 19, 2012 @ 16:48
    Peter Schermers
    0

    I had no problems creating the page, it was just that I - indeed - wanted to disable users to create more than one Contact Us page. You see, I am not a true developer since I am foremost a usability / multimedia designer, so these things are often important to me. ;-) But thanks anyway!

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

    Gotcha.  It's not an outlandish request, I've had a similar requirement in an older project where each "section" needed to have a "quiz" document type but could only have one.  I ended up adjusting my macro to only read the first one in case there were multiple.  It also gave me the idea to add that as a feature to Structure Extensions but I just haven't had time yet.  For now I always add "This should only be created once" to the description :)  Glad it's working for you with the workaround though.

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Apr 19, 2012 @ 17:15
    Thomas Höhler
    0

    The easiest was is to implement a New EventHandler, check if the node is created before and cancel the event, take a look at the events wiki:

    http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events

    http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/overview-of-all-events

    hth, Thomas

Please Sign in or register to post replies

Write your reply to:

Draft