Replies: 3   Views: 1235
Issue with data-text in crossreferences
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 dev@ams  · 15-01-2020 - 09:37


I have a problem when I use cross-references with HTML extended. This is what I use: 

<p><phpdocx_bookmark data-name="bookmarkname" data-type="start" />bookmark<phpdocx_bookmark data-name="bookmarkname" data-type="end" /></p>
<p>Â </p>
<p>Should be crossreference:</p>
<p>Â </p>
<p><phpdocx_crossreference data-text="Link to bookmark" data-type="bookmark" data-referenceName="bookmarkname" /></p>

In my document, the data-text is however not visible. Instead, I see number '1' for the cross reference. Am I doing something wrong or is this an issue with phpdocx?

Posted by admin  · 15-01-2020 - 09:58


We have checked your code and it's working as expected.

Please note that the current version of phpdocx add cross-references as PAGEREF (not bookmark text content), so if you update its value manually (MS Word, right click, Update field) or automatically (using a macro or ) the content shows the page number of the linked bookmark not the bookmark text content.

To add an internal link that displays a text content, you can use addLink (phpdocx_link using HTML Extended) with the bookmark name.

We move the request of applying the bookmark text content to the dev team to be added to the next release of phpdocx.


Posted by admin  · 15-01-2020 - 10:22


We have moved the request to the dev team and they have replied that the following change is already available in the current beta branch:

- The addCrossReference method now allows setting bookmark text and above/below as field content

The same applies to HTML Extended. This change is fully tested and it will be available in the next release of phpdocx.

As your license has LUS active, If addlink doesn't fit your needs please send an e-mail to contact[at] sending if you are using the classic or namespaces package and the dev team will send you the new classes and a sample script.


Posted by dev@ams  · 15-01-2020 - 10:49

Thank you for your replies! We have tested it with the addLink method and that works for us, great. We'll look forward to the next release!