Creating multiple TVs with custom input/output rendering

There’s another issue i’m trying resolve right now. I created a custom TV for multiple file upload, with a custom responsive template (based on jQueryUI Touch), both for backend an frontend usage (this is for a musical college, you know, so forcing madam-content-manager to fight MIGX from backend just to drop some docs/pics on page seemed bad idea). Everything’s fine, yet one thing makes me wonder. I registered a namespace, yes, created a pathing plugin, created input and output controllers, wrote a UI template for dropping-naming-sorting-uploading files, producing JSON to store it in hard-coded invisible field, tied to controllers with tv{$tv->id}, tv{$tv->value}. Success! But now i want another custom TV UI element and just don’t get how to separate them from each other. Links to controllers are hard-coded in pathing plugin, tied to same events. All i have unique here of each TV is then tv{$tv->id} value sticked into template. Is that so? Should i struggle to code all custom UI elements in one template file, selecting them to render as needed, by id, or there’s something i missed? What is the exact mechanics of process? Found some “how to” guides for simplest cases (including the one in official MODX docs), but lack explaination. Tried to reverse-engineer MIGX, however, it’s still beyond my dev level.

And another one… There’s a line in official MODX Docs:
”The pathing plugin will not be required in MODX 2.3; the Namespace will handle all the pathing. This is why we told you earlier to make the Namespace.”

It’s 2.8.3 here, but still doesn’t seem the case. Or maybe i’m missing something here again?

Quite new in all this stuff, so i’m sorry if asking something obvious.

What exactly are you trying to do? Could this be achieved by just creating a second custom TV in another namespace or does it have to be in the same custom TV?

I’m trying to reder two custom input elements for two different TVs on one page in one category. What do i do:

  1. Create a folder structure like this:
  2. Create a namespace reffering to this structure (also on previuos screenshot).
  3. Create pathing plugin to catch events, to add input and output renderig options to appropriate lists on editing TV and to load a custom template for that TV whet editing document:
  4. Create input controllers to pick a template file:
  5. Create appropriate template files for custom controls:
  6. Create new TVs, set them to appear in right templete in common categoty:

  7. Chose an appropriate input and output type for them (those as if i get ir right follow the names of createl controllers on step 4:

As you may see on screenshots, there are three different templates. But when it comes to editing document, all 3 of them are rendered using the same template (the first one), however, the TV IDs are different:

The file structure looks ok.

What is the content of the files core/components/customtvs/tv/input/picbox.class.php and core/components/customtvs/tv/input/customform.class.php?

My guess is, that you kept the class name “TemplateSelectInputRender” and didn’t change it to a unique class name (e.g. “PicboxInputRender”).

<?php
if(!class_exists('PicboxInputRender')) {
    class PicboxInputRender extends modTemplateVarInputRender {
        public function getTemplate() {
            return $this->modx->getOption('core_path').'components/customtvs/tv/input/tpl/picbox.htm';
        }
        public function process($value,array $params = array()) {
        }
    }
}
return 'PicboxInputRender';

Well, your guess was perfectly accurate! Changed classnames to unique ones, everything works fine now. Except some var name and event handling clashes in javascript, but thats quite reasonable, as far as all template code finally share the same DOM, i guess…

Thank you!