Open Dimchao opened 11 months ago
Thats strange. Are you sure external_links is the handle?
What do you get if you try \Statamic\Facades\Entry::whereCollection('external_links')
?
That works beautifully!
Yeah, it is a weird bug and I have tried SO many ways of trying to understand what either I was doing wrong, or if my settings/yaml files were corrupted.
I have been wracking my brain over this.
As an aside: A lot of the docs mention that you can do something... but don't actually say how, or it's too cryptic to understand unless you probably made Statamic. It took me several days before I gave up on trying to extend Bard functionality. Another two before I understood that I should work around the Markdown and go straight to CommonMark extensions.
I am mostly working with Blade since this is my first Stamic site and I prefer working with nuts and bolts of Laravel. It's been a bear to say the least. That said, Statamic is freaking incredible! I just wish it was easier to work with as a beginning learning it.
Real examples would help immensly in the documentation. That's why I mentioned CommonMark above. They gave a real world example immediately unlocked understanding.
Sorry... needed to vent. Two days behind on the project now because of the lack of documentation. But seriously, incredible CMS.
Ouch, sorry to hear that.
There is a very active discord channel you can hop into and ask questions. Also do raise issues on the docs repo to highlight what you think could be better, I'm sure the core team would appreciate the feedback.
@ryanmitchell Yeah, I've thought of raising issues on the docs. It's just system wide and I've needed to focus on this project (launch is next week). Not to mention, the CMS is so good. I didn't want anything I said come across like $^!%ing on someone else's baby. It just needs real world examples in the docs...
An example from the Statamic Markdown (i.e. not helpful documentation):
You may customize the behavior of the markdown parser by providing a CommonMark config array in config/statamic/markdown.php. All the available options are outlined in the CommonMark docs. You can override the base options as well as any extension’s options.
You only need to provide the specific options you want to override. For example:
'configs' => [
'default' => [
'allow_unsafe_links' => false,
'heading_permalink' => [
'symbol' => '#',
],
]
]
This is not any more useful than looking at the config file itself. It wasn't until I spent about 10 hours in a full code deepdive and dd
'ing everything I could to understand that when you want to extend the Markdown as provided in the docs:
Markdown::extend('special', function ($parser) {
return $parser
->withStatamicDefaults()
->addExtensions(...);
});
'special'
is the actual named parser which you then need to name and set specifically in the config file and that to mess with the parameters of the commonmark markdown packaged with Statamic, you need to denote that in its own place in the configs as well...
'configs' => [
'default' => [
'allow_unsafe_links' => false,
'heading_permalink' => [
'symbol' => '#',
],
],
'special' => [
'configuration_value_1' => 'allow_all',
'configuration_value_2' => 'jump_when_found',
],
]
Then of course you'll have no way of extending through Statamic without CommonMark's default's which will abort all markup if there are any html tags included in your passed string. Gah! ANyways... I've built what I needed now (markup to pull in values from Statamic's globals and any values from config files). I was surprised this wasn't a feature already.
Clearly needed to vent... :)
Are the entries in your external_links
collection all drafts?
@jasonvarga everything is published. Just double checked too.
Can you share content/collections/external_links.yaml
?
@jasonvarga
title: 'External Links'
template: default
revisions: false
sort_dir: asc
date_behavior:
past: public
future: private
preview_targets:
-
label: Entry
url: '{permalink}'
refresh: true
Seems fine. 🤔
Can you share a couple of the external_links entry md files?
@jasonvarga This is directly from my files, but I did need to redact the URL's
---
id: 37a55890-dea9-427a-a3f9-2199a1d3c372
blueprint: link
title: 'Volunteer Signup Form'
redirect: 'https://forms.office.com/Pages/ResponsePage.aspx?id=redacted'
route_name: external.volunteer-signup
updated_by: 2
updated_at: 1691394968
---
---
id: 4cdf1149-7cd7-43d8-acdc-c237ff3a7c12
blueprint: link
title: Instagram
redirect: 'https://www.instagram.com/'
route_name: external.instagram
updated_by: 2
updated_at: 1691637887
---
---
id: dc89df49-b3a4-4774-ac21-0a6bfdef8424
blueprint: link
title: Facebook
redirect: 'https://www.facebook.com/'
route_name: external.facebook
updated_by: 2
updated_at: 1691637940
---
Ah there we go. Redirects are filtered out by the tag by default.
Try adding that parameter:
$externalLinks = Statamic::tag('collection:external_links')
+ ->redirects(true)
->fetch();
@jasonvarga gotcha... so how can I make an entry and just have the URL be what I set it to be, internal or external? Or, is that not possible and I need to use redirects? I honselty had no idea how this was even set. Still learning Statamic by reading as much as I can and dd
ing everything I can to try and figure it out.
I've been trying to figure out a way to allow my client to register whatever external links they need, so I can run the scripts and templates I need to manage their site. I still find great use using the laravel routing system for a variety of reasons.
Much appreciated for the assist.
Bug description
I have two Collections created: 1) pages; 2) external_links. The 'pages' collection contains all of page Entries of my site, which includes a route_name field. The external_links collection hold Entries that just have URL values associated with them, plus labels and a rount_name field for using Laravel's named routing system.
In my web/routes.php, I call to grab these collections using the
Statamic:tag
method. When I useStatamic::tag('collection:pages')->fetch()
I receive all of the active pages on the site as expected. However, I receive nothing when I useStatamic::tag('collection:external_links')->fetch()
. I cannot for the life of me figure out why this is the case.How to reproduce
resources/blueprints
directories, have a single yaml file for each collection (outlined below).web/routes.php
file, write the code (outlined below).resources/blueprints/pages/page.yaml
resources/blueprints/external_links/link.yaml
routes/web.php
Logs
Environment
Installation
Other (please explain)
Antlers Parser
None
Additional details
I install Statamic through your documentation for docker. Which technically mean I installed Laravel first and then Statamic on top of it?