E
E
exedis2017-07-10 18:04:36
PHP
exedis, 2017-07-10 18:04:36

How to make interactive select in modx revo?

Hello, you need to make a drop-down list, the choice of its value depends on the loading of the next list, and so on. The lists themselves are loaded using pdoResources. I tried filtering and loading through jq, but nothing intelligible happened

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Andreev, 2017-07-10
@b0nn1e

Make a separate file like ajax.php
In which something like

<?php
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' || empty($_REQUEST['action'])) {exit();}
$action = $_REQUEST['action'];
define('MODX_API_MODE', true);
require dirname(__FILE__).'/index.php';
$modx->getService('error','error.modError');
$modx->getRequest();
$modx->setLogLevel(modX::LOG_LEVEL_ERROR);
$modx->setLogTarget('ECHO');
$modx->error->message = null;

switch ($action) {
  case 'select1':
    $output = $modx->runSnippet('pdoResources', array(....) );
  case 'select2':
    $output = $modx->runSnippet('pdoResources', array(....) );
  break;
}

@session_write_close();
exit(json_encode($output));

And a bunch of spaghetti code in JQ or vuejs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question