We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19534
    • 183 Posts
    Hey!

    I’m currently working on an Extra which adds some HTML to the update-resource page in the manager:



    Untill now the HTML was quite simple and it was generated with in the plugin code which listens to the OnDocFormPrerender event.
    But now I’d like to add some features which will make the HTML a little bit more complex. I really hate to write HTML code within my PHP code.
    So I thought of using a (file-based) chunk to do this. With code something like this:
    <?php
    $myPlaceholders = array (.....);
    $f = $this->config['chunksPath'].strtolower($name).$suffix;
    if (file_exists($f)) {
    	$o = file_get_contents($f);
    	$chunk = $this->modx->newObject('modChunk');
    	$chunk->set('name',$name);
    	$chunk->setContent($o);
    }
    $chunk->setCacheable(false);
    $myHTML = $chunk->process($myPlaceholders)
    


    Normaly I place my chunks (which are all used in the frontend, not in the manager) into /core/components/myExtra/elements/chunks
    I thought of placing the chunks which I will use for the manager to /core/components/myExtra/elements/chunks/mgr ....

    Normally I always look at Shaun’s extras, because I really like his coding style and he is a member of the core developer team. But I didn’t find an example which for this issue...

    I really want to apply the "MODx best practice" to all my MODx contributions... So how do you handle things like this?
    Do you use chunks in the manager?
    Or do you use Smarty templates?
    Or even some other stuff??

    Remember: I’m not building a custom manager page. I need to generate some HTML which then is passed to the $modx->event->output() method...

    Cheers,
    Jakob
      Add-On to easily manage your multilingual sites: Babel