Mixing Orchard CMS content with module - orchardcms

I am currently working on an Orchard module. This module contains an MVC application including the views. I would like to make the module as configurable as possible. One of the items that I would like the customer to configure is the way the MVC views from the module look. Part of it will be determined by the theme. But not everything. Consider the following scenario:
The module contains a view for placing an order. The view displays a form in ´normal view way´. That is field labels and input labels. But at the head of the form each customer must be able to define his own set of instructions to display. Or maybe the customer wants to put there a message for pointing the customer to some other actions.
In the most ideal way I would have a content page where the customer can put all kind of content and one specific block that is the result of the view of the module. Kind like a web part. I can´t find out if it is possible and how that is achieved.
Edit for clarification
Module creates a page like this:
TITLE
FORM
So both title and form are outputted by the module controller.
I have managed to create a layer with the condition that the url matches the page with my form.
I have added a HTML widget to this layer in the content zone with position 1 (tried 0 to).
However the pages looks like this:
TITLE
FORM
WIDGET
instead of
WIDGET
TITLE
FORM

Returning a ShapeResult from your controller action will ensure that your view is themed and benefits from widgets, which are your "kind like a web part" thingies in Orchard.

Related

Template to provide static HTML wrapping a page-specific value

I am creating a page template. Each page using the template will have a single unique value that gets embedded into the page HTML. The rest of the HTML is constant for all pages. Assume the following is the desired result:
click me
I want a template that provides click me, while allowing the individual pages (content admins) to provide id.
I've tried using an Editable Text web part, and putting the "before" and "after" HTML in the HTML Envelope before and after sections, and adding the ID on the "Page" tab. However, that is not quite working. What is the best way to accomplish this?
This can be done. What you'd want to do is add that field to the page type fields you're adding those pages with. For instance, say you have a list of locations under /locations.
i.e.:
/location/chicago
/location/new-york
/location/minneapolis
The locations themselves (Chicago, New York, Minneapolis) are your custom page type and have a unique field called LocationID. On your template, add a static text webpart (not static HTML because the WYSIWYG editor overwrites the markup you add) and simply add this:
click me
If the LocationID field has a exists AND has a value, it will output it, otherwise it will just leave the URL http://www.example.com/
If you didn't want to show that link at all on other pages, then set the Show for page types property based on the page type you want it to show for in the Visibility section of the static text webpart.

Orchard CMS: Using different Layout for Anonymous users

I would like to use a different layout view for anonymous users. I have tried using url alternates and I am not sure how I can create a layout for anonymous users since there is no particular url for them.
The idea is that, if a new user visits the site I want to show a splash screen with very limited information with an option to register/ login to view the full site. This splash screen will have a completely different layout / look and feel from the rest of the site.
I tried using the Anonymous user layer but all I could do was move widgets (maybe I am missing something).
Any help would be greatly appreciated.
Thanks!
There is no out of the box solution but you can do something like this to get what you want:
Add new layout in a file with the name of your choosing - for example, you could name it Splash.cshtml.
Add the code below to the top of your Layout.cshtml template:
#if (WorkContext.CurrentUser == null) {
#Display.Splash()
return;
}
The code will check if the user is logged in. If it's not, it will render the content of your Splash.cshtml template, and stop the rendering of the rest of the Layout.cshtml template.
If you need to display any of the widgets in your Splash.cshtml template, you could add it by simply adding #Display(Layout.NameOfTheZone) where you should replace NameOfTheZone with the actual name of the zone you're using inside the Layout.cshtml template. Generally, anything that you use inside Layout.cshtml template with the Model object, you can use through Layout object inside any of your views.

Global sidebar with widget support

I would like to make a layout with a sidebar that can have widgets from different modules. Lets say there shall always be a login widget at the top if the user isn't logged in then it shall show user info. The getting started album guide could use it to display the latest albums and so on, i hope you understand how i want to use the sidebar.
Could it be done with a config file in autoload and a small code that read that config and calls the widgets on every page load?
There are several ways of page composition in Zend Framework 2:
1. Switching between Layouts
By default, ZF2 provides you with a single layout template layout.phtml.
In real-life applications, you will probably need to have several layouts
and switch the layout for certain controller/action. In each of your layouts, you will be able to show different widgets/sidebars.
2. Partial Views
A partial view is a .phtml view template file which can be rendered by another
view template. Partial views allow to compose your page of pieces and reuse pieces
of view rendering logic across different view templates. This is accomplished through the Partial view helper.
3. Placeholder View Helper
The Placeholder is another useful view helper allowing for capturing HTML
content and storing it for later use. Thus, analogous to the Partial
view helper, it allows to compose your page of several pieces.
4. Forward Controller Plugin
With the Forward controller plugin, you are able to call an action (for example, the action rendering some widget) from another module/controller from your controller and grab the output of that action. Then you are able to incorporate that output into your page.
5. Use View Models for Page Composition
When you write action methods for the controller classes, you use the ViewModel
class as a variable container for passing the variables from controller to view template,
and for overriding the default view template name. But, actually the ViewModel class is more than just a variable container plus view template name. In fact, it is closely related to the layout and page composition.
The third big capability of the view model class is that it allows for combining several
view models in a tree-like structure. Each view model in the tree has the associated
view template name and data variables that can be passed to the view template to control
the process of rendering.
This feature is internally used by Zend Framework 2 when "combining" the layout view template and the view template associated with the controller's action method. ZF2 internally creates the view model for the layout template and assigns it with layout/layout view template name. When your controller's action method returns the ViewModel object, this object is attached as a child to the layout view model.
So, you can attach your own view models to the default view model to render the page of pieces that you want.

Making the webform submission results as a link in Drupal 6?

I am a newbie in using Drupal 6 and I am still walking in the dark in terms of module familiarization and module configurations. Lately, I installed the Webform module for my site to be able to let users submit a request. In my Webform, there is a Select View field where it lists all contents of a specific Content Type on my Drupal site. I was able to use a View as a datasource for my normal webform select component via the Webform View Reference Component that's whay I have a custom <select> field which are views on my Webform. Now, after a successful submission of the form, I go to Results and found the data which are saved upon submission. What I want is that, on my Results page, the selected option from the list, which basically are views, will be a link to their respective views. This is how it looks like,
I am really lost right here. Can someone lend me a hand on how to make this possible? Cheers.
Install this module http://drupal.org/project/webform_report it will be displayed in table format and also you can customize the report & also It will create separate content type.
Below is the screen shot for webform report, you can also view, edit & delete from report itself.

Using a MulitpleLookupField in MOSS '07 Layout Page

I have a page layout for my MOSS '07 site that I want put a MultipleLookupField in. The field will point to a multiple lookup column in my custom content type that points back to the pages library so I can have a "Related Articles" field.
I've gotten the field to show up correctly--it's even editable when the page is in edit mode! But when you click on the link that shows up there, it display the page's properties view instead of the page itself.
There's lots of properties on the control, but there's little documentation at MSFT as to what they do.
Does anyone know how to change the link's URL to the actual page instead of the properties view?
Here's the tag I'm using:
<SharePointWebControls:MultipleLookupField
ID="MultipleLookupField1"
FieldName="RelatedIssues"
runat="server"></SharePointWebControls:MultipleLookupField>
The link takes me to here: /Pages/Forms/DispForm.aspx?ID=6&RootFolder=*
I want it to take me here: /Pages/faq1.aspx
Unfortunately the lookup control is designed to be compatible with generic lists and does not understand that the document libraries have a file with a specific url associated.
You will probably have to find a custom lookup control on the web or roll your own.

Resources