Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 12 01:41

    jtkech on patch-1

    (compare)

  • Apr 12 01:39

    jtkech on patch-1

    Update ZoneShapes.cs (compare)

Richard Garside
@NogginBox
I've asked a question on GitHub discussion about exporting content from Orchard Framework into Orchard Core. I think I've seen others ask the question in here, but stuff gets lost in here so I thought a question on Github was more likely to remain a useful resource:
https://github.com/OrchardCMS/OrchardCore/discussions/7780
BJury
@BJury
How do you query for a localised version of content? I have this to fetch the content items, but I need to match the localisation to the current locale.
var i = await Session.Query<ContentItem>()
        .With<ContentItemIndex>(c => c.ContentType == "ReportHeading" && c.Published && c.Latest).ListAsync();
This message was deleted
5 replies
Seth Cleaver
@scleaver
Hi Steven... I think that works because you decorate your controller with the cors attribute but in my case this is an ordinary OC page so I can’t add an attribute. I have tried the cors module but that doesn’t work either
2 replies
Zoltán Lehóczky
@Piedone
It took a tiny bit longer than anticipated but our new Orchard Core tutorial series will premiere on the 1st :). So if you're new to Orchard check it out here: https://www.youtube.com/watch?v=aSNRH-BDAdY
2 replies
CrestApps
@CrestApps

I have a controller that creates a shape like this

public async Task<IActionResult> Display()
{
    Location location = new Location()
    {
        Name = "Test 1",
    }

    IShape shape = await _displayManager.BuildDisplayAsync(location, this);

    return View(shape);
}

Here is how my location driver looks like LocationDisplayDriver

public class LocationDisplayDriver : DisplayDriver<Location>
{

    public override IDisplayResult Display(Location model, IUpdateModel updater)
    {
        return Initialize<DisplayLocationViewModel>(nameof(DisplayLocationViewModel), viewModel =>
        {
            viewModel.Id = model.Id;
            viewModel.Name = model.Name;
        }).Location("Content");
    }
}

I created a view called ~/Views/DisplayLocationViewModel.cshtml while the Locations/Display.cshtml view has @await DisplayAsync(Model)

But when I try to render the shape using @await DisplayAsync(Model) I get this error

Exception: Shape type 'Location' not found

I am expecting the shape to be rendered using ~/Views/DisplayLocationViewModel.cshtml view. What am I missing here that is causing this error?

