0

我正在尝试在using中创建一个block内部,但到目前为止没有成功。sub block.docxopenTBS

这是我的PHP array

$myBlock = array(
   0 => array(
          'description' => 'description1',
          'name'        => 'name1',
          'photos'      =>  array (
                0 => array(
                   'path' => 'C:\path_to\pic_0000y.png',
                   'name' => 'photo0000'),

                1 => array(
                   'path' => 'C:\path_to\pic_1111y.png',
                   'name' => 'photo111'),
                ), // end of photo array
       ),  // end of first element 

   1 => array(
          'description' => 'description2',
          'name'        => 'name2',
          'photos'      =>  array (
                0 => array(
                   'path' => 'C:\path_to\pic_3333y.png',
                   'name' => 'photo3333'),

                1 => array(
                   'path' => 'C:\path_to\pic_00000.png',
                   'name' => 'photo00000'),
                ), // end of photo array
       ),  // end of second element
);

我正在TBS像这样合并:

$this->TBS->MergeBlock( 'myBlock', $myBlock);

相当于php我想要实现的目标:

foreach( $myBlock as $myBlockKey => $myBlockData)
{
  echo $myBlockData['description'];
  echo $myBlockData['name'];

  foreach( $myBlockData['photos'] as $photoKey => $photoData)
  {
     echo $photoData['name'];
     echo $photoData['path'];
  }
}

这将显示:

description1
name1
photo0000
C:\path_to\pic_0000y.png
photo111
C:\path_to\pic_1111y.png

description2
name2
photo3333
C:\path_to\pic_3333y.png
photo0000
C:\path_to\pic_0000y.png

我想发布我尝试过的错误内容并没有多大意义,但这几乎就是我试图做的:

[myBlock; block=begin;]
      [myBlock.description]
      [myBlock.name]

      [myBlock.photos; block = begin;]  // where it fails
          [myBlock.photos.path]         // where it fails
          [myBlock.photos.name]         // where it fails
      [myBlock.photos; block=end;]      // where it fails

[myBlock; block=end;]
4

1 回答 1

1

您必须使用 TBS自动分块功能。

[myBlock; block=begin;sub1=photos]
      [myBlock.description]
      [myBlock.name]

      [myBlock_sub1; block = begin;]
          [myBlock_sub1.path]
          [myBlock_sub1.name]
      [myBlock_sub1.photos; block=end;]

[myBlock; block=end;]

您的 [myBlock.photos;block = begin] 语法无法工作,因为 (1) [myBlock] 的块边界已经定义,因此此标记中的参数“block”被忽略。(2) [myBlock.photos] 是一个数组项,因此无法显示。

于 2016-02-03T09:17:03.113 回答