My layouts/home.htm has this :
<!-- Header -->
{% partial 'site/header' %}
<!-- Nav -->
{% partial 'site/nav-links' %}
<!-- Marquee -->
{% partial 'site/marquee' %}
partials/site/marquee.htm :
[collection announcements]
handle = "Announcement"
==
<?php
function onStart()
{
dd($this->announcements);
}
?>
==
<div>
code
</dob>
dd returns null even though I added content in the backend - even for other Tailors like events etc.
So a partial can’t have this ?
[collection announcements]
handle = "Announcement"
==
<?php
function onStart()
{
dd($this->announcements);
}
?>
==
How else do I have access
chris
#2
Hi @anjanesh
can you share more about your tailor blueprint ?
I got it solved (using Gemini) by placing this in the home.htm layout :
##
description = "Default layout"
[collection announcements]
handle = "Announcement"
==
And in themes/demo/partials/site/marquee.htm
==
<?php
function onStart()
{
if ($this->announcements)
{
$this['activeAnnouncements'] = $this->announcements
->where('is_active', true)
->orderBy('priority', 'asc')
->get();
}
else
{
$this['activeAnnouncements'] = collect([]);
}
$this['activeAnnouncements'] = $this->announcements;
}
?>
==
{% if activeAnnouncements|length > 0 %}
<code>
{% endif %}
It seems
[collection announcements]
handle = "Announcement"
can’t be placed in a partial like themes/demo/partials/site/marquee.htm ?
this is my announcement.yaml file :
uuid: xxx-xxx-xxx-xxx-xxx
handle: Announcement
type: structure
name: Announcement
drafts: false
fields:
message:
label: Announcement Message
type: text
placeholder: 'Announcement Message'
validation:
- required
is_active:
label: Active
type: switch
default: true
priority:
label: Display Order
type: number
default: 100
columns:
message:
label: Message
searchable: true
is_active:
label: Active
type: switch
navigation:
icon: icon-bullhorn
order: 700
My composer.json :
"require": {
"php": "^8.5.0",
"october/rain": "^4.0",
"laravel/framework": "^12.0",
"october/all": "^4.0"
},
I thought I was using October CMS 4.1