Display standard Kentico CMS document page using MVC controller - kentico

Is there an easy way to use an MVC controller in Kentico; and, return a specific page that has been developed in Kentico, as opposed to referencing something like ~/Views/ControllerName/SomeView.cshtml?
I'm trying to use the MVC controller to provide some needed routing functionality, and already had a working page prior to using the controller. I would like the display to be pulled from the working page I had before using the controller.
I'm using Kentico 7.

Especially in Kentico 7, MVC support was more or less "you can use it, but it won't be usable with portal functionality."
You can have MVC pages, and have Portal pages, but there really isn't a way to pull in a portal style page into it. You're best bet is to try to either use some custom logic to render the elements you need and pull in that content dynamically into the page.
I could be wrong, my MVC isn't as strong as my kentico.

Trevor is right - there is an ASP.NET MVC support in Kentico v7 you can use but there is nothing like MVC Portal Engine or something like that. There are two possible ways how to achieve your scenario:
You can use Kentico as a 'model' and read (manipulate) data via API in your controller and view (typically in Razor). Then you need to:
a) register route to your controller in CMS Desk > Node > Properties > URls and choose proper Path type (route or MVC) - this is prefered way
b) create MVC page template in Site manager > Page templates
You can find example on Corporate Site (part of default installation) in CMS Desk > Corporate Site > Examples > Development Models > MVC
You can learn more in Kentico CMS 7 documentation (MVC development overview section).
Please note there is whole new MVC approach in latest version (Kentico 9).

Portal engine is based on web forms and components such as web parts, page templates or widgets are not supported by MVC itself so you wont be able to display your page using MVC.
Kentico 10 will contain many new features regarding MVC, but mixing portal engine with it will not be the case.

Related

How I can save a Page in a Page Template in Kentico Xperience13

In Kentico Xperience13, when I go in the Page Template application they said we need to use the Page Application to create a page and save it as a Page Template. But when I create a Page I don't see the place where I can save as a Page Template. So when I came back in the Page Template application the list is always empty.
To use Page Templates in Kentico Xperience 13, you either need to create default templates through code - see Developing page templates, or you can save widgets that have been added to a page as a custom page template - see Saving pages as custom page templates
As someone currently working on a site in Xperience 13, you may want to consider taking a class or two on Pluralsight to give you the basics of MVC and .net core. I am new to those but have been using Kentico for over 10 years. This change to MVC has been a bear to learn. But the Pluralsight courses have helped me get a better understanding of the structure.
Kentico does use content based routing as an option (and I think it is default in 13) you can learn more about it here https://docs.xperience.io/developing-websites/implementing-routing#Implementingrouting-Contenttree-basedrouting
when you build page types you don't have to worry about the model and the controller portion, kentico handles it, you just need to build the view.
this tutorial covers the basics https://docs.xperience.io/13tutorial/asp-net-core-development-tutorial

Can you combine Kentico 12 MVC and Kentico 12 Portal Engine development within the same website?

One of our clients has a rather large website, currently build in Kentico 11 / Protal Engine. We are now preparing the transition to Kentico 12 / MVC.
We woul'd like to do this gradually, per section. We have a couple of concerns regarding this:
Is it possible to run parts of a website Kentico 12 MVC and other parts Kentico 12 Portal Engine?
Is it possible to handle specifice cultures first? So is it possible to have 2 versions (MVC / Portal Engine) of the same page?
Are there any best practices concerning a gradual transition to K12 MVC? Since this is a rather large site, we have to do this transition gradually.
I would highly highly recommend against mixing a Portal Engine site and MVC site in Kentico (Web Forms and MVC in the same project). While yes, this is techncially possible (see this link on websites that use MVC partially in the portal engine on an older version of Kentico) it is no where near a best practice. There is a performance consideration (overhead of processing requests in both the web forms lifecycle and mvc pipeline), long term maintainablity consideration (hard to rememeber what goes / went where), and overall technical debt to deal with.
I would recommend jumping to MVC for the whole thing when it is time for a redesign as a best choice, or when your version of Kentico won't be supported by Kentico on Portal any longer (see the Kentico MVC transition guide)
If you absolutely need to do this in chunks, consider creating a second site in your Kentico instance at a different subdomain and learning MVC for Kentico there while still connected to he same instance. You could start treating the content as a content model accessible through the Kentico libraries nuget packages in a clean MVC architecture. This site could live at subdomain.website.com while your existing portal engine site could be at www.website.com. Again, this would not be my first choice, but it could possibly make sense in your scenario.
There is no easy way of combining the Portal Engine and MVC together. In your scenario, it will be even harder as Portal site is on Kentico 11 and MVC site you are going to build on Kentico 12 I presume. Hence, the only strategy I see is:
develop, release and migrate content for a new site section by section
host both solutions separately (separate db, separate web servers)
set up a reverse proxy that will be routing requests to old or new site based on URL, so that for the site visitor it will still look like a single site
The only challenge in this approach is if you have some functionality that spends across the entire site. For example, it can be my account that is used for e-commerce, favourites, newsletters, etc. In this case I'd suggest considering moving this first alongside with the relevant sections.

