We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I’ve tried a variety of ways to add templates and TVs to a package and have them end up in a category. Nothing seems to work.

    I tried adding them to the category (this works fine with snippets, plugins, and chunks) with addMany() and the standard attributes array with Children. For Templates, they get added fine, the category saves fine, they end up in the tree -- but uncategorized.

    I’m using
    xPDOTransport::UNIQUE_KEY => 'templatename'
    , which seems right to me.

    With TVs, I can’t even get the build script to run:

    [2011-02-02 22:25:22] (ERROR) No foreign key definition for parentClass: modTemplate using relation alias: modTemplateVar


    With the templates, I’ve tried setting the category in a script resolver. I tried adding the category to each template with addOne(), adding the templates to the category with addMany(), and setting the ID of the category directly with $template->set(’category’,$id) amd $template->set(’category’,’CategoryName’);
    .
    This code fails to get the category in the script resolver:

    $categoryObj = $object->xpdo->getObject('modCategory', array ('category'=>$category));


    The category exists (I created it in the build script and it shows in the tree -- all the snippets, chunks, and plugins are categorized under it) and I have it spelled correctly.

    Has anyone actually added templates and/or TVs to a category in a transport package -- am I doing something wrong?
      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
      • 34120
      • 236 Posts
      Quote from: BobRay at Feb 02, 2011, 11:24 PM

      Has anyone actually added templates and/or TVs to a category in a transport package -- am I doing something wrong?
      I have but I’d struggle to tell you how exactly, I followed the same process as for snippets and chunk etc.

      $modx->log(modX::LOG_LEVEL_INFO,'Packaging in templates...');
      $templates = include $sources['data'].'transport.templates.php';
      if (!is_array($templates)) $modx->log(modX::LOG_LEVEL_ERROR,'Could not package in templates.');
      $category->addMany($templates);


      Not sure if that will be any help.
        • 3749
        • 24,544 Posts
        Thanks. I’m afraid that’s what I’ve been trying, with no success.
          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
          • 34120
          • 236 Posts
          Don’t know if any of this is relevant but I’m using:
          xPDOTransport::UNIQUE_KEY => 'category'

          And for the snippets etc.
          xPDOTransport::UNIQUE_KEY => 'name',

          There’s no unique key for my templates.

          Out of my depth really but thought I’d try and help smiley
            • 3749
            • 24,544 Posts
            The problem turned out to be some left-over code from a while back, way at the bottom of my build script, that installed the elements for a second time (which apparently de-categorized them).
              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