Forum


Replies: 2   Views: 734
Cómo utilizar replacelistvariable para obtener una lista anidada
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by rmartinez  · 13-12-2021 - 11:44

Hola de nuevo.

¿Puede utilizarse el método replaceListVariable pasándole un array anidado para una lista anidada?

Es decir, sería pasarle un array como el siguiente:

$items = ['1', '2', ['2.1', ['2.1.1', '2.1.2']], ['2.2', ['2.2.1', '2.2.2']]]

para obtener esto:

  • 1
  • 2
    • 2.1
      • 2.1.1
      • 2.1.2
    • 2.2
      • 2.2.1
      • 2.2.2

Cada vez que le paso un array anidado, como el que os comento, al método replaceListVariable, me pinta lo siguiente:

  • 1
  • 2
  • Array
  • Array

Pero, obviamente, no es lo que quiero.

¿Alguna idea?

La versión de phpdocx que tengo es la 8.5.

Gracias.

Saludos.

Posted by admin  · 13-12-2021 - 11:47

Hola,

Utilizar arrays anidados en el método replaceListVariable se permite desde el lanzamiento de phpdocx 12 (https://www.phpdocx.com/news/post/phpdocx-v12-release-notes/223):

  • replaceListVariable allows using sub-arrays.

por ejemplo:

$items = array(
  'First item',
  'Second item',
  array(
    'Subitem A',
    'Subitem B',
    'Subitem C',
    array('Subitem C.1', 'Subitem C.2'),
    'Subitem D'
  ),
 'Third item'
);

$docx->replaceListVariable('LISTVAR', $items);

Versiones anteriores de phpdocx no lo permiten. Te recomendamos actualizar tu licencia a la última versión disponible.

Saludos.

Posted by genuvenue  · 18-12-2021 - 13:47

Deleted by admin · 18-12-2021 - 14:22