We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29597 ☆ A M B ☆
    • 350 Posts
    I currently have two issues with my flexibility package.
    I'm trying to create several categories in the build script and assigning several snippet, chunks and TV's to them.

    The errors I get during package install:


    Script resolver actions completed
    Could not find TV: footer_box_01 to associate to Templates.
    Could not find TV: footer_box_02 to associate to Templates.
    Could not find TV: footer_box_03 to associate to Templates.
    Could not find TV: footer_box_04 to associate to Templates.
    Could not find TV: page_box_01 to associate to Templates.
    Could not find TV: page_box_02 to associate to Templates.
    Could not find TV: page_box_03 to associate to Templates.
    Could not find TV: page_box_04 to associate to Templates.
    Could not find TV: page_lightbox to associate to Templates.
    Could not find TV: sidebar to associate to Templates.
    Could not find TV: optional_contactform to associate to Templates.
    Could not find TV: optional_gallery to associate to Templates.
    Could not find TV: optional_slider to associate to Templates.
    Could not find TV: page_boxes to associate to Templates.
    Could not find TV: email_adress to associate to Templates.
    Could not find TV: FooterBoxNumber to associate to Templates.
    Could not find TV: siteLogo to associate to Templates.
    Could not find TV: footer_box_01 to associate to Templates.
    Could not find TV: footer_box_02 to associate to Templates.
    Could not find TV: footer_box_03 to associate to Templates.
    Could not find TV: footer_box_04 to associate to Templates.
    Could not find TV: page_box_01 to associate to Templates.
    Could not find TV: page_box_02 to associate to Templates.
    Could not find TV: page_box_03 to associate to Templates.
    Could not find TV: page_box_04 to associate to Templates.
    Could not find TV: page_lightbox to associate to Templates.
    Could not find TV: sidebar to associate to Templates.
    Could not find TV: optional_contactform to associate to Templates.
    Could not find TV: optional_gallery to associate to Templates.
    Could not find TV: optional_slider to associate to Templates.
    Could not find TV: page_boxes to associate to Templates.
    Could not find TV: email_adress to associate to Templates.
    Could not find TV: FooterBoxNumber to associate to Templates.
    Could not find TV: siteLogo to associate to Templates.
    Could not find TV: multiItemsGrid to associate to Templates.

    To add the categories I have:
    $category = $modx->newObject('modCategory');
    $category->set('id',1);
    $category->set('category', 'Flexibility');
    
    $category2 = $modx->newObject('modCategory');
    $category2->set('id',2);
    $category2->set('category', 'Site options');
    
    $category3 = $modx->newObject('modCategory');
    $category3->set('id',3);
    $category3->set('category', 'Page options');
    
    $category4 = $modx->newObject('modCategory');
    $category4->set('id',4);
    $category4->set('category', 'Footer');
    
    $category5 = $modx->newObject('modCategory');
    $category5->set('id',5);
    $category5->set('category', 'Footer content');
    
    $category6 = $modx->newObject('modCategory');
    $category6->set('id',6);
    $category6->set('category', 'Page content');
    
    $category7 = $modx->newObject('modCategory');
    $category7->set('id',7);
    $category7->set('category', 'Template');
    


    To assing TV's to the categories I have:
    /* add tvs */
    $tvs1 = include $sources['data'].'transport.tvs1.php';
    if (is_array($tvs1)) {
        $category2->addMany($tvs1,'TemplateVars');
    }
    
    $tvs2 = include $sources['data'].'transport.tvs2.php';
    if (is_array($tvs2)) {
        $category3->addMany($tvs2,'TemplateVars');
    }
    
    $tvs4 = include $sources['data'].'transport.tvs4.php';
    if (is_array($tvs4)) {
        $category5->addMany($tvs4,'TemplateVars');
    }
    
    $tvs5 = include $sources['data'].'transport.tvs5.php';
    if (is_array($tvs5)) {
        $category6->addMany($tvs5,'TemplateVars');
    }
    


    Each include transport.tvs2.php has code like this:
    $tvs2 = array();
    
    $tvs2[11]= $modx->newObject('modTemplateVar');
    $tvs2[11]->fromArray(array(
        'id' => 11,
        'name' => 'optional_contactform',
        'caption' => 'Contactform',
        'description' => 'Do you want a contactform on this page?',
    	'category' => 'Page options',
        'type' => 'option',
    	'elements' => 'yes==yes||no==no',
        'display' => 'default',
        'locked' => 0,
        'rank' => 4,
        'default_text' => 'no',
        'display_params' => '',
    	'properties' => array(),
    ),'',true,true);
    
    $tvs2[12]= $modx->newObject('modTemplateVar');
    $tvs2[12]->fromArray(array(
        'id' => 12,
        'name' => 'optional_gallery',
        'caption' => 'Gallery',
        'description' => 'Do you want a picture gallery on this page?',
    	'category' => 'Page options',
        'type' => 'option',
    	'elements' => 'yes==yes||no==no',
        'display' => 'default',
        'locked' => 0,
        'rank' => 3,
        'default_text' => 'no',
        'display_params' => '',
    	'properties' => array(),
    ),'',true,true);
    
    $tvs2[13]= $modx->newObject('modTemplateVar');
    $tvs2[13]->fromArray(array(
        'id' => 13,
        'name' => 'optional_slider',
        'caption' => 'Slider',
        'description' => 'Do you want a slider on this page?',
    	'category' => 'Page options',
        'type' => 'option',
    	'elements' => 'yes==yes||no==no',
        'display' => 'default',
        'locked' => 0,
        'rank' => 2,
        'default_text' => 'no',
        'display_params' => '',
    	'properties' => array(),
    ),'',true,true);
    
    $tvs2[19]= $modx->newObject('modTemplateVar');
    $tvs2[19]->fromArray(array(
        'id' => 19,
        'name' => 'page_boxes',
        'caption' => 'Sub-content boxes',
        'description' => 'How many sub-content boxes do you want on this page?',
    	'category' => 'Page options',
        'type' => 'option',
    	'elements' => '0==0||2==2||3==3||4==4',
        'display' => 'default',
        'locked' => 0,
        'rank' => 1,
        'default_text' => '0',
        'display_params' => '',
    	'properties' => array(),
    ),'',true,true);
    
    return $tvs2;
    


    What am I doing wrong?
    [ed. note: ThaClown last edited this post 14 years, 8 months ago.]
      MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
      DESIGNfromWITHIN, MPThemes and Any Screen Size
      Follow me on Twitter | Read my blog | My code on GitHub