Using the Portal App as the Foundation of a New Website

Using the Portal App as the Foundation of a New Website

The Scrivito Portal App can serve as a basis for implementing many and varied websites, not just customer portals. In this guide, we are going to show you how to remove the default content and start from scratch with just a homepage. On this occasion, we’re also going to explain how to use the layout areas.

For this tutorial, you don’t need to download or clone the Portal App and execute it locally because we won’t touch any files in the codebase. Just open your Portal App in the browser.

Let’s get started right away!

Adding a site

In the Interface Builder, a website is represented by its homepage object. Typically, a content object of the “Homepage” type is equipped with several attributes from which the app code obtains various global styling and layout settings, site-specific access keys for third-party services like Facebook, etc.

First, when opening your Portal App in the browser, make sure to have “scrivito/” in the URL path as the first element after the hostname for having the editing interface available. Of course, you can also use the editing interface on edit.scrivito.com, or jump in via the JustRelate Console.

Then, create a working copy for applying the changes we’re going to make in the course of this guide. You can do this by setting the display mode to “Edit” using the switch on the top bar, or by clicking “New” in the “Working copies” sidebar.

Next, on the “Sites” sidebar, click “Add site” and provide the name, homepage type, and the language of the site you wish to create.

Afterwards, if you select the new site via the “Sites” sidebar, an empty page with just one widget list for the page content will be displayed. We will take care of the layout of this page later.

Removing the default websites

A website consisting of more than just a homepage cannot be deleted via the “Sites” sidebar or the main menu. You would have to do this object by object, starting at the deepest level of the page hierarchy. However, we can use a script to delete the objects belonging to a particular site. To determine the objects to delete, we require their site ID which can be taken from the properties of any page belonging to the site in question.

To proceed, open your browser’s JavaScript console and change the context from top to scrivito_application_scrivito. Then, in the script below, replace the DEFAULT-SITE-ID placeholder with the ID of the site to remove. Now, run the script and watch the pages disappear. A similar version of this script along with many other usage examples can also be found in the SDK Cheat Sheet.

Rerun this script to also remove the other default site the Portal App comes with.

Specifying the new site’s basic properties

If you open the properties of the homepage you created a few moments ago, you will notice that there’s a whole bunch of configuration options available on several tabs, too many to discuss all of them here.

The options most essential for the site to work properly are the “Base URL” and “Location of search results page” site settings (the latter only if you want to enable searching), and the header, sidebars, and footer layout options.

Base URL: This is the URL of your site’s homepage, e.g., https://acme.com.

Location of search results page: In the context of the Portal App, the search results page is a regular page that is equipped with a few special widgets providing the functionality needed to display clickable search results, “search again” and “load more” buttons, etc. You can copy this page from one of the original portal sites (via another working copy), paste it to your new site, and specify it here in the site settings.

Header, sidebars, and footer: These layout elements are disabled by default. Switching them on as needed allows you to globally add standard elements such as a top-level navigation, breadcrumbs, etc., to your pages via widgets. To edit these layout sections, switch to “Edit layout” in the top bar.

Populating the navigation

The first thing that should be done after creating a new website is to specify its title on the “General” tab in the page properties. Later, this title shows up in, for example, the “Breadcrumbs” widget, making it easier to navigate back to the homepage from any subpage. Then, choose the other layout areas you wish to include on your pages.

As an example, we’ve enabled the “Left navigation” layout option, placed a “Vertical navigation” widget inside the corresponding widget list, and switched “Show link to parent page” on in this widget’s properties.

Now, to create a subpage underneath the homepage, click the light blue handle of the “Left navigation” widget, followed by “Add page”. You will be presented with a dialog that lets you select the type of the new page. Wherever such a light blue handle can be seen, it’s for managing the subpages of the current page.

Several other layout widgets are available for bringing the site layout areas to life, e.g., the “Top navigation” or the “Breadcrumbs” widget mentioned above.

Summarized ...

After adding a new site to the Portal App content, and removing the default sites, you can use the page and widget types the app provides to add your own content and choose how it’s made accessible to visitors, most probably via a navigation.

For getting the most out of the Portal App, we recommend installing it locally and adapting the existing page and widget types according to your demands, or to create custom page types or custom widget types to cover your individual use cases.