We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42562
    • 1,145 Posts
    DEMO check out TinyJSONGallery http://modx.com/extras/package/tinymcewrapper
    Which transforms any chunk into a powerful gallery. And now with the bellow, it will be able to transform any Resource into a gallery - galleries attached to each Resource - awesome!

    TUTORIAL
    You have seen that cute resource/element tree in MODX right?
    Ever wondered how to create simple Manager Resources that are viewable within the tree? fully customizable and viewable only by your inmates? And enjoying the benefits of resource groups and that fantastic MODX permissions?

    Oh wait, I guess your quest got dampered when you heard of CMP, SCHEMA, xPDO, xPIDIDY, XML, CLASS files etc etc etc and ExtJSSSSSigh!!!

    WHEN ALL I WANTED WAS A BLASTED IFRAME WITHIN A PAGE IN THE MANAGER THAT HAD A LINK IN THE RESOURCE TREE
    or
    A CHATROOM, in-house DOCUMENTATION, EMPLOYEE DATABASE LIST

    1. Use any resources - choose your pattern - how would I segregate the resources I need to be purely Managerial?
    a. custom class_key is a nice option, but NOT AT ALL ...the tutorial on that little fella is 14 pages long
    if resource has this class_key...$jQuery.transformPAGE()

    b. template is fine also
    if resource has this template ...$jQuery.transformPAGE()

    c. using resource id to target resources is a DUHyal waste of time, period

    d. pagetitle suffix is highly effective ... you could do a PHP match...
    if pagetitle contains $suffix, $jQuery.transformPAGE()
    or //to target all children
    if parent pagetitle contains $suffix, $jQuery.transformPAGE()

    e. use TV (hidden or not) http://bobsguides.com/blog.html/2014/04/09/get-tv-values-the-fast-way/
    depends on your project ...
    if this TV has a value via this resource, $jQuery.transformPAGE()


    2. The Plugin: You are asking, where to put all my code into?
    It takes half a second to create a Plugin in MODX ... enuf sed!
    Start with this...
    if ($modx->event->name == 'OnDocFormPrerender') {
    
       // insert above quick logic to segregate resources to become Manager Pages
       // use whatever language you want, ExtJS, jQuery to build your page or alter an existing one
    
    }
    


    Here is a quick ExtJS to create a tab and content from which you may target.parent().parent().etc() and do other weird stuff.
    $modx->regClientStartupHTMLBlock('
            <script type="text/javascript">
            Ext.onReady(function() {
              var newPanel = new MODx.Panel({
                  title: "Image Gallery",
                  id: "my_Custom_ManagerResource",
                  width: "100%",
                  items: [{
                    html: "<div class=coolStuffs style=resize:vertical;width:99%;height:auto;> stuff and beans</div>"
                  }]
              });
              var tabs = Ext.getCmp("modx-resource-tabs");
              tabs.insert(0,newPanel); // this will ensure your tab comes first
              tabs.setActiveTab(newPanel); // you may thank digitalpenguin (murray) for this little fiery magic
            });
        </script>');
    $modx->regClientStartupHTMLBlock("<script src='jQuery.js'></script>");
    $modx->regClientStartupHTMLBlock("<script src='coolStuffs.js'></script>");


    3. you are done ... go ahead now and place a link in your Manager top bar, dashboard etc, hide the resource from the resource tree so that clients don't meddle with it.

    Cheers,
    what's in a name?
      TinymceWrapper: Complete back/frontend content solution.
      Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
      5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
      • 3749
      • 24,544 Posts
      Love the subject. smiley

      BTW, if the plugin is only attached to OnDocFormPrerender, this 'if' statement is unnecessary:

      if ($modx->event->name == 'OnDocFormPrerender') {
      }
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting