Mindfuc
Mindfuc

Reputation: 109

How to pass variable from template to other elements in cakePHP

I am really new into php, and cakephp3. I created template which is used by almost every email, only text in emails is something what is changing, so i get text by $this->fetch('email.text'), and in email i am passing it by $this->append('email.text').

I want to declare $variable = "some string" and pass it from template to email. How i can archive that?

Upvotes: 0

Views: 605

Answers (1)

Kishen Nagaraju
Kishen Nagaraju

Reputation: 2200

If you have created an element then you can call that element and pass the variable like below:

echo $this->element('email.text', array('var1' => 'some string'));

and inside the element file you can access the variable as $var1.

Hope this helps.

Upvotes: 2

Related Questions