[[+content_image]]
M
M
mbhusty2020-01-16 17:25:31
MODX
mbhusty, 2020-01-16 17:25:31

How to display your placeholders in AdvSearch results?

Calling up a search results snippet on a page

[[!AdvSearch?
      &queryHook=`testHook`
      &fields=`id,name,active,description`
      &withFields=`id,name,active,description`
      &init=`all`
      ]]

in testHook I write the following
$main = array(
  'package' => 'links',
  'packagePath' => '{core_path}components/links/model/',
  'class' => 'LinksItem',
  'fields' => 'id,name,active,description', // displayed
  'withFields' => 'name,active,description', // where we do the search
);

// set the query hook declaration
$qhDeclaration = array(
  'qhVersion' => '1.3',       // version of queryHook - to manage futures changes
  'main' => $main,
);

/** @var TYPE_NAME $hook */
$hook->setQueryHook($qhDeclaration);
return true;

in result output chunk
[[+advsearch.id]]
[[+advsearch.name]]
[[+advsearch.description]]

The advsearch doc - https://devpastet.ru/dokumentacziya/modx-revo/snip...
says Available placeholders - fieldName Any field value specified in the fields parameter.
As a result, only the resource id is displayed, there is no other data.
How to display the values ​​of other fields?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
M
mbhusty, 2020-01-23
@mbhusty

It was enough to change
to
and add tablePrefix, because my table prefix is ​​different from modx

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question