Copied to clipboard

Flag this post as spam?

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


  • Powellze 38 posts 73 karma points
    Jul 22, 2009 @ 10:54
    Powellze
    0

    True/False Data Type allowed to be mandatory or use RegEx?

    I have been trying to work out if its possible to make a 'True/False' data type be mandatory (true state) or specify a regular expression to check the input.

    Please can anyone state if this is possible?

  • Powellze 38 posts 73 karma points
    Jul 24, 2009 @ 15:51
    Powellze
    0

    I have had another look at this and it appears as though you cannot make the data type true/false mandatory or validate against a regular expression.

     

    My problem is I don't want part of my site to appear within the navigation, so I was hoping to use the Hide In Navi property within the document type.

    In the case I want to use this property the true/false requires to be manadatory and true, so that the template the user is editing can not be set live without checking this box.

     

    Any ideas to get around this or another data type that may do what I wish?

    My alternative so far is to use a text field which is mandatory and will not validate without the word true.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 24, 2009 @ 16:00
    Dirk De Grave
    0

    Hi,

     

    "I have had another look at this and it appears as though you cannot make the data type true/false mandatory or validate against a regular expression."

    Sound pretty obvious to me. Checkbox has either a true or false state and both states are valid. Don't think the checkbox is validated against a regular expression anyway.

     

    Best solution I can think of is to capture the Publish event for those docs (might have to filter for some specific docs in the event handler), and cancel the publish action if checkbox is not set.

    If you need some code samples, just check the wiki page

     

    Cheers,

    /Dirk


  • Rick Mather 42 posts 124 karma points
    Jul 24, 2009 @ 16:17
    Rick Mather
    0

    I tend to do something similar on my projects, as there are always doctypes that I don't want to either a) be visible in the navigation by default, or b) ever show up in the navigation (e.g. "settings" pages). I usually do the following:

    * Hook into the publish event and change the 'umbracoNaviHide' property to true for doctypes that should never be in the navigation. This ensures that whatever value the user selects will be overridden.

    * Hook into the new event and change the 'umbracoNaviHide' property to true for pages that shouldn't be in the navigation by default (e.g. news articles of which there can be a lot). This helps keep the sitemap nice and tidy but still allows users to put the pages back into the navigation if they want to.

    Maybe one or both of these options will work for you.

  • Bert 128 posts 251 karma points
    Jul 24, 2009 @ 16:40
    Bert
    0

    addapt your xstl to check on both the navihide property and the document type? Or is that not possible?

    That way you bother the editors less.

  • Powellze 38 posts 73 karma points
    Jul 24, 2009 @ 18:14
    Powellze
    0

    Hi Dirk & Rick & Bert,

    I appreciate the time you have all spent thinking about this and I want to thank you all for your solutions you have put forward. I think there are two good plans of action for me to try out of these. I will get back to you all on monday and let you know how it goes.

  • Powellze 38 posts 73 karma points
    Jul 27, 2009 @ 17:50
    Powellze
    0

    OK, having thought about this some more I have come to the conclusion that I am still unhappy with the soltuions.

     

    Here is some background to my issue:

    I have a Downloads Section, which has many Downloads Folder, which has many Downloads File.

    So think of it like this the 'download section' contains 'categories' which contains 'files'.

    The Download section has a template, the folder and file don't. The download section page shows categories and the files for the categories, the user should only be able to access the files and not the folder for its list of files.

     

    Due to this, I have assumed that I am unable to tie into the create/publish event as I will not have access to a c# script block/code behind.

    This leaves me with one last solution which I am not to keen on, this is to exclude the download folders at any section I dont want the folders/files to be seen and perform this for other sections I have created like video's/news.

     

    I have been thinking about creating an empty template for the downloads folder and hooking into the new/published events.

    Any more ideas if this would be ok and please could you point me in the right direction event wise?

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jul 27, 2009 @ 18:23
    Sebastiaan Janssen
    0

    Have a look at this DataType that is True by default. Put this datatype on a documentType (alias: umbracoNaviHide) and all the documents of that type will not appear in the tree by default. The user is still allowed to uncheck this though.

     

  • Rick Mather 42 posts 124 karma points
    Jul 27, 2009 @ 22:49
    Rick Mather
    1

    You don't need to have templates for your categories / files in order to add events. Your custom events should ideally go into a class-library which gets compiled / copied into your sites bin directory, where they'll automatically get picked up by Umbraco.

    This wiki page has some cool examples. You should be able to adapt one of the 'before publish' examples to auto-hide pages with specific aliases.

     

  • Powellze 38 posts 73 karma points
    Jul 28, 2009 @ 12:56
    Powellze
    0

    I want to thank everyone for there help in the solution.

    I tried the datatype default but couldn't quite get what I wanted so I have used the solution suggested as to hook into the Document_BeforePublish event.

    Here is the code incase anyone comes across this in the future:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using umbraco.cms.businesslogic.web;
    using umbraco.BusinessLogic;

    namespace (Namespace removed for client) {
    public class AutoHideDownloads : ApplicationBase {

    public AutoHideDownloads() {
    Document.BeforePublish += new Document.PublishEventHandler(Document_BeforePublish);
    }

    public void Document_BeforePublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e) {

    Log.Add(LogTypes.Custom, 0, "Document_BeforePublish Executed in AutoHideDownloads");
    //Only applies for news
    if (sender.ContentType.Alias == "BS_DownloadsFolder") {
    sender.getProperty("umbracoNaviHide").Value = 1;
    sender.Save();
    }
    }
    }
    }

    As a note you must reference these dll's from the umbraco bin directory for your solution:

    businesslogic.dll
    cms.dll
    interfaces.dll

     

    Rick, I have one last question if you could answer this then I think I am 100% happy with the solution. The umbracoNaviHide is updated but only after I reload the content from the editors navigation. Is it possible to set this umbracoHideNavi true event to show after the postback event has completed? Or could I remove the hide in navigation within the document type?

Please Sign in or register to post replies

Write your reply to:

Draft