[SOLVED] Recommended practice: OOP in Umbraco - ma...
# help-with-umbraco
j
This question is causing me SO much difficulty with wording correctly, so apologies! My starting point is "How do I register objects, with attributes, that then get used by other pages, which aren't accessible as an individual page" - so for example, an Animal object, with attributes like IsFluffy, which I can then assign to Owner pages, and can filter by like "Give me all Owners who have Animals which are fluffy". So I would imagine the way to do this is, in the backoffice, to make an Animal List document type and an Animal document type, then in the Content Section create the Animal List with Animal children, then implement a Content Picker (see 3.) on the Owner to select that Owner's animals, allowing for the appropriate queries. The goal is to be able to create instances of objects (/Document Types) in the back office which can then be used on and by other pages, without themselves being accessible web pages. 1. Is this the correct approach? 2. If I did not want to have an accessible URL path for each of these declarable Animals or Animal List pages, how would I do that? 3. is there a "Multiple Content Picker" editor? Hope this makes sense - just a conceptual issue I'm getting stuck on so would appreciate direction toward the Umbracian way of achieving this. (and yes there's a strong argument for wanting to see the individual Animals, especially the fluffy ones, but let's gloss over that for now please and thank you) TIA!
a
1., sounds good
2. Don't assign them a template, and add a piece of code that prevents adding a URL (my head is foggy, so can't recall how its called, i'll look it up for you) Edit: AH here is is: A NotificationHandler (Basically like, a event listener in javascript) that triggers on when in the backoffice is loaded. You can do somethinge like this:
Copy code
csharp
  public void Handle(SendingContentNotification notification)
    {
        // Hide URL information on nodes without assigned templates
        if (notification.Content.TemplateId == 0)
        {
            notification.Content.Urls = Array.Empty<UrlInfo>();
        }
This hides the normally automaticcally assigned Url in the backoffice as well 🙂
3. There's a MultiNodeTreePicker that should suit your needs, you can even specifiy you can only select Animals
j
OK brilliant, thank you for the clarification!
For clarity, where did you look this up?
a
My own code 😄
Not adding a template solves it for the frontend, but in the backend a URL still shows, and I don't like that ;P