Yii Framework Forum: Included External Js in Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Included External Js in Yii

#1 User is offline   kocero 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 21-May 17

Posted 21 May 2017 - 07:33 PM

Hi friends!
My customer bought a project prepared with Yii.
I met with Yii and Everything is perfect.
I have a small problem and I didn't find any solutions yet.
I have seo tracking script with core php.
I must add my code in view/main.php

But I didn't find any solutions, how can i add this code for my main.php.
Generally
Usually added this code in footer.php for core php projects.

I hope you can help me about this problem. Thank you.
0

#2 User is offline   Fabrizio Caldarelli 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,065
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 22 May 2017 - 02:54 AM

Open file with -Assets suffix in assets/ folder (usually AppAsset.php) and add your js file in $js var:

    public $js = [
         // ...
         'https://domain/seo/js/analytics_js/client.js',
    ];

Yii2 by example: my book about Yii2
https://www.packtpub...nt/yii2-example
0

#3 User is offline   kocero 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 21-May 17

Posted 22 May 2017 - 03:06 PM

Thank you friend! Even you wrote me on stackoverflow.
But this doesn't work for me. I must add id="domain" data-name="6208315" values for external script.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users