CrestApps
@CrestApps
In my mind, Initialize<DisplayLocationViewModel>(nameof(DisplayLocationViewModel), viewModel => the first parameter is setting the type or the viewName to be used
Zoltán Lehóczky
@Piedone
This is because it tries to find the Location.cshtml (or .liquid, for example) shape, the wrapper for the object. If it would be a content item then it'd look for Content.cshtml.
CrestApps
@CrestApps
@Piedone isn't nameof(DisplayLocationViewModel) setting the view name?
Zoltán Lehóczky
@Piedone
That's also setting a shape name, yes, but that's another one, just for the shape created in the driver. This is a composition of two shapes: one wrapper, then the children from the drivers (or possibly more). You can also have more drivers with more shapes.
When you have to show code it's better to open a discussion instead of the chat next time :).
CrestApps
@CrestApps
@Piedone got it. Since I don't have location.cshtml, is there a way to render this DisplayLocationViewModelwithout having to create Location.cshtml? I already have display.cshtml
CrestApps
@CrestApps
Also when I Added the Location.cshtml, I am running into a infinite condition of some sort. The view Location.cshtml keeps on getting called. I put @await DisplayAsync(Model) in it.
Zoltán Lehóczky
@Piedone
I don't think so. The whole point of using shapes and drivers like this is to have a multi-layer, flexible system that is extensible from multiple classes or even modules (multiple modules could contribute to displaying a Location). If you're looking for something simpler then perhaps you want to use ad-hoc shapes? https://github.com/Lombiq/Orchard-Training-Demo-Module/blob/6f9e00ade204dbcd5d6b941707b61c35e8979897/Controllers/DisplayManagementController.cs#L30
CrestApps
@CrestApps
@Piedone thank you. my location needed DisplayAsync(Model.Content) instead of DisplayAsync(Model) which displayed it
Zoltán Lehóczky
@Piedone
Yeah, for the stack overflow that'll be it :). For your prior question see my reply.
CrestApps
@CrestApps
In the Display.html, if I change DisplayAsync(Model) to DisplayAsync(Model.Content) that avoids the Location.cshtml altogether. Is this not a recommended approach?
Zoltán Lehóczky
@Piedone
Usually not. There what you're doing is that instead of displaying a whole item shape (i.e. the shape of the Location) you're just displaying one local zone of it (Content). This removes the point of using local zones :).
I encourage you to look through the display management tutorial I linked. Because my hunch is that you're slightly overcomplicating compared to what you really need. The approach you've taken is suitable if you want the full-fledged display management like it is for content items. Judging from the simplifications you've made this is not really something you'd benefit from; thus, probably ad-hoc shapes are a better choice. These can also have a C# "code behind": Take a look at shape methods (search for [Shape] in the OC codebase) or writing an IShapeDisplayEvents implementation.
CrestApps
@CrestApps
@Piedone I agree with you. I feel that adding a DisplayManager/Driver is an over kill. I am just not sure how to display my object correctly. in a standard .NET MVC app, I would get the model from my repository, map it to a ViewModel, pass that ViewModel to the view for directly rendering. I kinda want to replicate the same thing in the CMS. I pulled my Location model from the LocationRepository, I can map it to the ViewModel without the driver.... I am just trying to figure out how to convert the viewmodel to shape from the controller without the display manager.
I am looking at the Adhoc setup which seems to be simpler. But, how would I render my viewModel ?
Zoltán Lehóczky
@Piedone
Keep in mind that OC is also MVC, so you can do exactly what you explained (if you don't need OC's display management) and just display a simple view. Otherwise, yeah, an ad-hoc shape would be the easiest. You can also pass complex objects (anything, really) to a shape (i.e. the shape object) and access it from the shape template (i.e. the cshtml file). Check out the linked sample.
CrestApps
@CrestApps
I actually want to use Shapes. But, is there an easier way create the shapes directly from the controller without having to use the display manager and driver?
Zoltán Lehóczky
@Piedone
Yes, and again please take a look at the sample. If you search for "shape" in the project there will be another sample of creating a shape directly from backend code and possibly also a sample of using ShapeResult (if not, check out the OC source), that's what you're looking for.
CrestApps
@CrestApps
@Piedone I am following the training model you provided. Thank you for that! Is there an example somewhere on how to create a simple CRUD without using content type/parts? my data are coming from custom repositories.
CrestApps
@CrestApps
trying to figure out how to handle the post request on an admin controller
Zoltán Lehóczky
@Piedone
Please create a discussion unless both the answer and question can be something like one sentence otherwise this will get convoluted and others looking for the same info won't be able to easily find it.
Sipke Schoorstra
@sfmskywalker
@Skrypt A customer asked about an Elastic Search implementation for Orchard, and I just so happen to know that you are an expert on the matter. You mentioned on SO (https://stackoverflow.com/a/57475016) that there are plans to support Elastic Search. Is this something you (or someone else) is actively working one? Would you be available for hire should the customer ask for it (they haven't asked; just assessing the situation proactively ;))
Jasmin Savard
@Skrypt
Nothing has been done so far regarding ElasticSearch. There's been discussion about it but the focus has been on releasing OC 1.0 mainly.
As for the other question, Skype me.
Julien Chomarat
@juchom
Hi everyone, I'm studying the Blog recipe and I'm not sure why is there a Blog type and a BlogPost type. BlogPost is a post, but I don't really understand the point of the Blog type?
Hisham Bin Ateya
@hishamco
This will be handy if you have multiple Blogs in your site
Julien Chomarat
@juchom
ok, thanks I was expecting this answer!
Hisham Bin Ateya
@hishamco
For example Microsoft dev blogs, they have many blogs for their developers each one has many blog post .. hope this illustrate why Blog Type is important
Julien Chomarat
@juchom
it's pretty clear!
One more question, I want to add an Employee type with its bio and I want to add a BlogPost type where the author is one of the Employee. How do we modelize this with Orchard?
1 reply
Hisham Bin Ateya
@hishamco
There's a UserPicker
I'm not sure if it's mereged yet /cc @deanmarcussen
Julien Chomarat
@juchom
it's merged here: OrchardCMS/OrchardCore#7570
Hisham Bin Ateya
@hishamco
So, you can use it ;)
ramanikrishnaraj
@ramanikrishnaraj
Hi, my objective is to create a custom module to access table in another server using web API.
First I tried to create a project named OrchardCore.CustomModule
Created a controller with HomeController.cs file, view/Home/hello.cshtml. Modified the Startup.cs , Manifest.cs etc.
Added the OrchardCore.Module.Targets in dependency.
Referenced the OrchardCore.CustomModule in OrchardCore.Cms.Web dependencies.
In startup.cs file of OrchardCore.Cms.Web added services.AddOrchardCms().AddMvc();
Everything is compiled, But can't see the module in features. What I'm missing? Any help is appreciated.
Julien Chomarat
@juchom

@hishamco , UserPicker almost solve my problem, the problem is that a User has not enough properties, I'd like to have more things like a bio and a picture for example.

Is there a way to extend the User or should I go for a custom type Employee?

Hisham Bin Ateya
@hishamco
There's a custom setting added to extend the user, so you can add a profile propteries that attached to the user using CustomSettings streotype, I enchrouge you to check @deanmarcussen demo in Orchard Standup https://www.youtube.com/watch?v=_ff79hm5PAc
3 replies
Richard Garside
@NogginBox
Can you automatically run a recipe as part of an Azure DevOps deployment?
The devops team are very excited and want to be able to do a completely automated clean build and deploy.
2 replies
zedjr
@zedjr
is decoupled cms where i can write my own code in visual studio then copy and paste plugins from orchard into my code to use then admin section. Am just starting out with orchard and trying ot learn all this cms stuff also.
1 reply
zedjr
@zedjr
lets say i got a website xyz and it is custom built. Now i want to add ecommerce and a place for client to put in their products. What part of orchard core should i learn?
1 reply
Sébastien Ros
@sebastienros
@juchom also note that you can also create fake authors, that are not necessarily users. This way you can always assign anyone to anything, even if users leave. And can still assign a user account to a "Author content item" using a user picker field.
1 reply
shao123-dev
@shao123-dev

Hi at all!
i have a question. I have created my own module. So my View is a cshtml file with html Code.
And it works! :)

My idea is, i will use the module in future with different styles/layouts. For my test i create in the Admin Area -> Design -> Templates, added a Template.

I tested my output with {{ Model.ContentItem.Content }}
My output was:
{ "WebSammlungDetailPart": {}, "WebSammlungField": { "WebSammlungField": { "WebSammlungId": "34" } }, "FlowMetadata": { "Alignment": 3, "Size": 100 } }

Here is my question: How i can my cshtml code/variables to my liquid template? So my output is not complete. I get only my WebSammlungid? I dont use a controller. i send my variables direct to the display driver.

Aaron Amm
@aaronamm
FYI, I just opened an issue about adding GitHub action to deploy to Azure App Service automatically.
OrchardCMS/OrchardCore#7819