Back to Microdata class

Method getExpectedDisplayType

protected static string
getExpectedDisplayType
(mixed $type, mixed $property)
Return the expected display type: [normal|nested|meta] In which way to display the Property: normal -> itemprop="name" nested -> itemprop="director" itemscope itemtype="https://schema.org/Person" meta -> `<meta itemprop="datePublished" content="1991-05-01">`
Parameters
  • string $type The Type where to find the Property
  • string $property The Property to process
Returns
  • string
Since
  • 3.2
Class: Microdata
Project: Joomla

Method getExpectedDisplayType - Source code

/**
 * Return the expected display type: [normal|nested|meta]
 * In which way to display the Property:
 * normal -> itemprop="name"
 * nested -> itemprop="director" itemscope itemtype="https://schema.org/Person"
 * meta   -> `<meta itemprop="datePublished" content="1991-05-01">`
 *
 * @param   string  $type      The Type where to find the Property
 * @param   string  $property  The Property to process
 *
 * @return  string
 *
 * @since   3.2
 */
protected static function getExpectedDisplayType($type, $property)
{
    $expectedTypes = static::getExpectedTypes($type, $property);
    // Retrieve the first expected type
    $type = $expectedTypes[0];
    // Check if it's a 'meta' display
    if ($type === 'Date' || $type === 'DateTime' || $property === 'interactionCount') {
        return 'meta';
    }
    // Check if it's a 'normal' display
    if ($type === 'Text' || $type === 'URL' || $type === 'Boolean' || $type === 'Number') {
        return 'normal';
    }
    // Otherwise it's a 'nested' display
    return 'nested';
}