orchard cms: how to add media picker field to anew module - orchardcms

I am building a module for orchard cms.
I would like to use the mediapiker module in my module.
Through the orchard backend interface, its possible to add a moudle to a content item.
What is not clear, is how to use one module in another.
how do I add the mediapiker field to my razor view in visual studio?

You should take a look at MediaPickerFieldDriver.cs and MediaPicker.Edit.cshtml. They are both in Orchard.Fields. That should give you everything you need.
Then again it's not entirely clear what you are trying to do. If you are just trying to add a media picker field to your content type from code, then you should do it from the migration, like this:
ContentDefinitionManager.AlterPartDefinition("Product",
builder => builder.WithField("ProductImage",
fieldBuilder => fieldBuilder
.OfType("MediaPickerField")
.WithDisplayName("Product Image")));
Update: As #ed13 points out in his answer, for more recent versions of Orchard 1.x (1.10+), the field type is MediaLibraryPickerField instead of MediaPickerField.

If it helps anyone using a later version of Orchard (v1.10.+), the code required to add a media picker field is below:
ContentDefinitionManager.AlterPartDefinition("YourContentPart", builder =>
builder.WithField("BackgroundImage",
fieldBuilder => fieldBuilder
.OfType("MediaLibraryPickerField")
.WithDisplayName("Background Image")));
Hope that helps someone.

Related

Mixing content and widgets

I am new to Orchard and question myself how to mix up widgets and content. As of my understanding, the page content type has one layout where you put all your content in: HTML, images, et cetera. Where it will get displayed is defined by the theme. By placing widgets into the zones of the theme I can display custom modules in addition.
But, what if I want (for one specific page, from top to bottom)
Content/HTML -> Widget -> More Content/HTML -> Another Widget -> Even more Content/HTML?
I know it is possible to achieve that by placing the second and third content block into a widget and configure the layer to match the url of my page, but this seems to me like a hack.
In DNN you can place everything, HTML as well as modules, into the exact container/zone you want. In nasty Joomla! you can "import" modules (widgets) as part of the HTML of an article.
What is the way to achieve that mix up in Orchard?
You have tagged the question as orchardcms-1.10 so you should be able to do it.
Orchard has a module called Orchard.Layouts which provides the functionality that you are describing.
Are you using an upgrade old version?
If you have upgraded your site from an older version of Orchard then it will still just have the old style BodyPart as its main content editor. Fresh installs will have LayoutPart which can provide these kinds of complex layouts.
For an introduction on this subject look at IDeliverable's Orchard Layouts intro article.
If you are working with an old upgraded version please add a comment and I will explain the upgrade process.
Have you enabled the Layout Widgets module / feature?
If you already see this but can't add the widgets then make sure you enable the Widget Elements feature:
Go to:
Admin panel
Modules
Type widget into the filter at the top
Click Enable on the Widget Elements feature
Now when you go back to the layout editor you will see a new category with all the widgets placeable as elements.

openNtf debugToolbar UI is overridden by extLib's Bootstrap3 theme

This relates to an Xpages project using openNtf's Extension Library for Domino 9.0.1 V 16 (2016-01-28). There is a custom theme applied that extends extLib's Bootstrap3 theme.
Now I also applied Mark Leusink's debugToolbar Plugin (V 4.0.1, 2014-03-10).
Unfortunately all tables that are display inside the toolbar are partially "destroyed", as in this example:
Debugging the resulting html I see that the "label" cells of the debug table are assigned class="label" or class="label wide". Unfortunately bootstrap.css applies a display: inline style to a .label selector.
Currently I solved this by applying my own custom css file to reset toolbar styling; but I wonder whether there might be a more elegant way, maybe some kind of property that I simply missed out here. Or is this something that have to be done within the toolbar's source code?
Please add this as a defect on the project, so the contributor is aware and can resolve.
Alternatively, download the source code from https://github.com/OpenNTF/DebugToolbar, contribute the fix and make a pull request.
Hopefully Paul's and my entries at github and within the openntf.org project will help resolving this issue. Meanwhile my workaround seems to be the only option here;
As I mentioned above I created a custom styleSheet with just one line in it:
div.dBar table.grid td.label{display:table-cell;}
Then I created a cusom control as a container for the debug toolbar so that I could link my custom style sheet as a resource. The debug custom control finally is added to all the xpages where I want to have the toolbar.
Maybe this can help others, too.

Orchard Projection Isotope

I'm trying create an affiliate directory on my Orchard site. The directory is populated by running a query on my custom Content Type. The directory needs to be sortable and searchable. I've set up a basic jsfiddle here that is a basic functioning version of what I'm attempting to do, but it's just in html: http://orchard1.pha.jhu.edu/affiliates-beta-2
Or you can view the jsfiddle here: http://jsfiddle.net/tgelles/AMZf8/
Has anyone discovered a way to best use isotope on an Orchard Projection? I've downloaded the Projection Layout module, but I have no idea how to use that/where to inject the specific isotope code. I've also created alternate template files for the Projection's Summary display, but I don't know how to best inject the isotope plugin into that razor file.
Any help would be appreciated.
The best way would be creating a shape, but You could easily edit the query template and inject the js through a custom view for that projection(url,type, etc)
Check in your Queries.
There was a video which helped me understand better how they work: http://www.youtube.com/watch?v=Ka55wTTXZg8
Hope it helps.

HTML Editor in Orchard 1.4

I had a look around on SO to see if someone has asked this question before or not, but couldn't find any posts. My apologizes, if this is a duplicate question.
In Orchard 1.3, there is a module for HTML field that one can use...but there is nothing in Orchard 1.4. How do I go about creating a content type with multiple HTML fields? ( Just adding it in UI and not coding).
Thanks
It's the opposite. There wasn't one out of the box in 1.3, and you had to download one from the gallery, whereas it's built-in 1.4.

Searching content in custom module of Orchard CMS doesn't work

I wrote my own module for Orchard CMS. Module have some widgets, for example,one of widgets is a news widget. In Admin menu(Content->Content Type) I checked Index this content type for search, but when I try to search anything in my widget, nothing found. For searching I use standart widget, which part of Orchard CMS. I know that Orchard use Lucene.net, and there are my questions:
How Lucene.net index content of all pages ?
What I need to implement in my module(widgets) for searching ?
A widget is not routable, so it can't appear in search results.

Resources