Codxplore.com

Latest news:

Quran ul karim is a free Quran application for android. This application is advertisement free application for android smartphone. Download from https://play.google.com/store/apps/details?id=com.akramhossain.quranulkarim&hl=en

Install Smart App Banner Yii2 without jQuery


Install Smart App Banner Yii2 without jQuery

Smart app banner is an important element which is used to motivate user to 
download mobile application instead of using the website. The usage of a smart banner is only to promote app.
To implement smart banner in Yii2 web application we need to do the following

  • Download the javascript library from github using this https://github.com/kudago/smart-app-banner  as .zip format
  • Put smart app banner library to web folder
  • Load the required js and css file to main.php file
  • Place the smart banner js code

in the Yii2 web application goto \views\layout\main.php file and put the following code in head section

$this->registerCssFile(BaseUrl::home() . 'path-to-library/smart-app-banner.css');
$this->registerJsFile(BaseUrl::home() . 'path-to-library/smart-app-banner.js');

before the $this->endBody() method in the body section add the following javascript code to initialize smart banner

$smartBannerJs = "new SmartBanner({
            daysHidden: 1,   // days to hide banner after close button is clicked (defaults to 15)
            daysReminder: 1, // days to hide banner after \"VIEW\" button is clicked (defaults to 90)
            appStoreLanguage: 'us', // language code for the App Store (defaults to user's browser language)
            title: 'AppName‎',
            author: 'AppAuthor',
            button: 'VIEW',
            store: {
                ios: 'On the App Store',
                android: 'In Google Play',
                windows: 'In Windows store'
            },
            price: {
                ios: 'FREE',
                android: 'FREE',
                windows: 'FREE'
            }
            // , theme: '' // put platform type ('ios', 'android', etc.) here to force single theme on all device
            // , icon: '' // full path to icon image if not using website icon image
            // , force: 'ios' // Uncomment for platform emulation
        });";
$this->registerJs($smartBannerJs, View::POS_READY);

Tags : javascript, PHP, Yii2,

Views : 172

Subscribe Us


Follow Us