Integrating html templates in Kentico 10

I am using Kentico portal to make an E-commerce site.If I wish to change the design of available sample E-commerce site.Would it be a tidious task ?
Example : If I download e-commerce design templates (i.e html and css files) and I wish to change design of each page of sample kentico site (home page,product detail page etc.)then, what is the most suitable and quick way to achieve this ?
How should I update the html/css of each page of available site with downloaded templates? OR Should I create entirely a new e-commerce site in the portal ?
The out of the box sites are meant to be used as examples and references not to build a production site off of. The markup used on the Ecommerce site will also be different, considerably different than your purchased template. I've found it much easier and faster to start from scratch with a blank site and implement all of the design that way. Make sure you take advantage of shared layouts and templates, this will help make development and re-skins in the future easier.

Liferay create site / page programmatically

I have been using Liferay for work for 2 weeks. I noticed that it's a bit difficult to find good documentation and tutorials.
Until now I created pages from the web portal. After I create them, I drag and drop portlets. I don't really like this approach, I would prefer to use a coding approach. Is there a way to create a website or page programmatically by defining a project as I do to create portlets?
Moreover, I am using Liferay with WebLogic 10.3.6. I want to know where liferay puts pages I created via web-portal on the file system. I suppose that a file, or something similar, is created when I declare a new site on the Liferay web-portal.
Thank you all,
Marco
Yes Liferay has it's Database, all data of any Liferay object is stored in the database and / or on the file system depending on your configuration.
However, one of the functionality of Liferay is to let you create pages / sites through the UI. As documented in the Java Portal Specification and Liferay Server Documents your approach to create pages in an alternative way is possible but it is part of Liferay's Portal Services. You can use Liferay's Service (HTTP REST) API to call the related service. To access those APIs you need to configure your Liferay Server.
In case you want to do programmatically you still need to configure, enable and call those external HTTP services from your code. You should not create Liferay Objects from your own code hosted as an extension inside your Liferay Instance as that will result inconsistency in your Liferay Database / filesystem. (As in case of page creation Liferay creates a set of other related objects in it's database / filesystem.)
In your liferay bundle you will find two plugins of interest.
First is resources-importer-web for which description says
The Resources Importer app allows front-end developers to package web
content, portlet configurations, and layouts together in a theme
without saving it as a compiled .LAR file thereby allowing for greater
flexibility in its usage between Liferay Portal versions.This app will automatically create associated content when other
plugins are deployed that are configured to make use of the Resource
Importer app.This app installs as a Liferay service.
Second is welcome-theme which declares resources to be created by resources-importer-web. This on should be example how to create your own. Take a look at
welcome-theme\WEB-INF\src\resources-importer\*
welcome-theme\WEB-INF\liferay-plugin-package.properties
This feature is described at importing-resources-with-themes
As mentioned by gabor_the_kid, Liferay stores all objects in its tables. For example, User related objects would be in user table. Liferay exposed services or API's to change the default/to add new behaviors by program but not easier than achieving it through UI. Also maintenance should be considered for going program way of creating pages or layouts etc.
You can describe your changes using xml and use the Liferay Portal DB Setup core to create the changes in DB.
The library defines the list of available xml configurations.

Which is the Liferay equivalent of a IBM WebSphere Portal / WCM Menu?

I've developed with WPS and WCM for several years and now I am also learning Liferay. I can't help but compare the features and I understand that in Liferay some things are done differently.
I would like to know the best practices to manage the following simple example:
A simple page with a carrousel with several images and links
Google analytics inserted in the page (Reusable in most pages)
The following is how I'd solve it in IBM WPS:
A HTML component with the Google Analytics code that is called in every page (I can't find how to do this in Liferay)
A content definition of an image and a link.
Create several contents for each image and link.
Create a menu that shows the list of content in the form of a carrousel (I can't find how to do this either in Liferay)
I am aware that Liferay has a list portlet and content that has repeatable items. I know I could use these, however its much more usable if I can have on content for each image/link and one reusable HTML snippet of code.
How should I solve this in liferay in the most efficient way?
Thanks!
You have to use Liferay Web Content portlet for creating the carousel. This is available in Control Panel. For your particular requirememnt you have to create a dynamic web content, which involves using of Velocity language and javascript to iterate over a set of images. Infact if you see Liferay's website, the home page has this kind of stuff.
For Google Analytics there are two ways. Liferay is not just meant for creating one site, it caters creation of multiple sites. Each site has a group of pages. You can create site from Control panel again. In the site settings you have this option to add google analytics id. So with each site can have different google analytics id.
If you want to do it at a global level, we add the google analytics script snippet in the Theme of liferay.
To get a better understanding of all the jargons used in Liferay, you have to atleast go through Liferay's documentation. And while going through it you have unlearn what you have previously learned. Liferay has hell lot of features than Websphere portal.
http://www.liferay.com/documentation/liferay-portal/6.1/user-guide

Resources