https://discord.umbraco.com
Join Discord
✅ Returning a view with a custom model / adding fields to models
j

jacksorjacksor (Richard Jackson)

about 2 years ago
Happy Saturday / God lørdag! Goal: add custom properties to a ModelsBuilder-created model which can be defined and calculated by a controller and then passed into a View (first image). Purpose is to remove logic from View and move to Controller. Following [this](https://docs.umbraco.com/umbraco-cms/v/10.latest-lts/reference/routing/custom-controllers#returning-a-view-with-a-custom-model) part of the docs I was largely successful in defining the ViewModel and Controller which "extended" the Home Model, but when I passed the ViewModel into the View I "lost access" to the original Home Model fields in a strongly-typed manner i.e. no longer intellisensable. The docs seem to say that I'd need to access the original Home Model's fields using syntax such as
Model.Value<IHtmlString>("productDescription"))
rather than
Model.productDescription
(second image) which isn't ideal. Could anyone advise me on this? I've included
HomeViewModel.cs
,
HomeController.cs
and
home.cshtml
for transparency of my current approach. Greatly appreciate any input.
homecontrollerhomeviewmodelhome
j
d
  • 2
  • 5
  • 23
How to get hold of the crop when using local crops?
c

Craig100

8 months ago
V13.6.0 Using Slimsy I need to put the crop name in. But, I don't know what it is because this image picker is using local crops and the editor can choose from a few. So, how do you get hold of the selected crop name?
@if (Model.Content.BannerImage is MediaWithCrops theImage && !isBackoffice) {
<slimsy-picture media-item="@theImage" css-class="lazyload img-fluid" crop-alias="@theImage.LocalCrops.GetCrop("????????")" render-lqip="true" alt-text="@Model.Content.Title" size="auto"></slimsy-picture>
}
Thanks
c
d
m
  • 3
  • 12
  • 22
Rich text Editor content disappears
m

Marian

9 months ago
Hello there, We use Umbraco ver. 7.12.3 on legacy website. We have the following problem which happens time to time: The "Rich text Editor" property content sometimes fully disappears after saving (I see in cmsPropertyData table in DB that its dataNtext field contains empty string for such versions). And we do not think it's due to accidental cleanup, because it happened at least for second time for last a few months. As I can see, content is always restorable, so it isn't very critical for now. But we need to know possible causes and, if it's possible to resolve this issue easy - to resolve it. Updating Umbraco isn't an option for us - as that legacy website is on support only, and soon will be switched off. So we want to fix it being on Umbraco 7 (preferrable on 7.12.3). Thanks for advise.
m
j
  • 2
  • 1
  • 22
Migrate e-commerce site currently on WP WooCommerce
f

Florent Grandjean

10 months ago
I have to make an offer to migrate a WooCommerce site. What easy solution (without huge recurring licence cost unlike Commerce) would you recommend today to implement for a small/medium e-commerce site V13min. for the german market ? Thanks for your tips 🙏
f
y
r
  • 3
  • 4
  • 22
Possible to use UFM with blocklist in Umbraco 13?
t

TigerMan

11 months ago
Hi I have a blocklist in Umbraco 13. I would like to use my controls value (picker) so when they save they can see the value without having to open up the item in the list. I'm using something like {{fieldName}} Which brings back the guid but not the value. I've tried various ways to get the value but nothing works. I've read the documentation but it focuses on Umbraco 14+ Am I missing a simple syntax somewhere?
t
j
  • 2
  • 1
  • 22
Umbraco.Commerce.Checkout Confirmation email smtp settings
h

hollystyles

about 1 year ago
Hi I am having trouble with confirmation emails not arriving. It works locally in development with :
"Smtp": {
  "From": "noreply-DEV@devdomain.tld",
  "DeliveryMethod": "SpecifiedPickupDirectory",
  "PickupDirectoryLocation": "C:\\DEV\\Emails"
}
But on server with
"Smtp": {
  "From": "noreply-TEST@stagingdomain.tld",
  "DeliveryMethod": "Network",
  "Host": "192.168.101.233"
}
Nothing seems to happen. I am looking in back-office -> Settings -> log viewer but I can't see any errors or warnings. What should I look for if I suspect there is an smtp issue? I have checked that the confirmation email template is selected for the store and the path is correct.
h
s
  • 2
  • 5
  • 22
JS and CSS bundled and served as needed in a Block List heavy site.
s

SiempreSteve

about 1 year ago
I feel like I've been dancing around this problem for too long and I'm missing something very obvious. Site has 100s of page each with a varying number of picked block list modules / blocks. Some of these have third party libraries, chunky amounts of js and or css that is required - think sliders, video blocks, popups etc etc - some pages have multiple sliders etc. Traditionally I'd stick output all the required css and js in minified bundles, built out in gulp, and move on with my life. However Google Lighthouse likes to tell me (as do the SEO audits) that my bloated bundles have lots of unused css and js on each page (which of course, they do!). I've just been playing with Vite and it looked promising but I can't see how I could have a dynamic bundle / dynamically load components (or whatever) to cover the above use case. So how does everyone in 2024 cover the above? Code splitting with bundle goodness and dynamic - happy Lighthouse whilst not having 20-30 included css and js files conditionally included?
s
s
+3
  • 5
  • 25
  • 22
Access IpublishedContent on Background task.
n

nl_05

about 1 year ago
Anyone here have tried accessing page url inside the background task ? I tried this code but no luck . Anyone can help me what approach should I need to do here ? Thanks in advance > public IPublishedContent GetPage(int id) > { > using (var cref = _umbracoContextFactory.EnsureUmbracoContext()) > { > var cache = cref.UmbracoContext.Content; > return cache.GetById(id); > } > }
n
s
m
  • 3
  • 2
  • 22
uSync to sync changes
t

TigerMan

about 1 year ago
Hi I'm trying uSync and have come across the following scenario: PC 1: created a document type with some fields. Push this code into the repository. PC 2: pulled the latest changes and run an import. The document type isn't there. I do a full import and the document type isn't there. Is there a way to ensure this doesn't happen? I think I can export but what if this step is forgotten?
t
b
k
  • 3
  • 6
  • 22
Add data-attributes to table cells in RTE
j

Jeroen Visschers (iO)

about 1 year ago
Hi all, To make tables more responsive I want to add some data-attributes to the cells, that are equal to the
th
in the table. This way, I can make cards instead of rows on mobile, using this data-attributes in css. (see [this example](https://codepen.io/AllThingsSmitty/pen/MyqmdM) ) Is there a way to intercept the rendering part of RTE and add my own logic to it, so I can add the data-attributes automatically? I don't want the content editor to have to worry about this, and make mistakes in the code.
j
h
s
  • 3
  • 16
  • 22
Previous848586Next

Umbraco

A hub and casual space for you to interact with fellow community members and learn more about Umbraco!

Powered by