How do I get the site name?

Hi all,

I’m working on the AdvancedSearch module and within resource-list.phtml file in view/search/ and trying to show one presentation of data for each item on one site but show a different presentation on another.

But I can’t seem to get the current site name.

the variable $site seems to be an instance of \Omeka\Api\Representation\SiteRepresentation

But if I call $site->displayTitle(), I get this error:
Call to undefined method Omeka\Api\Representation\SiteRepresentation::displayTitle() in /Applications/MAMP/htdocs/new/modules/AdvancedSearch/view/search/resource-list.phtml:76

And I can’t find any documentation for what methods are available for SiteRepresentation.

Does anyone know what I might be able to use for this purpose? Or is there a place I can read about what’s available for SiteRepresentation?

Actually I found a variable called $siteSlug set as
$siteSlug = $site ? $site->slug() : null;

So I could check it there.

Also, I didn’t check this but I think there’s a list of properties returned in the file SiteRepresentation.php in the folder application/src/Api/Representation/

        'o:slug' => $this->slug(),
        'o:theme' => $this->theme(),
        'o:title' => $this->title(),
        'o:summary' => $this->summary(),
        'o:thumbnail' => $thumbnail,
        'o:navigation' => $this->navigation(),
        'o:homepage' => $homepage,
        'o:item_pool' => $this->itemPool(),
        'o:owner' => $owner,
        'o:created' => $created,
        'o:modified' => $modified,
        'o:is_public' => $this->isPublic(),
        'o:assign_new_items' => $this->assignNewItems(),
        'o:page' => $pages,
        'o:site_permission' => $this->sitePermissions(),
        'o:site_item_set' => $this->siteItemSets(),
        'o:site_item' => ['@id' => $itemsUrl],

So I think title() would have worked too.

We do have a developer docs page for representations but it doesn’t currently have any information on the SiteRepresentation.

$site->slug() will get you the URL slug, and $site->title() the title.

Cool. Thanks so much for getting back to me :slight_smile: