Categories > OpenTBS with DOCX >

array listed with bullet point in docx

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: pela222
Date: 2015-12-08
Time: 02:19

array listed with bullet point in docx

Hi,
I read so far the following:
http://www.tinybutstrong.com/forum.php?thr=2950 and http://www.tinybutstrong.com/forum.php?thr=3502 and http://stackoverflow.com/questions/18754590/inserting-a-bullet-point-and-styling-to-onshow-entires-in-opentbs

I also saw in manual the following solution:
[onshow.myarray;ope=list] and [onshow.myarray;ope=list;valsep='+']

I am struggling with having my array merged in docx as bulleted list.
At the moment the solution (lisitng each of array object in new line) is:
$str = implode("\r\n", $array);
    function f_paragraphs($str, &$CurrVal) {
        $CurrVal= str_replace("\r\n", "<w:p></w:p>", htmlspecialchars($CurrVal));
    }
and my docx template looks:
[onshow.str;strconv=no;onformat=f_paragraphs;noerr]
Is it possible to list the array with bullet points?
Appreciate your help Skrol29
By: pela222
Date: 2015-12-11
Time: 18:55

Re: array listed with bullet point in docx

Hi Skrol29,

I spend a few hours on looking into manual and OpenTBSforum. I think that solution to my query could be using table. I tried to use:
$TBS->MergeBlock('body', $data);
and docx template is (code below is paste in single row/column table in ms word):
Name: [body.fields;block=w:tr;sub1=common1.multiText]
•    [body_sub1.val;block=w:tr]

but it is not working for me. I say I am not understanding properly the structure of my array / and using MergeBlock improperly.

please find here my ver_export file:
array (
    'fields' =>
    array (
        'common1' =>
        array (
          'multiText' =>
          array (
            0 =>
            array (
              'used' => 'yes',
              'value' => 'Common1 sub1',
            ),
            1 =>
            array (
              'used' => 'yes',
              'value' => 'Common1 sub2',
            ),
            2 =>
            array (
              'used' => 'yes',
              'value' => 'Common1 sub3',
            ),
          ),
        ),
        'common2' =>
        array (
          'multiText' =>
          array (
            0 =>
            array (
              'used' => 'yes',
              'value' => 'Common2 sub1',
            ),
            1 =>
            array (
              'used' => 'yes',
              'value' => 'Common2 sub2',
            ),
          ),
        ),
    ),
)

Looking forward for tips how to do it for my data structure. What I am interested in achieving is listing "common[].multiText" values in rows.
Thank you.
By: pela222
Date: 2015-12-14
Time: 14:34

Re: array listed with bullet point in docx

Sorry for confusing. My actual array stracture for fields 'f' is:
$data = array (
    'common1' =>
    array (
      '0' => 'comm1, 1st field',
      '1' => 'comm1, 2st field',
      '2' => 'comm1, 3st field',
    ),
    'common2' =>
    array (
      '0' => 'comm1, 1st field',
      '1' => 'comm1, 2st field',
    ),
  );

how can I display it as already discriped
By: Skrol29
Date: 2015-12-16
Time: 11:00

Re: array listed with bullet point in docx

Hi,

How do you want the result to be displayed ? This is not clear for me. Can you draw it ?
By: pela222
Date: 2015-12-16
Time: 11:27

Re: array listed with bullet point in docx

Hi Skrol29,

Sorry for being very chaotic on my explanation. The system I am using is giving me two possibilities:
1) I am receiving a string of fields. (I could probably change it to "coma separated" string if requireded)
array (),
    'f' =>
    array (
    'common1' =>
        array (
        '0' => 'field1 field2 field3.',
        ),
    'common2' =>
        array (
        '0' => 'field1',
        ),
    ),
2) I am receiving an array with fields
array (),
    'f' =>
    array (
    'common1' =>
        array (
        '0' => 'field1',
        '1' => 'field2',
        '2' => 'field3.',
        ),
    'common2' =>
        array (
        '0' => 'field1',
        ),
    ),

