Developer forum

Forum » Swift » Generated files?

Generated files?

Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Hi,

After setting up a fresh copy of Swift, and adding it to one of my own repositories, I'm confronted with the fact that a lot of new files are added after first run.

I have been trying to figure out where they come from and if I should want them in Git, but I cannot really get my head around what is happening.

I do notice this list seem specifically bound to some Apps. But where are the sources of these files. and can I just safely add them to .gitignore, seeing they are not an integral part of Swift apparantly?

Here is part of the list.  

Thanks,

Justin


Replies

 
Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Wrinting the post already helped my own thoughts a bit :-)

Apparantly they are added through an update mechanism in : Application(9.14.1)\Admin\Update\Files\Templates

Stil wondering if I should just add Templates\* in .gitignore and Whitelist everything from Swift. 

Or is something else wrong with my setup, and should this not happen at all?

Anyone who can shine some light on this?

Justin

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

You probably just ran an update from 0 - and get copies of all templates from main install form since break of dawn.

And then - they should not be in your Swift design folder - they would normally be in your /Templates folder directly - so something funny you must have done.... :-)

Votes for this answer: 1
 
Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Circling back to this one :-)

The added directories are indeed not in the Swift design folder, but they are in the Templates folder. That seems to be the normal case, as I have seen that for a lot of sulutions.

Now a lot of these folder I can just add to .gitignore, because they will also show up on my local dev solution, and I do not want them in git. (do i?) (maybe it could be an idea that the swift .gitignore does all of that ootb also? for me it was very confusing that after running Swift for the first time on a clean dev solution, I had to add a lot of stuff to .gitignore) 

but What about the eCom and eCom7 folder? Swift contains some files in these folder, but after running DW a lot more is in these folders, So I'm a bit stuck in the sense that I would want the Swift files in git, but do'nt want the rest?

Ofcourse it could also still be that I'm totally missing some important point here :-)

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Justin,

 

The folders outside of "Design", such as eCom7 with the Shipping Providers are needed, because when you select the templates in Payment (and some Shipping) Providers, they are de-contextualized, meaning, not withing the context of a website. Another example is the email template for "Send User Details" in the User card.

 

As it turns out, when that object (payment/shipping/...) is rendered, it is rendered within a certain context and when that happens, if there is a template with the same name within that Design folder, it is used instead.

 

That is why certain files exist outside of the Designs folder, but they are empty, and you'll find an exact match within the Swift folder hierarchy, containing all of the code.

 

Hope this helps shed some light.

 

Best Regards,

Nuno Aguiar

 
Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Hey Nuno,

Thanks very much! This definitly shines some light on my confusion, but (as often is the case) also raises some follow-up questions :-)

  • How do other developers setup the local environment, am I doing anything out of the ordinary, or is everyone adding these folders to git and makes them part of deployment? Or alternatively we are all changing the gitignore file? (I'm using a setup with te Swift Files folder as a virtual folder as described here:https://doc.dynamicweb.com/get-started/introduction/installation/installing-a-pre-existing-solution)
  • Does this mean that for example the templates in /Templates/Designs/Swift/eCom7/CheckoutHandler are inline checkout forms? and is the list of these out of date in the docoumentation here: https://doc.dynamicweb.com/documentation-9/ecommerce/payment/payment-methods#sideNavTitle1-5-1
  • Is it then correct that the template lowest in the hierarchie wins, so if for exmample i want to ovveride the /Templates/Forms/Mail/DefaultMail.cshtml i should create my own version of that in /Templates/Designs/Swift/Forms/Mail
  • Altough I think I get the "de-contextualized" concept I think, I'm confused about what it really means. For example, related to the previous point, in Default.cshtml there is code that is dependent on the context of the mail that is being sent within the DynamicWeb contex, so for example this line will only work in context? Form submitted @submitDate.ToString(Dynamicweb.Core.Helpers.DateHelper.DateFormatString) @emailFieldName

Thanks again!

Justin

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

I can explain the decontextualized.

When you are on a page in the backend and edit i.e. a page or a pragraph, it knows what website you are on. A website uses a design - i.e. Swift. So based on that information when you need to select a template, Dynamicweb can figure out that you might want to use a template from the Swift design.

When you are setting up things under settings - i.e. a shipping method or payment method - you do not edit those in the context of a website. So we have no clue if you will use a template from Swift or from another design from another website. So there is no "design context" when choosing the template there.

So you have to choose a template that is "out of context" - which means from /Files/Templates/eCom7/Checkout/* or similar.

Then when that payment method is used - on a checkout setup on a paragraph which is on a page which is on a website that uses the Swift design, it will first check if a template with the same name exists in the context of the design - /Files/Templates/designs/swift/eCom7/Checkout/* - and use that if it exist or fallback to the one you chose.

Not super simple - I agree - but how it works.

So all kinds of templates you can choose from places that are not in a website context, and hence not in a design context, needs templates in these locations.

All of this complexity stems from the fact that designs and layout is a relatively new implementation model - about 13 years old - and we still have support for the implementation models before that. Because as we discussed earlier - we always want and need to update all customers 4eva...

Votes for this answer: 1
 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply
This post has been marked as an answer

Hi Justin,

 

  • How do other developers setup the local environment (...)
    I can't speak for all of the files you are seeing, but using the example of the Payment providers again, In my opinion, you should commit the files to git anyway, because the files, even if empty, are meant to be empty and used.

     
  • Does this mean that (...) the templates (...) out of date in the docoumentation
    No. That documentation is HOW Dynamicweb works with Payment Providers. Then in another part of the documentation you can learn about templating works https://doc.dynamicweb.com/template-tags/introduction/concept/templates.
    Then you have Swift, which is a Design https://doc.dynamicweb.com/template-tags/introduction/concept/designs. Basically it's an implementation on the Dynamicweb platform. And Swift is using Payment Providers, but levering the templating capabilities to keep the templates files and design consistent.
     
  • Is it then correct that the template lowest in the hierarchie wins
    Yes, and there's actually 4 hiererarchies to it. Going botom up, the hierarchy is
  • Altough I think I get the "de-contextualized" concept I think, I'm confused about what it really means.
    If a context dependent request (C# method or template tag or logic) and it's used on a de-contextualized setting, you'll run into issues (tags might return empty - c# methods will likely throw an "object not set to an instance of an object" exception)
    Consider the order confirmation template:
    • If you apply it to the app settings on the checkout paragraph, then when the order is complete, there's context - we know which paragraph it is, hence the page, hence the area.
    • If you apply the same file to order state notifications and you go to Ecommerce and change the order to that particular state, then there's no pageview (no page, no area, no nothing). You could have 20 websites in the backend, which one to choose? You could argue the order had been placed on a particular page, but what if the page no longer exists? The template what works correclty in the previous bullet, no longer works here.

 

Hope this makes sense.

 

Nuno Aguiar

Votes for this answer: 1

 

You must be logged in to post in the forum