Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart ListItem Numbering #10

Closed
RLovelett opened this issue Oct 16, 2012 · 12 comments · Fixed by #198
Closed

Restart ListItem Numbering #10

RLovelett opened this issue Oct 16, 2012 · 12 comments · Fixed by #198
Assignees
Milestone

Comments

@RLovelett
Copy link
Contributor

Is there a way to restart the ListItem numbering (lettering)?

Using this code snippet:

$numberStyleList = array('listType' => \PHPWord_Style_ListItem::TYPE_NUMBER);
$alphStyleList = array('listType' => \PHPWord_Style_ListItem::TYPE_ALPHANUM);

$section->addListItem('One', 0, null, $numberStyleList);
$section->addListItem('Two', 0, null, $numberStyleList);
$section->addListItem('Alpha', 1, null, $alphStyleList);
$section->addListItem('Beta', 1, null, $alphStyleList);
$section->addListItem('Three', 0, null, $numberStyleList);
$section->addListItem('Charlie', 1, null, $alphStyleList);

Currently it would output this:

1. One
2. Two
   A. Alpha
   B. Beta
3. Three
   C. Charlie

I want to output this:

1. One
2. Two
   A. Alpha
   B. Beta
3. Three
   A. Charlie

Is there some other code call that needs to be made? Or is this a limitation of PHPWord?

@elwinarens
Copy link

I'm having the same problem with an ordered list. Any updates on this issue?

@RLovelett
Copy link
Contributor Author

Yes, kind of. I never got it fully ready for prime-time. That is why I never submitted a pull-request.

But I have a branch in a personal fork called saic. In that branch I have worked-around this issue by completely allowing you to design your own numbered lists. Similar to the way you can create paragraph and font styles.

The specific commit is this one: https://github.com/RLovelett/PHPWord/commit/1a6c6851f0d2444245f457c245d717ab18084672

If you make patches/changes to it I would love to see them. I want to make this feature complete and get it merged into master. 👍

@Progi1984 Progi1984 modified the milestones: 0.7.2, 0.7.1, 0.7.3 Mar 3, 2014
ivanlanin added a commit to ivanlanin/PHPWord that referenced this issue Apr 11, 2014
ivanlanin added a commit that referenced this issue Apr 11, 2014
Ability to add custom numbering style. Solved #10.
@ivanlanin
Copy link
Contributor

Hi @RLovelett, can you please check the latest version of the develop branch to verify that this feature is already in place and perhaps give us some suggestion for improvement? Thanks.

@ivanlanin ivanlanin added this to the 0.10.0 milestone Apr 13, 2014
@ivanlanin ivanlanin self-assigned this Apr 15, 2014
@Progi1984
Copy link
Member

@RLovelett Some news ? :)

@RLovelett
Copy link
Contributor Author

Yeah there is news. The code is way different now between when I made https://github.com/RLovelett/PHPWord/commit/1a6c6851f0d2444245f457c245d717ab18084672.

What is more, code that I wrote, has been cut-n-paste into the PHPWord repository rather than cherry-picked or merged. Which is causing git to choke on my rebase/merge. Which is causing me to have resolve a lot of conflicts. Basically making me have to re-review all the code.

I need to figure out if the code that I wrote has already been merged into master/develop. Also, there is entirely new chunks of code that I cannot figure out when it came into existence and why it came it to existence because of all the renaming/moving of files (e.g., when did indent start existing in Paragraph?). For instance I know that the proper use of indenting (i.e., w:ind) is required to cause lists to restart their numbering. It does not appear that the version of indenting and hanging lines was implemented fully to take advantage of that...

Point is a lot has changed and I need to figure out what has been implemented and what has not. Then I can go about figuring out how to apply the old restart numbering fix to this new code. Bottom line though is I should be able submit a new patch against develop.

@ivanlanin
Copy link
Contributor

Hi @RLovelett. Yes, heavy changes to the code base has been made since codeplex (0.6.*). I don't know when indent was added to paragraph style, but I add hanging in #48.

Since there's no pull request and the code base is quite different, I focused on implementing the functionality and the result is probably quite different with your approach. Please feel free to change my implementation.

Thanks.

@Progi1984 Progi1984 modified the milestones: 1.0.0, 0.10.0, 0.11.0 May 4, 2014
@ivanlanin ivanlanin modified the milestones: 0.12.0, 0.11.0 Jun 1, 2014
@alpha1125
Copy link

Is there any updates to this issue?

@ivanlanin
Copy link
Contributor

Custom numbering has been added since 0.10. See Sample_14_ListItem.php for the implementation example. Recipe to create numbered headings (#193) has also been added. We kept all issues open until the original submitter confirm.

@RLovelett
Copy link
Contributor Author

@ivanlanin go ahead and just write this down as a confirm from me.

I am not going to have the time to recreate the project that caused me to make the pull request using the new PHPWord. Without that tool I have no way to confirm if it is "working" or not working. (PHPWord did not have a testing framework back when I originally was working this stuff).

If I ever do end up using the project again and I find that it is not working; I will submit a new pull request then.

@ivanlanin
Copy link
Contributor

Ok, @RLovelett. Thanks.

@Kell
Copy link

Kell commented Feb 26, 2020

Hey folks,
i see the issue is closed but i don't see how list numbering is restarted just custom numbering styling was added?
I also found this https://stackoverflow.com/questions/34390893/phpword-and-listitemrun-reset-numbering , which seems to me that its still not possible in proper way and i need to make new style if i want a reset ?
Setting numbers manually isn't possible, right? for example to set the "counter" back to 1?

@ivanlanin

@alpha1125
Copy link

@Kell that was how I eventually approached it. New style id for every list restart. Wasn't the end of the world, but the output was generated, and more meant for human editing... so it wasn't much of a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

6 participants