Like this? I tried it but the text disappeared completely.
<div class="legal-text">
<h1><?php echo $page->bigheadline(); ?></h1>
<h2><?php echo $page->headline(); ?></h2>
<p><?= $page->text()->kirbytext() ?></p>
</div>
Like this? I tried it but the text disappeared completely.
<div class="legal-text">
<h1><?php echo $page->bigheadline(); ?></h1>
<h2><?php echo $page->headline(); ?></h2>
<p><?= $page->text()->kirbytext() ?></p>
</div>
Without the p tags, as these are created by the kirbytext()
method.
And your field is not called text, but textfeld
. You have to use the field names as defined in your blueprint.
Many thanks indeed. It worked very well. Here is how the code looks now:
<div class="legal-text">
<h1><?php echo $page->bigheadline(); ?></h1>
<?= $page->headline()->kirbytext() ?>
<?= $page->textfeld()->kirbytext() ?>
</div>
Inside the templates folder, I created a text.php template which is supposed to act as a template for the Impressum page and the About us pages.
In the Blueprints folder there is a folder called pages and inside this pages folder, there a text.yml file with the following values:
title: Text
preset: page
num: zero
status:
draft: true
listed: true
fields:
Bigheadline:
label: Bigheadline
type: textarea
Headline:
label: Headline
type: textarea
Textfeld:
label: Textfeld
type: textarea
In the text folder, there is text.txt file. When I created the about and Impressum pages in the Kirby panel, a new folder appeared inside the text folder. Attached is a screenshot. As we can see, the text folder has a 0_about folder and 0_impressum folder. Inside each of these two folders, lives a text.txt file. I have attached some screenshots from the folder structure as shown inside VS Code and the Kirby panel.
The URL shows mypage.com/text.about. I would like to know if I can just have mypage.com/about and how this can be achieved.
This is folder structure from VS Code
Hello,
I included an image dynamically using this code: <img src="<?php echo $page->images()->first()->url(); ?>">
The previous static page code looked like this:
<a href="images/soap-green.png"><!-- 2400x1600 -->
<img src="images/soap-green.png" id="box" class="zoom"><!--466x267-->
In the static version of the page, I was able to hover over the image and the jQuery magnifying glass will work. However, since I used this code: the magnifying glass no longer functions.
The code for the magnifying glass is stored in the footer.php file which lives in the snippets folder.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="/assets/js/jquery.magnify.js"></script>
<script src="/assets/js/jquery.magnify-mobile.js"></script>
<script>
$(document).ready(function() {
$('.zoom').magnify();
});
</script>
Hi,
I’m trying to make a dynamic menu out of this HTML:
<nav class="desktop-navigation">
<ul>
<li>
<a href="#">Products</a>
<ul class="dropdown">
<li><a href="#">Detergents</a></li>
<li><a href="#">Soaps</a></li>
<li><a href="#">Bathroom</a></li>
</ul>
</li>
<li><a href="#">Who we are</a></li>
<li><a href="#">Marketing</a></li>
<li><a href="#">Kontakt</a></li>
</ul>
<img src="/kirby/assets/svg/logo.svg" class="object-contain object-center w-full h-full"
alt="logo">
</nav>
I grabbed the following code from the Kirby starter kit and applied it as follows but it did not work properly.
<nav class="desktop-navigation">
<ul>
<li>
<a href="#">Products</a>
<ul class="dropdown">
<?php foreach ($site->children()->listed() as $item): ?>
<a <?php e($item->isOpen(), 'aria-current="page"') ?> href="<?= $item->url() ?>"><?= $item->title()->esc() ?></a>
<?php endforeach ?>
</ul>
</li>
<?php foreach ($site->children()->listed() as $item): ?>
<a <?php e($item->isOpen(), 'aria-current="page"') ?> href="<?= $item->url() ?>"><?= $item->title()->esc() ?></a>
<?php endforeach ?>
</ul>
<img src="/kirby/assets/svg/logo.svg" class="object-contain object-center w-full h-full"
alt="logo">
</nav>
I appreciate your help.
You can find different types of menus here:
Thank you, but since my PHP knowledge is limited, I don’t know how to put the code in the correct manner. This is how I put it and the menu items disappeared:
<!-- ======= Desktop Navigation ======= -->
<div class="container">
<nav class="desktop-navigation">
<ul>
<li>
<a href="#">Products</a>
<ul class="dropdown">
<li><a href="#">Detergents</a></li>
<li><a href="#">Soap</a></li>
<li><a href="#">Other products</a></li>
</ul>
</li>
<?php
// main menu items
$items = $pages->listed();
// only show the menu if items are available
if($items->isNotEmpty()):
?>
<nav>
<ul>
<?php foreach($items as $item): ?>
<li><a<?php e($item->isOpen(), ' class="active"') ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a></li>
<?php endforeach ?>
</ul>
</nav>
<?php endif ?>
</nav>
</div>
Well, what you probably want is this example, so you just need to copy/paste it into your template (as a replacement for your hard-coded one, not additionally):
BTW if you have new questions unrelated to the previous question, please always create a new topic. Thank you.
Thank you, noted.
Hi,
I applied the code you provided as follows and the menu disappeared completely for some reason:
<?php
// nested menu
$items = $pages->listed();
// only show the menu if items are available
if ($items->isNotEmpty()):
?>
<div class="container">
<nav class="desktop-navigation">
<ul>
<?php foreach ($items as $item): ?>
<li>
<a<?php e($item->isOpen(), ' class="active"') ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a>
<?php
// get all children for the current menu item
$children = $item->children()->listed();
// display the submenu if children are available
if ($children->isNotEmpty()):
?>
<ul class="dropdown">
<?php foreach ($children as $child): ?>
<li><a<?php e($child->isOpen(), ' class="active"') ?> href="<?= $child->url() ?>"><?= $child->title()->html() ?></a></li>
<?php endforeach ?>
</ul>
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
<img src="/kirby/assets/svg/logo.svg" class="object-contain object-center w-full h-full" alt="logo">
</nav>
</div>
<?php endif ?>
Maybe you have no listed
pages (prepended number or date), then you have to adapt the code accordingly. Please read the guide or watch the introductory videos on YouTube to learn the basics.
Having said that, making pages you want to appear in the menu listed makes it easier to separate them from those you don’t want in the menu (like the error and home page, for example)
A post was split to a new topic: Exclude home page in breadcrumb
Hi,
I’ve a template that lives inside the templates folder. The name of this template is product.php.
This code <a class="button-two" href=""><?php echo $page->mehr(); $pageUrl;?> </a>
will output the text “Mehr dazu”. However, I want the visitor to be able to be taken to the kontakt page when they click on the Mehr dazu button To achive this I wrote: <?php $pageUrl = 'kontakt'; ?>
However, it is not taking me to the kontakt page.