Forum


Replies: 1   Views: 714
Listoverrideoptions start is not working?
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 neukanri  · 22-10-2020 - 05:30

 

I am creating a list using listOverrideOptions.

The "type" is changed, but the "start" is not changed and the previous state is inherited.

I want you to start from 2 at first, and start from 1 on the override side.

// CUSTOM LIST
$fullNumOpt = array(
    'type' => 'decimalFullWidth',
    'format' => '%1',
    'left' => 400,
    'hanging'=> 280,
    'align' => 'left'
);
$kanNumOpt = array(
    'type' => 'japaneseCounting',
    'format' => '%1',
    'left' => 800,
    'hanging'=> 380,
    'align' => 'left'
);
$irohaOpt = array(
    'type' => 'irohaFullWidth',
    'format' => '%1',
    'left' => 1200,
    'hanging' => 380,
    'align' => 'left'
);


$joOpt = array();
$joOpt[0] = $fullNumOpt;
$joOpt[0]['format'] = '第%1æ¡';
$joOpt[0]['left'] = 440;
$joOpt[0]['hanging'] = 500;

$joOpt[1] = $fullNumOpt;
$joOpt[1]['format'] = '%2';
$joOpt[1]['start'] = 2;
$joOpt[1]['left'] = 440;
$joOpt[1]['hanging'] = 420;

$joOpt[2] = $kanNumOpt;
$joOpt[2]['format'] = '%3';

$joOpt[3] = $irohaOpt;
$joOpt[3]['format'] = '%4';

// override
$kanOpt = array();
$kanOpt[0] = $fullNumOpt;
$kanOpt[0]['format'] = '第%1æ¡';
$kanOpt[0]['left'] = 440;
$kanOpt[0]['hanging'] = 500;
$kanOpt[0]['start'] = 1;
$kanOpt[1] = $kanNumOpt;
$kanOpt[1]['start'] = 1;
$kanOpt[1]['format'] = '%2.';

$kanListStyle = array();
$kanListStyle[0] = array(
    'listOptions' => $kanOpt,
    'name' => 'kanList'
);

$docx->createListStyle('joList', $joOpt, $kanListStyle);

$tidy_html = createTidyHTML($html);

$docx->replaceVariableByHTML('EXTERNAL', 'block', $tidy_html,
    array(
        'customListStyles' => true,
        'strictWordStyles' => true,
        'useHTMLExtended' => true,
        'parseDivsAsPs' => true,
        'wordStyles' => array(
            '.joList' => 'joList',
            '.kanList' => 'kanList',
        )
    )
);

 

Posted by admin  · 22-10-2020 - 06:51

Hello,

All options included in phpdocx are fully tested and working. As the previous post (https://www.phpdocx.com/en/forum/default/topic/2020) that's behaviour is from MS Word, list override works in that way, some properties (such as start value) are inherited and they can't be overwritten. You need to set start as 1 in the main list style to set the level override start as 1, if you set it to 2 then level overrides start from 2. You can check this behaviour using MS Word too if you open the DOCX output and try to edit it.

From your code:

// set the start value of the first level of the list:

$joOpt[0]['start'] = 1;

// set the start value of the second level of the list:

$joOpt[1]['start'] = 2;

So as you are setting 2 as start in the second level, then items in that level start from 2, you can't overwritte it in the level override properties. Level override works in this way, to start 2nd level from 1 you need to set that value:

$joOpt[1]['start'] = 1;

Regards.