Craft\Exception

Variables passed to the sortByField filter are not entries

/home/pacsystem/sitac.org/craft/plugins/sortbyfield/twigextensions/SortByFieldTwigExtension.php(29)

17         );
18     }
19 
20     /**
21      * The "sortByField" filter sorts an array of entries by the specified field's value
22      *
23      * Usage: {% for entry in craft.entries|sortByField('ordering', 'desc') %}
24      */
25     public function sortByFieldFilter($content, $sort_by = null, $direction = 'asc') {
26         if(!is_array($content)) {
27             throw new Exception(Craft::t('Variable passed to the sortByField filter is not an array'));
28         } elseif(!(isset($content[0]) && is_object($content[0]) && (get_class($content[0]) === 'Craft\EntryModel' || get_class($content[0]) === 'Craft\Commerce_ProductModel') )) {
29             throw new Exception(Craft::t('Variables passed to the sortByField filter are not entries'));
30         } elseif($sort_by === null) {
31             throw new Exception(Craft::t('No sort by parameter passed to the sortByField filter'));
32         } elseif(!$content[0]->__isset($sort_by)) {
33             throw new Exception(Craft::t('Entries passed to the sortByField filter do not have the field "' . $sort_by . '"'));
34         } else {
35             // Unfortunately have to suppress warnings here due to __get function
36             // causing usort to think that the array has been modified:
37             // usort(): Array was modified by the user comparison function
38             @usort($content, function ($a, $b) use($sort_by, $direction) {
39                 $flip = ($direction === 'desc') ? -1 : 1;
40                 $a_sort_value = $a->__get($sort_by);
41                 $b_sort_value = $b->__get($sort_by);

Stack Trace

#0
+
 /home/pacsystem/sitac.org/craft/storage/runtime/compiled_templates/45/45627400b8bd527d52a4879c308d11a90a181ba4a9896ac6dcbe08fe47fcefbf.php(143): Craft\SortByFieldTwigExtension->sortByFieldFilter(array(), "relatedCycle", "asc")
138 \t\t\t\t<div class=\"dates-nodo\">
139 \t\t\t\t\t
140 \t\t\t\t\t";
141         // line 56
142         $context['_parent'] = $context;
143         $context['_seq'] = twig_ensure_traversable($this->env->getExtension('Craft\SortByFieldTwigExtension')->sortByFieldFilter(($context["entries"] ?? $this->getContext($context, "entries")), "relatedCycle", "asc"));
144         foreach ($context['_seq'] as $context["_key"] => $context["entry"]) {
145             // line 57
146             echo "\t\t\t\t\t
147 \t\t\t\t\t<div class=\"post-nodo\">
148 \t\t\t\t\t    <div class=\"padding-left-1\">
#1
+
 /home/pacsystem/sitac.org/craft/app/vendor/twig/twig/src/Template.php(217): __TwigTemplate_a639b3d41eeadf3b3784b1d77b846dddc5540525ce3a993f4264e805cb963f3c->block_content(array("entry" => Craft\EntryModel, "user" => null, "currentUser" => null, "craft" => Craft\CraftVariable, ...), array("content" => array(__TwigTemplate_a639b3d41eeadf3b3784b1d77b846dddc5540525ce3a993f4264e805cb963f3c, "block_content")))
212             throw new \LogicException('A block must be a method on a \Twig\Template instance.');
213         }
214 
215         if (null !== $template) {
216             try {
217                 $template->$block($context, $blocks);
218             } catch (Error $e) {
219                 if (!$e->getSourceContext()) {
220                     $e->setSourceContext($template->getSourceContext());
221                 }
222 
#2
+
 /home/pacsystem/sitac.org/craft/storage/runtime/compiled_templates/4a/4a14fce1608c1fd03aa5d7c05e3007934fd47c075abf204a0ea74b10cc73629b.php(94): Twig\Template->displayBlock("content", array("entry" => Craft\EntryModel, "user" => null, "currentUser" => null, "craft" => Craft\CraftVariable, ...), array("content" => array(__TwigTemplate_a639b3d41eeadf3b3784b1d77b846dddc5540525ce3a993f4264e805cb963f3c, "block_content")))
89 \t\t</div>
90 \t</header>
91 \t
92 \t";
93         // line 53
94         $this->displayBlock('content', $context, $blocks);
95         // line 56
96         echo "
97 \t<div class=\"blockNewsletter\">
98 \t\t<div class=\"formNewsletter\">
99 \t\t\t<form class=\"flex full-width flex_space-around flex_col\" action=\"\" method=\"POST\">
2024-03-29 02:13:32 Apache / Craft CMS 2.9.2