Hello all,
I’ve just modified a page blueprint to include phone number and email contact details.
The page blueprint looks like this:
title: Services
icon: star
image:
query: false
back: black
options:
changeStatus: true
changeTemplate: true
delete: false
columns:
main:
width: 2/3
fields:
description:
label: Description (meta)
type: text
navigation:
label: Navigation label
type: text
heading:
label: Heading (H1)
type: textarea
intro:
label: Intro
type: textarea
phone:
label: Phone Number
type: tel
required: false
width: 1/2
email:
label: Email Address
type: email
required: false
width: 1/2
servicesoptions:
label: Services Modules
type: structure
columns:
title:
width: 1/4
text:
width: 3/4
fields:
title:
label: Title
type: text
icon:
label: Icon
type: files
text:
label: Text
type: textarea
url:
label: Url
type: text
required: false
linktext:
label: Link Text
type: text
required: false
text:
label: Supplemental text
type: textarea
size: large
sidebar:
width: 1/3
sections:
files:
headline: Files
type: files
image:
back: white
The new fields items are ‘Phone Number’ and ‘Email Address’.
I’ve added the following code into my template:
<?php if ($item->phone()->isNotEmpty()): ?>
<div class="plate-contact">
<a href="tel:<?= Str::slug($item->phone()->html()) ?>" class="btn"><?= $item->phone()->html() ?></a>
<?php endif ?>
<?php if ($item->email()->isNotEmpty()): ?>
<a href="mailto:<?= $item->email()->html() ?>" class="btn"><?= $item->email()->html() ?></a>
<?php endif ?>
</div>
However, I’m getting an ‘Undefined variable $item’ error when I go to the page.
What’s particularly puzzling is that exactly the same template code works on one of my other pages, the only difference is that the phone number and email addresses are included in the blueprint as part of a structure field.
Can someone tell me what’s causing the error?