Replies: 1 comment 7 replies
-
I ran into that cryptic error recently, and fixed it in 3.3.66. That would have at least pointed to the truncate modifier faster.
Your screenshot looks like everything was being output correctly - you can tell by the italic and bold text mixed in, but you need some css to style it.
It only works on plain text. When you have bard configured with sets, it'll be an array, which was the error you were getting. You could have used the
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been following Jacks course on Laracasts and everything was going fine with the exception of the Bard field. I couldn't get it to render anything except plain text. I then realised I had broke something. As someone still trying to find their feet when it comes to developing... I checked the logs and seen this:
[2023-01-26 20:11:27] local.ERROR: Passed value cannot be an array {"userId":"7fca6675-5318-423a-9001-2b009693218d","exception":"[object] (Statamic\\Modifiers\\ModifierException(code: 0): Passed value cannot be an array at /Users/paul/Projects/ttg/vendor/statamic/cms/src/Modifiers/Modify.php:170) [stacktrace] #0 /Users/paul/Projects/ttg/vendor/statamic/cms/src/Modifiers/Modify.php(133): Statamic\\Modifiers\\Modify->modify('safe_truncate', Array) #1 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Language/Runtime/ModifierManager.php(119): Statamic\\Modifiers\\Modify->__call('safe_truncate', Array) #2 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Language/Runtime/Sandbox/Environment.php(1257): Statamic\\View\\Antlers\\Language\\Runtime\\ModifierManager::evaluate(Object(Statamic\\Fields\\Value), Object(Statamic\\View\\Antlers\\Language\\Runtime\\Sandbox\\Environment), Object(Statamic\\View\\Antlers\\Language\\Nodes\\Modifiers\\ModifierChainNode), Array) #3 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Language/Runtime/Sandbox/Environment.php(1278): Statamic\\View\\Antlers\\Language\\Runtime\\Sandbox\\Environment->applyModifiers(Object(Statamic\\Fields\\Value), Object(Statamic\\View\\Antlers\\Language\\Nodes\\Modifiers\\ModifierChainNode)) #4 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Language/Runtime/Sandbox/Environment.php(1515): Statamic\\View\\Antlers\\Language\\Runtime\\Sandbox\\Environment->adjustValue(Object(Statamic\\Fields\\Value), Object(Statamic\\View\\Antlers\\Language\\Nodes\\VariableNode)) #5 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Language/Runtime/Sandbox/Environment.php(923): Statamic\\View\\Antlers\\Language\\Runtime\\Sandbox\\Environment->getValue(Object(Statamic\\View\\Antlers\\Language\\Nodes\\VariableNode)) #6 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Language/Runtime/Sandbox/Environment.php(296): Statamic\\View\\Antlers\\Language\\Runtime\\Sandbox\\Environment->process(Array) #7 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Language/Runtime/Sandbox/Environment.php(321): Statamic\\View\\Antlers\\Language\\Runtime\\Sandbox\\Environment->processStatements(Array) #8 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Language/Runtime/NodeProcessor.php(1727): Statamic\\View\\Antlers\\Language\\Runtime\\Sandbox\\Environment->evaluate(Array) #9 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Language/Runtime/NodeProcessor.php(712): Statamic\\View\\Antlers\\Language\\Runtime\\NodeProcessor->reduce(Array) #10 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Language/Runtime/RuntimeParser.php(382): Statamic\\View\\Antlers\\Language\\Runtime\\NodeProcessor->render(Array) #11 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Language/Runtime/RuntimeParser.php(760): Statamic\\View\\Antlers\\Language\\Runtime\\RuntimeParser->renderText('<!-- article --...', Array) #12 /Users/paul/Projects/ttg/vendor/statamic/cms/src/View/Antlers/Engine.php(97): Statamic\\View\\Antlers\\Language\\Runtime\\RuntimeParser->parseView('/Users/paul/Pro...', '<!-- article --...', Array) #13 /Users/paul/Projects/ttg/vendor/laravel/framework/src/Illuminate/View/View.php(195): Statamic\\View\\Antlers\\Engine->get('/Users/paul/Pro...', Array) #14 /Users/paul/Projects/ttg/vendor/laravel/framework/src/Illuminate/View/View.php(178): Illuminate\\View\\View->getContents() #15 /Users/paul/Projects/ttg/vendor/laravel/framework/src/Illuminate/View/View.php(147): Illuminate\\View\\View->renderContents() #16 /Users/paul/Projects/ttg/vendor/statamic/cms/src/Tags/Partial.php(29): Illuminate\\View\\View->render() #17 /Users/paul/Projects/ttg/vendor/statamic/cms/src/Tags/Partial.php(13): Statamic\\Tags\\Partial->render('news/card') #18 /Users/paul/Projects/ttg/vendor/statamic/cms/src/Tags/Tags.php(138): Statamic\\Tags\\Partial->wildcard('news/card') #19 [internal function]: Statamic\\Tags\\Tags->__call('news/card', Array)
It had my head battered as everything was working fine. While it may be obvious to experienced developers... it took me a good hour to work out it was related to using truncate in a field which I had now turned into a bard field with options. So, as a quick workaround I changed {{ news_text }} to be {{ title }} and it worked. Obviousy it looks stupid... but it was just to get it working until I could ask for help. So I'm not out of the woods just yet.
The Bard field seems to be my Kryptonite and it would be great if someone is able to explain/help with the following:
Why was the news item only very limited formatting of text, even without preserving breaks:
Link to what it looks like in browser: https://ibb.co/p1RyD7z
Here's where I'm trying to display the field in my antlers file:
{{ news_content}} {{ if type == "text" }} {{ text }} {{ elseif type == "quote" }} <div class="quote-block"> “{{ quote }}” <div class="italic mt-4">‐ {{ author }}</div> </div> {{ elseif type == "related_articles" }} {{ related_entries }} <a class="" href="{{ url }}">{{ title }}</a> {{ /related_entries }} {{ /if }} {{ /news_content }}
Does safe_truncate not work with a bard field - or am I using it wrong?
Can anyone see anything I'm doing wrong which is causing the Bard field to not work as expected?
I have read the Statamic docs, but I thought I did everything it was asking - plus following Jack in the videos, the only thing I can think of is I missed something. If anyone is able to offer help/advise/solutions that would be great thank you.
Beta Was this translation helpful? Give feedback.
All reactions