Hi Dynamicweb,
Any chance you could send or publish the source files from the <code></code> attributes below.
Best regards,
Rasmus
Hi Dynamicweb,
Any chance you could send or publish the source files from the <code></code> attributes below.
Best regards,
Rasmus
Hi Rasmus,
You can see the code samples in the API documentation: http://doc.dynamicweb.com/api-docs
Just search for ViewModelBase
Best regards,
Morten
Hi Morten,
Thanks a lot, somehow I didn't realise these files where referenced in the API documentation.
Best regards,
Rasmus
Hi again,
The above works like a charm, so this is just a follow up question.
When Dynamicweb renderes a paragraph using viewModels it will use the ParagraphViewModel and I can't seem to figure out how to make it use my own ViewModel.
From the peeks into the source code I have made, it does not seem to be possible, is this the case?
Best regards,
Rasmus
Hi Rasmus,
That is correct. Replacing the standard view models with your own custom implementation is not supported.
What are you trying to achieve? Maybe there is another solution.
Best regards,
Morten
Hi Morten,
I am trying to prevent magic strings in my templates, it will only take one careless developer before it turns into a runtime error.
Since I am planning to use Code First items, I was hoping to use these as my DataModel and transform that model into a custom ViewModel in a NotificationSubscriber. I would like to move all logic out of my view template and prevent relying on strings to find values.
Best regards,
Rasmus
How about using a custom wrapper in your templates?
Something like this, where CustomModel is your own implementation...
I know it's not exactly what you are looking for, but it does provide some of the same benefits.
Best regards,
Morten
Hi again,
Sure that will work, and I think that is the route we are taking (we have done that previously also).
I was just hoping to be able to pass my own implementation somehow to the template like:
@inherits Dynamicweb.Rendering.ViewModelTemplate<SomeNamespace.CustomModel>
Thanks Morten.
Best regards,
Rasmus
I have made a note about your feature request and will look into it at some point, but I can't promise you anything yet.
Thanks for the feedback.
You must be logged in to post in the forum