I'm trying to add a dash - and a defined string $pageurle right after the {target} sothat the url in the href (se below code) is extended with, naturally a dash and the contents of the variable $pageurle
See the existing piece of code into which I would like to inject the dash & variable right after the href:
// html for breadcrumbs
var $breadcrumb_templates = array(
'separator' => '→',
'link' => '<a href="{target}">{name}</a>',
'wrapper' => '<div class="breadcrumbs">{items}</div>',
);
Now, when I add the dash and the $pageurle, dreamweaver says i'm doing something wrong and shows an eror. I must be doing something stupid here... but what? Your ideas/code/improvements/possible dives into this matter are much appreciated by me.

Pretty sure it's because class property initialising statements (the var gave it away), may only contain constants or literals.
You can't perform anything procedural in the statement.
Best to do this sort of thing in your constructor.
Edit
To illustrate
class MyClass
{
public $breadcrumb_templates = array(
'separator' => '→',
'link' => '<a href="{target}">{name}</a>',
'wrapper' => '<div class="breadcrumbs">{items}</div>',
);
public function __construct($pageurle = null)
{
if (null !== $pageurle) {
$this->breadcrumb_templates['link'] =
sprintf('<a href="{target}-%s">{name}</a>', $pageurle);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With