Checking if it is a homepage of a site in layout.phtml

Hello all,

I have a question related to finding the homepage of a particular site. It is similar to this question. https://forum.omeka.org/t/solved-how-to-find-current-page-slug-in-theme/3250/1

Basically i am writing a theme, and in the layout.phtml file i would like to write a conditional to check if the current page is the homage page of a particular site and then basically display a large search area. I don’t want to hardcode (/s/siteslug/page/homepage/) the home page of a site, because I would like the theme to be re-used across many different sites.

Is there any way to call the homepage of a site?

Hi @sanjinmuftic ,

You could do something like this in your layout:

<?php if($site->homepage()->siteUrl() === $this->url(null, [], true)): ?>
   <div>
      <!-- Your large search area here-->
   </div>
<?php endif ?>

Dear @fackrellj,

Thanks so much, this is perfect and so clean. All I need to to is to make sure that within the navigation of each site, that I have explicitly stated what the home page is (instead of just having first page of navigation - otherwise it crashes the site- i think homepage() returns null).

Many thanks for this!
Sanjin