# Section targeting and parametrization

Targeting a section in inventory.json may take place in two different scenarios:

  • By naming a placement (e.g. inline_mosaic_portada_1)
  • By section parametrization (e.g. ${SECTION_NAME})

Section targeting behavior though varies depending on how the inventory placements are consumed, that is:

  1. By accessing Marfeel from section pages or article pages in Mosaic
  2. By accessing Marfeel in Deeplinking (i.e. through the article page URL directly)

In case 1 the section identification happens without any problems.

In case 2, an article accessed through deeplinking is always associated with the default home section, as there's no prior way to identify the section that this article belongs to. We need to use the providers.json file to detect the section name in this situation.

The detection can be done by URL or by metadata.

# Section name detection by URL

In the Tenant's providers.json file:

{
  "sectionNameStrategy": {
    "type": "byUrl"
  }
}

In this example, the section name detection strategy will parse the article URL pathname, split it by / and pick the first pathname chunk as the section name. For instance, in an URL like the following, the identified section name will be "politica":

https://www.examplesite.com/politica/partidos-politicos/12345/someFancyArticle.shtml

# Options

Use an index parameter to pick other string-chunks as section names:

{
  ...,
  "sectionNameStrategy": {
    "type": "byUrl",
    "options": {
        "index": "2"
    }
  },
  ...
}

# Section name detection by metadata

To detect the section name by reading the <meta /> tags of a document, declare the strategy and the relevant meta tag in the providers.json file:

{
    ...,
    "sectionNameStrategy": {
        "type": "byMeta",
        "options": {
            "property": "article:section"
        }
    },
  ...
}

Detects politica if this is present in the HTML:

<meta property="article:section" content="politica" />

# Consistency

To ensure a consistent behaviour between articles opened from section pages and articles opened in deeplinking, you must make sure that the section names in definition.json are the same as what is detected via providers.json.

WARNING

If you change a section "name" in the definition.json, make sure you also change it in the corresponding layout descriptor files.