I am new to Kirby and this is my first message to the forum. I am trying to convert my existing website to Kirby on my local computer to see if it is right for me. So far everything has worked out nicely except for this:
I have created a visible parent page called “Courses” which shows up in my main navigation menu.
The parent page has 8 visible child pages which pop up in the sub menu when I hover over the main “Courses” menu item.
Is there an easy way to have the “Courses” link not link to any page content at all? Essentially, I would just like to be able to hover over the “Courses” link and only be able to click on one of the 8 sublinks. Is that possible?
As a workaround I have followed the “Simple redirect” instructions and have made the “Courses” menu item redirect to the first child link. Is that the best I can do in this situation?
I’d create a new template templates/node.php for pages that serve only as a parent with no content themselves. In this template use a go()-redirect to the first child page: The template file will have only one line
Thank you for the replies and suggestions. This seems more complicated than I thought it would be (due to my limited experience with Kirby). I think I’ll stick with the “Simple redirect” solution for now and maybe come back one of the above methods when I am feeling more comfortable with the coding.
If you need any more information, don’t hesitate to ask.
Basically, you need to make the link clickable based on some sort of condition. To achieve that, you can either use a field in your text file, or a special template as described in the examples above. These implementations have the advantage that they can be used in a more general way if you later add pages, for which you want to implement the same behavior.
If you only want to implement this for this one page, you just need to add a condition to your menu which checks for the page’s uid while the rest stays all the same:
<nav>
<?php foreach($pages->visible() as $page): ?>
<li <?php e($page->isOpen(), ' class="active"') ?>>
// check for page "courses" and just echo the title
<?php if($page->uid() == 'courses'): ?>
<?php echo $page->title()->html() ?>
// for all other pages wrap a link around the title
<?php else: ?>
<a href="<?php echo $page->url() ?>"><?php echo $p->title()->html() ?></a>
<?php endif ?>
</li>
<?php endforeach ?>
</nav>
Hello Kirby!
I’m also new to this, but i’m loving your product!
Like Kurtg i need to make my projects link not link to the projects page, but be clickable and show the submenu on click and hover. I could do this with a standard HTML menu and jquery, but i like to think there is a Kirby way. When trying to do this with the examples above it didn’t work. I’m no pro, rather a beginner, so i grant the mistake is mine. In the meantime I’m using the redirect method, which is ok but not desirable.
The structure of my site is the following:
-Home
-Projects: 1, 2, 3,
-contact
(projects should just work as the button for the actual projects.)
I followed the directions from tobiasweh literally, and tried to adjust it to my own menu, but to no success.
To show the submenu on click, you need some javascript that listens for the click event. The only Kirby specific part is filtering the menu items to determine which item should behave in what manner (that has been explained above). The rest needs to be solved with CSS and JS.
I’m not quite sure what you want to achieve on clicking the parent item: Open the submenu or link to a subpage?
hi, this post is from 2015, and i have the same question. and as i read the solution is simple(not for me) so i assume this “simple” feature should be available from within the panel to set it easely, but i cannot find the setting. where is it?
There is no such setting. As explained above, there are multiple ways to go about this. One of these options would be an additional field in the blueprint for the page, that you can then query in your template.
So, this field needs to be added first, before you can use it.
i love kirby, but it’s hard to understand it for me.
which files do i need to add the function? or why isn’t it baked into kirby, as it seems for you an easy thing to implement? seems a lot of people want this feature. If not, which files and which code i need to add?
This I cannot tell you, because it depends on your content and template structure.
To use Kirby in any useful way, you do need to know the very basics, like what is a blueprint, template, snippet. How do I create a blueprint, add a field to it.
I’m sorry, but I cannot possibly repeat the documentation here in the forum.
You do need a certain willingness to learn to code, if you want to use Kirby effectively. Kirby is not WordPress, you will not find any possible setting available out of the box.