Copied to clipboard

Flag this post as spam?

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


  • Travis Schoening 47 posts 173 karma points
    May 06, 2021 @ 13:59
    Travis Schoening
    0

    Using full ModelsBuilder package instead of embedded (Can the embedded modelsbuilder be disabled?)

    Per the note under the "installation" section on https://our.umbraco.com/documentation/reference/templating/modelsbuilder/introduction

    I have a version that I've compiled and would like to use (to enable the use of a base class). I can add this reference fine in VS and it works some of the time.

    However, a couple of issues

    1) This creates to "Models Builder" tabs in the "Settings" section (which seem to always display the same thing on both 2) At times (again, regardless of what tab you're on) , it varies between the compiled version 8.1.6 and the embedded 8.13.0. When it comes up with 8.13.0, I'm not able to implement my base model class, and it seems the only reliable way to get 8.1.6 back is to close out of VS and run again.

    Does anyone know if there Is there a way to disable the embedded modelsbuilder which hopefully would fix this issue?

    Thanks!

  • Travis Schoening 47 posts 173 karma points
    May 06, 2021 @ 14:05
    Travis Schoening
    1

    What is it about working on something for the better part of a day and not getting anything to work, only to have that "voila" moment right after asking for help on an online forum? ha.

    Anyways, I believe I may have found the answer I needed, so if anyone ever has the same issue, take a look at https://github.com/umbraco/Umbraco-CMS/issues/10186#issuecomment-827600160

  • Patrick van Kemenade 101 posts 339 karma points
    May 07, 2021 @ 17:55
    Patrick van Kemenade
    0

    Not sure if I understand the use case for keeping the (old) Models Builder instead of the embedded version. You mention that you want to use a base class.

    Maybe this is an alternative. Suppose you have a Volvo, Ford and Audi, they are all cars with distinct properties but all share a base class Car.

    And in the code you want to loop over every Car you have and use it's base functionality.

    A way to do this is to create a composite type Car. And then use this in Volvo, Audi, Ford. When the classes are generated (using embedded) you'll notice that each of then implements ICar.

    Furthermore since there all partials you can extend the behavior in a seperate class file.

    Not sure what your specific scenario is, but could this be an alternative ?

  • Travis Schoening 47 posts 173 karma points
    May 07, 2021 @ 18:01
    Travis Schoening
    0

    Hi Patrick,

    Appreciate the response! I think your solution would work for some scenarios for sure, so appreciate you responding.

    A lot of what I'm trying to implement with a base class is tied also to a custom viewpage. (Properties like a theme and other layouts to use, obtaining the root note, and some helper methods and it just seemed the base model works best.

    As I mentioned, the link to the GitHub comment I included was what I needed to prevent the hiccups with the models builder version.

    In my particular scenario, it seems everything is working now!

    Thanks again!

  • Patrick van Kemenade 101 posts 339 karma points
    May 07, 2021 @ 18:13
    Patrick van Kemenade
    0

    That kind of the same thing I use composites for. So in in the generates class I end up with a DocumentType having multiple different interfaces, so even if I have something like a backgroundimage which is just 1 field I make a composite for it. And use it in all DocumentTypes have a backgroundimage.

    And in my (Master) View I can then do things like:

            if(Model is IBackgroundBannerImage){ ... }
            if(Model is ICar){ ... }
            if(Model is ISeoFields){ ... }
    

    etc. and then call partials and stuff. So my master views can then handle a lot of stuff for all my different DocumentTypes.

    Anyway just for anyone reading who is doubting to use the separate package or the embedded one.

Please Sign in or register to post replies

Write your reply to:

Draft