The result I want to achieve in ms word is to have (when required) each field bullet pointed. Ideally I would like to have this achieved for the firsts structure (string of fields) but if it is not possible I will use the second structure (array of fields) to achieve bullet pointed list of fields in MS Word.

I hope this explanation is clear now.
By: Skrol29
Date: 2015-12-16
Time: 15:00

Re: array listed with bullet point in docx

Can you draw an example of the result you want regarding to your snippet of data?
Since your structure have several set of field, the final result is not obvious.
By: pela222
Date: 2015-12-16
Time: 17:00

Re: array listed with bullet point in docx

Hi,
I would like to achieve the following:
=====================
Here you can see my common1:
- f.common1.0
- f.common1.1
- f.common1.2
=====================
Some word custom text...
Here you can see my common2:
- f.common2.0
- f.common2.1
etc.

I would like to call them separately each time (each [common]) and list with bullet point only array with fields.
By: pela222
Date: 2015-12-16
Time: 18:33

Re: array listed with bullet point in docx

In other words now I am using:
[onshow.f.common1.0]
if the structure is as in no. 1) in post from 2015-12-16 Time: 11:27, or

[onshow.f.common1;ope=list;valsep='']
if the structure is as in no. 2) in post from 2015-12-16 Time: 11:27.

I just need to bullet point it rather than list one after another. I believe if bullet point is possible it will be for the second case. I am saying bullet point but, if it is marged in table as rows will do for me. (I will set no border for this table in MS Word).
By: Skrol29
Date: 2015-12-17
Time: 00:53

Re: array listed with bullet point in docx

OK, so here is the solution you can have :

PHP side :

$fields = array (
    'f' =>
    array (
    'common1' =>
        array (
        '0' => 'field1',
        '1' => 'field2',
        '2' => 'field3.',
        ),
    'common2' =>
        array (
        '0' => 'field1',
        ),
    ),
);

$TBS->MergeBlock('b', $fields['f']);

At the template side :
=====================¶
Here you can see my [b.$;block=tbs:p+tbs:p+tbs:p;sub1]:¶
• f.[b.$].[b_sub1.$;block=tbs:p]¶
=====================¶

By: pela222
Date: 2016-02-05
Time: 19:06

Re: array listed with bullet point in docx

Hi Skrol29,

thank you for your advice. I only now had some time to sit down and check your solution. Few words to give full picture of my structure:
Here you can see my [b.$;block=tbs:p+tbs:p+tbs:p;sub1]:¶
• f.[b.$].[b_sub1.$;block=tbs:p]¶
is giving my the following result:
Here you can see my common1:¶
• f.common1.0¶
• f.common1.1¶
--------
Here you can see my common2:¶
• f.common2.0¶
• f.common2.1¶
• f.common2.2¶
--------
I figure out that by changing your solution to:
Here you can see my [b.$;block=tbs:p+tbs:p+tbs:p;sub1]:
• [b_sub1.val;block=tbs:p]
I am getting the value of my array displayed. Which is nearly what I was looking for.
Nearly as I would like to display e.g ONLY b.$=common1 and in some other place in ms word I would like to display ONLY b.$=common2 rather than having them displayed all one after another.

What is the solution to my query? Thank you for your patience and help.
By: pela222
Date: 2016-02-07
Time: 20:19

Re: array listed with bullet point in docx

Hi,

I think I got the solution, by adding conditional statement I can display them separately e.g only array common1:
[b.$;block=tbs:p+tbs:p+tbs:p;sub1;when [b.$]=common1]
• [b_sub1.val;block=tbs:p;when [b_sub1.val]!=’’;]
------

I figured out that if I dont need to display b.$ (which I dont in my ms word document) I only need to replace first "b.$" with "b".
I added also a conditional statement not to display empty sub-blocks.

Thanks any way for your help Scrol29. Wont get it right without your help. :)
By: Skrol29
Date: 2016-02-09
Time: 02:57

Re: array listed with bullet point in docx

ok
:)