Question on placing custom content type in widgets

Topics: General, Troubleshooting, Writing themes
Dec 13, 2014 at 3:21 PM
Edited Dec 13, 2014 at 10:15 PM
I have created a theme and was able to define my own widgets so that my site has custom sections. Basically the site is a single page split into 3 different "slides" and instead of using the regular Page content type I would like to create a custom content type (or use the existing page one) and output that to the different widgets on each "slide".

I'm just not sure I am using the correct approach for this. For the page content type previously found in the default them it renders at the bottom of the page using the following -
@if (Model.Content != null)
    <div class="container mainContent">
@*end main content*@
I can't put this inside a custom widget. So instead I created a query called "All Pages" and used this to output all page content in my filter. I then added a new projection widget to my custom zone so that it would output my content in my slide.. and this seems to put the content in the correct place within my zone for editing.

I'm just not sure if this is the best approach to simply create a custom content type (just plain text for now) and add this to custom zones in my theme. Are projections/queries the way to go for this or should there be another method I should use? Appreciate any advice.. I have read documentation about custom themes but I still am confused :/

For my code, my theme's layout.cshtml looks like this now - (zone in my theme called Slides)

@if (Model.Slides != null)
@Zone(Model.Slides) (projection outputting my query for all pages)
Jan 6, 2015 at 12:08 AM
Edited Jan 6, 2015 at 12:25 AM
There are many way to organize and render pieces of view. In a hierarchical way, each view (*.cshtml), that you can override in your theme, use different models. So, in the Layout.cshtml, Model.Content is a zone with no widget and used to render the content item (that can be a list of other content items) associated with the current url, other zones contain other content items as widgets (based on layer rules, e.g always, if url = something...). There is a module from IDeliverable where you can associate widgets with a content item, so they are rendered when this content item is in the Content zone (based on the request url). You can also use the file to show, hide or move some parts (not a whole zone) (e.g title, body parts) to a specific zone. Finally, in 1.x version with the Layout module you can place any element you want where you want, an element can be a simple html text, a content part or a another content item

Note: Try the shape tracing module to see in the front end the hierarchy of views, all the shapes, display types, models, and the alternates you can use in your theme for views overriding with some files as "ShapeType-ContentType.DisplayType.cshtml"

To move a content item of your content type in a widget, you can add the "Widget" part to your type, input "Widget" in the stereotype setting, uncheck the "Creatable" and "Draftable" options (not well implemented in 1.8.x). After this, you can create some instances of your new widget and stack them in any zone. But, if you want full managed content items, you need to group them in another way. You can create a type with a "Container" part and add to your content type the "Containable" part, or use the "List" module. Finally, if you want your list to be updated when a new content item is created / published / unpublished, the best way is to use a projection

That said, if I understand, you want to load in one time all your 3 content items in your Slides zone, your Layout.cshtml is reduced to only display this zone. And maybe you implement on client side (with some jquery plug-in) a slider to move from one item to another. But, you need a Content zone, e.g when you log in, with a custom form or any other content item (not a widget) that need to be rendered in the Content zone. Here, a solution is to override your Layout view but only for the Homepage

So, in your case, I think the best way is to use a projection page (not a widget) and set it at the homepage. With projection, the advantage is that you can add filters and sort criteria. Did you see that in a query you can add layouts (shape, grid, list). In such a layout you can specify the Display Type, so, if you use "Detail" in place of "Summary", and if you have a body part, the full body text will be rendered. Finally, in some layout types, you can specify HTML properties for the container and content items. So, in one page you will have, in the Content zone, your 3 content items (full rendered) and with some html properties that can be used to implement your slider. You can also overide the view of the whole projection page, or only its inner List...

But, maybe I misunderstood what you want. For example, if you want different widgets on each slide, we have to find another solution. Let me know