Introduction to Enterprise Sites features

ArcGIS Enterprise Sites allows you to create a tailored web page experience for your users by allowing you to share your portal's authoritative GIS data to other departments more easily, even if they are not used to working in your GIS. Instead of learning to navigate the portal and access groups, members can go directly to the custom web page you create to navigate the content relevant to them. Click here to learn more about Enterprise Sites.

Note: The pattern to add, search, get, update and delete Sites and Pages is identical to that of Initiatives.

In this notebook, we will demonstrate how to

  • Create a site with a custom domain and pages
  • Edit a site's theme
  • Edit a site's page layout
from arcgis.gis import GIS

First, we will sign into an ArcGIS Enterprise organization to demonstrate these workflows. We can work with Enterprise Sites using the sites property of the GIS object.

Note: This workflow is for demonstration purposes only. To replicate this, you will have to sign-in to an ArcGIS Enterprise organization you have access to.

See also these examples for working with Initiatives and Events using ArcGIS Premium and site and page creation and cloning using ArcGIS Basic that demonstrate other ways of working with your Hub using the ArcGIS API for Python.

gis_portal = GIS(profile='your_enterprise_profile')
Enter password: ········
portal_site = gis_portal.sites.add('Portal Python Site', subdomain='site-in-python-new')
portal_site.item
Portal Python Site
Site Application by creator1
Last Modified: July 07, 2023
0 comments, 0 views

Enterprise Sites also come with a Site item and the Content Team group for that site, where you can add the items for your site's Content Library. Additional information about this can be found in ArcGIS Hub's Content Basics documentation. Users with Administrative privileges that create a site will also have a Core Team group created as part of the site, to allow collaboration among members of that team. You can also create Enterprise Sites with a custom domain that is different from the title, as shown above.

Let's add a page to the site.

portal_page = portal_site.pages.add('New page')
portal_page.item
New page
Site Page by creator1
Last Modified: July 07, 2023
0 comments, 0 views

Editing the theme of a site

The Theme settings help you define the colors for the header, global navigation bar, buttons, text, and background colors. The colors and fonts that you select are applied to the entire site layout and to any pages attached to the site.

Here is the default theme for the site we just created. We will see how a theme of a site can be edited.

image

We start by fetching the theme for this site.

theme = portal_site.theme
theme
{'header': {'background': '#fff', 'text': '#000000'}, 'body': {'background': '#fff', 'text': '#4c4c4c', 'link': '#0079c1'}, 'button': {'background': '#0079c1', 'text': '#fff'}, 'logo': {'small': ''}, 'fonts': {'base': {'url': '', 'family': 'Avenir Next'}, 'heading': {'url': '', 'family': 'Avenir Next'}}, 'globalNav': {'background': '#fff', 'text': '#000000'}}

Next, we fetch the value for the background color for this site theme to change it.

theme.body.background
'#fff'

Updating the theme for this site

Updating this theme color is a two-step process. You first assign newer values to the theme variables, and then use the update_theme() method to commit these changes to the site object.

This same process of assigning new values to existing variables (sections, rows, cards) can be followed to update the specific layout elements of the site or page.

theme.body.background = '#b20000'
portal_site.update_theme(theme)
True

The theme background color has successfully changed on our site.

image

Background on the layout of a site and page

The Site Editor provides a user with several capabilities in the form of cards to simplify their site building and editing workflows. However, applying a common change to multiple sites and pages in your organization can become a tedious process. Using the site layout editing functionality supported in the Python API, you can successfully apply a common change across all the necessary sites and pages. In order to programmatically edit a site, we need to take a deeper dive into the data model of a Site/Page item. The site layout has Sections that contain Rows, and the rows further contain Cards. Sections have configurable attributes, like background color and font-color, and are used to theme a site or page. Rows are the building blocks of your site and are implicitly created when you add a card to a section below another card. Whenever you want to add a card, such as a text card or image card, you must have a row card positioned where you want to add that content. Multiple cards can fit in a row card.

site_layout

Next, we will see an example of how to edit each aspect of the layout of this site and its page.

The process is similar to editing the theme of the site. We fetch the layout of the site/page, make the required changes and commit them using the update_layout() method.

Adding a new card to the site

layout1 = portal_site.layout

You can access the nested sections, rows and cards of the layout as shown below.

layout1.sections[0].ROWS[0].cards[0]
{'component': {'name': 'spacer-card', 'settings': {'height': '50'}}, 'width': 12}

To add a new card, you must update the cards list for the row within the section with the dictionary for the new card.

First, we will access the row we want to add the new card to.

layout1.sections[1].rows[0]
{'cards': [{'component': {'name': 'markdown-card', 'settings': {'schemaVersion': 1, 'markdown': '<p class="lead text-justify">This is the platform for exploring and downloading GIS data, discovering and building apps, and engaging others to solve important issues. You can analyze and combine datasets using maps, as well as develop new web and mobile applications. Let\'s achieve our goals together</p>'}}, 'width': 12, 'showEditor': False}]}

The first row of second section has 1 text card. We will now add another text card.

new_card = {'component': {'name': "markdown-card",'settings': {'markdown': "Build tailored websites and webpages to showcase ArcGIS Enterprise content to your users."}},'width': 6,'showEditor': False}
layout1.sections[1].rows[0].cards.append(new_card)
layout1.sections[1].rows[0].cards
[{'component': {'name': 'markdown-card', 'settings': {'schemaVersion': 1, 'markdown': '<p class="lead text-justify">This is the platform for exploring and downloading GIS data, discovering and building apps, and engaging others to solve important issues. You can analyze and combine datasets using maps, as well as develop new web and mobile applications. Let\'s achieve our goals together</p>'}}, 'width': 12, 'showEditor': False},
 {'component': {'name': 'markdown-card',
   'settings': {'markdown': 'Build tailored websites and webpages to showcase ArcGIS Enterprise content to your users.'}},
  'width': 6,
  'showEditor': False}]

Now, we publish these changes and verify them on the site.

portal_site.update_layout(layout1)
True

image

The new text card is successfully added to the site.

Deleting a card from the page

We will now delete the red text card from the page that reads "Where we're going". To do this, we fetch the layout of the page, delete the card from the layout, and publish the changes.

image

layout2 = portal_page.layout
layout2.sections[2].rows[0].cards[0]
{'component': {'name': 'markdown-card', 'settings': {'markdown': "<h2 id='where-we-re-going'>Where We&#39;re Going</h2> <p>Here are the next steps and how we need your help to improve this data:</p> ", 'schemaVersion': 1}}, 'width': 12, 'showEditor': False}

Next, we delete the card from the row.

layout2.sections[2].rows.pop(-1)
{'cards': [{'component': {'name': 'markdown-card', 'settings': {'markdown': "<h2 id='where-we-re-going'>Where We&#39;re Going</h2> <p>Here are the next steps and how we need your help to improve this data:</p> ", 'schemaVersion': 1}}, 'width': 12, 'showEditor': False}]}
portal_page.update_layout(layout2)
True

Verifying the changes, we see that the row has been retained while the text card has been deleted.

image

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.