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.
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?
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() for example!
This kind of thing should be as simple as using a bit of CSS, but check out one really neat trick, first.
<body class="<?php echo $page->slug() ?>">
You’ll end up with something like this, if your Homepage has the slug home:
<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:
/* 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 to add them more efficiently.