Forum


Replies: 3   Views: 203
Replacevariable to link
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 Exorion  · 11-03-2026 - 12:20

foreach ($docx->getTemplateVariables()['document'] as $key => $value) {

$array = $this->getWordStyles($value);

Log::notice('getWordStyles', $array);

$link = new WordFragment($this->docx, 'document');

$style = array(

'fontSize' => $array['fontSize'],

'font' => $array['font'],

'color' => $array['color'],

'bold' => $array['bold'],

'italic' => ($array['italic'] == true) ? true : null,

'strikeThrough' => ($array['strike'] == true) ? true : null,

);

$this->docx->createCharacterStyle('leaderCrmStyle' . $key, $style);

$link->addLink($writestr, array(

'url' => (is_null($this->client) ? env('APP_URL', 'www.site.com') : htmlspecialchars(env('APP_URL', 'https://www.site.com') . '/guest/product_request/' . $this->client->api_token . '/' . $p->id . '/?user_id=' . $this->user_id . '&price_level_id=' . $price_level_id)),

'rStyle' => 'leaderCrmStyle' . $key,

));

$variables = array($value => $link);

$this->docx->replaceVariableByWordFragment($variables, array('type' => 'inline'));

}

In previos phpdocx all was same style like in document - but now - its blue color and underline - how i can set the same style like in document? Thanks