# Home with exception

**URL:** <https://forum.getkirby.com/t/home-with-exception/5300>\
**Category:** Questions\
**Tags:** v2\
**Created:** [September 20, 2016, 9:08pm UTC](https://forum.getkirby.com/t/home-with-exception/5300 "2016-09-20T21:08:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [September 20, 2016, 9:08pm UTC](https://forum.getkirby.com/t/home-with-exception/5300/1 "2016-09-20T21:08:42Z")

</div>

Hello,

I have a «cosmetic» problem

My Home Button ist a logo with a text

if the user visit the page he can see only the **logo without text**  
if the user on a page but not the homepage a he click on the home button  
he arrived on the homepage and see the **logo with text**.

how can solved the little problem without generate double content  
and without js.

greetings perry

---

<div class="post-metadata">

**Author:** ![Thiousi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thiousi/32/13656_2.png) [@Thiousi](https://forum.getkirby.com/u/Thiousi)\
**Post date:** [September 21, 2016, 6:21am UTC](https://forum.getkirby.com/t/home-with-exception/5300/2 "2016-09-21T06:21:11Z")

</div>

If you’re using a different template for your homepage compared to all the other pages, you can use that in an if statement.

“If template is different than home =\> display text”

Let me know if you need help with that 😉

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 21, 2016, 9:51am UTC](https://forum.getkirby.com/t/home-with-exception/5300/3 "2016-09-21T09:51:16Z")

</div>

Do I get this right, that you want a different behavior of the logo depending on whether the home page is visited directly or if the user comes from another page?

If so, I think you could achieve this with cookies. But what is your use case for showing a different logo?

---

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [September 21, 2016, 12:26pm UTC](https://forum.getkirby.com/t/home-with-exception/5300/4 "2016-09-21T12:26:28Z")

</div>

thank you @texnixe @Thiousi for your answers.

if found a solution:

home button with link to /index.php  
if the user visit first time the homepage  
[www.myhomepage.com](http://www.myhomepage.com)  
**logo without text**

if the user use the home button (/index.php)  
**logo with text**

```auto
      <a href="/index.php">
      <div id="logo-wrapper">
        <ul id="logo-symbol">
          <li><h1>logo</h1></li>
        </ul>
        <?php
        $url= $_SERVER['REQUEST_URI'];
        if ($url == '/index.php')
        {
          ?>

                <ul id="logo-title">
                  <li>text</li>
                  <li>text</li>
                </ul>

               
         <?php                
          }
              ?>
      </div>
       </a>

```

---

<div class="post-metadata">

**Author:** ![AugustMiller](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/augustmiller/32/160_2.png) [@AugustMiller](https://forum.getkirby.com/u/AugustMiller)\
**Post date:** [September 21, 2016, 4:54pm UTC](https://forum.getkirby.com/t/home-with-exception/5300/5 "2016-09-21T16:54:20Z")

</div>

Hey! I think I understand what you’re looking to do (determine whether a visitor has seen your homepage, yet), but I wanted to offer a broader solution. For anyone else coming here looking for a way to alter the appearance of global page elements based on the current page, this is still relevant information!

The above may work, but doesn’t really look like a Kirby-specific solution— in fact, most people will be using `mod_rewrite` and have URLs without the `index.php` script name. Plus, Kirby has so many built-in helpers that you can probably avoid comparing strings to super global properties. Take [`$page->isHomePage()`](https://getkirby.com/docs/cheatsheet/page/is-home-page) for example!

This kind of thing should be as simple as using a bit of CSS, but check out one really neat trick, first.

```auto
<body class="<?php echo $page->slug() ?>">

```

You’ll end up with something like this, if your Homepage has the slug `home`:

```auto
<body class="home">

```

It’s also possible, as @texnixe noted, to set a Cookie— you could just as easily add a class to `body` based on the state of that cookie.

Either way, with CSS, you can use a scoped rule to target the header content you want to show or hide:

```css
/* Default appearance */
.logo-title { display: none; }

/* Appearance when on the homepage */
body.home .logo-title { display: none; }

/* Appearance based on cookie state */
body.already-viewed-homepage .logo-title { display: none; }

/* The same works for any other page slug! */
body.contact .logo-title { display: none; }

```

You can even add multiple classes (i.e. one for `$page->template()`)! I typically use [a helper function](https://github.com/AugustMiller/plainkit/blob/master/app/site/plugins/helpers.php#L2-L5) to add them more efficiently.

✌

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 21, 2016, 4:57pm UTC](https://forum.getkirby.com/t/home-with-exception/5300/6 "2016-09-21T16:57:20Z")

</div>

@AugustMiller Yes, I would prefer that to the solution with the index.php as well.

---

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [September 21, 2016, 10:17pm UTC](https://forum.getkirby.com/t/home-with-exception/5300/7 "2016-09-21T22:17:48Z")

</div>

@AugustMiller thank you for answer and the tip $page-\>isHomePage()

i found another solution with $\_SESSION  
set the session var in all templates but not in home template

```auto
       <div id="logo-wrapper">
            <a href="/">

        <ul id="logo-symbol">
          <li><h1>logo</h1></li>
        </ul>
        <?php
        
        if ($_SESSION["homebutton"] == 1 and $page->isHomePage())
        {
          ?>

                <ul id="logo-title">
                  <li>text</li>
                  <li>text</li>
                </ul>

               
               
<?php                
}
    ?>
       </a>
      </div>

```

why the /index.php is not a good solution ?

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 4:55pm UTC](https://forum.getkirby.com/t/home-with-exception/5300/8 "2025-02-06T16:55:12Z")

</div>

Archived on February 6, 2025, 4:55pm UTC


