Help Center

Find answers or browse our knowledge base.

How to Install Advanced PWA For Sngine

Download the zip folder and unzip, upload to your sngine root following the file structure.

Sngine files that you will need to overwrite

root/manifest.php
root/sw.js
content/themes/default/templates/admin.pwa.tpl
content/themes/default/templates/manifest.tpl

Visit your phpmyadmin and import the database db.sql located inside modules/pwa/db.sql 

Once all files are uploaded, you will need to edit a few files 

open 

content/themes/default/templates/_head.tpl

Look for

    
    {if $system['pwa_enabled']}
      
      
      
      
    {else}
      
      
      
    {/if}
    

and replace with 

{if $system['pwa_enabled']}
 {include file='pwa/pwa-head-tags.tpl'}
    {/if}

Open root/admin.php

Look for 

case 'pwa':

After that add 

require('modules/pwa/admin.php');

Open includes/ajax/admin/settings.php

and look for 

case 'pwa':

Replace that entire case with 

case 'pwa':
  // Check if it's a POST request for saving
  if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Include the handler
    $handler_path = __DIR__ . '/../../../modules/pwa/pwa_admin_handler.php';
    
    if (file_exists($handler_path)) {
      require_once($handler_path);
      exit;
    } else {
      return_json(['error' => true, 'message' => 'Handler file not found']);
    }
  }
  
  // GET request - Load data and render page
  
  // Load categories from database
  $get_categories = $db->query("SELECT * FROM pwa_categories ORDER BY category_id ASC");
  $pwa_categories = [];
  if ($get_categories && $get_categories->num_rows > 0) {
    while ($category = $get_categories->fetch_assoc()) {
      $pwa_categories[] = $category;
    }
  }
  
  // Load related apps from database
  $get_apps = $db->query("SELECT * FROM pwa_related_apps ORDER BY app_id ASC");
  $pwa_related_apps = [];
  if ($get_apps && $get_apps->num_rows > 0) {
    while ($app = $get_apps->fetch_assoc()) {
      $pwa_related_apps[] = $app;
    }
  }
  
  // Load shortcuts from database
  $get_shortcuts = $db->query("SELECT * FROM pwa_shortcuts ORDER BY `order` ASC");
  $pwa_shortcuts = [];
  if ($get_shortcuts && $get_shortcuts->num_rows > 0) {
    while ($shortcut = $get_shortcuts->fetch_assoc()) {
      $pwa_shortcuts[] = $shortcut;
    }
  }
  
  // Load analytics stats
  $pwa_stats = [
    'total_installs' => 0,
    'this_month' => 0,
    'this_week' => 0,
    'today' => 0
  ];
  
  $get_total = $db->query("SELECT COUNT(*) as count FROM pwa_analytics WHERE event_type = 'install'");
  if ($get_total) {
    $pwa_stats['total_installs'] = $get_total->fetch_assoc()['count'];
  }
  
  $get_month = $db->query("SELECT COUNT(*) as count FROM pwa_analytics 
                          WHERE event_type = 'install' 
                          AND created_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH)");
  if ($get_month) {
    $pwa_stats['this_month'] = $get_month->fetch_assoc()['count'];
  }
  
  $get_week = $db->query("SELECT COUNT(*) as count FROM pwa_analytics 
                         WHERE event_type = 'install' 
                         AND created_at >= DATE_SUB(NOW(), INTERVAL 1 WEEK)");
  if ($get_week) {
    $pwa_stats['this_week'] = $get_week->fetch_assoc()['count'];
  }
  
  $get_today = $db->query("SELECT COUNT(*) as count FROM pwa_analytics 
                          WHERE event_type = 'install' 
                          AND DATE(created_at) = CURDATE()");
  if ($get_today) {
    $pwa_stats['today'] = $get_today->fetch_assoc()['count'];
  }
  
  // Recent activity
  $get_recent = $db->query("SELECT * FROM pwa_analytics 
                           ORDER BY created_at DESC 
                           LIMIT 20");
  $pwa_recent_activity = [];
  if ($get_recent && $get_recent->num_rows > 0) {
    while ($activity = $get_recent->fetch_assoc()) {
      $pwa_recent_activity[] = $activity;
    }
  }
  
  // Assign to Smarty
  $smarty->assign('pwa_categories', $pwa_categories);
  $smarty->assign('pwa_related_apps', $pwa_related_apps);
  $smarty->assign('pwa_shortcuts', $pwa_shortcuts);
  $smarty->assign('pwa_stats', $pwa_stats);
  $smarty->assign('pwa_recent_activity', $pwa_recent_activity);
  
  // Set active tab if provided
  $smarty->assign('active_tab', $_GET['tab'] ?? 'general');
 break;

Now go to sngine default pwa settings in admincp/pwa

setup you images, you don't need to worry about resizing the icons images because it will be resized on upload. 

If you got stuck and need help, open a thread here 

 

 

Was this answer helpful?
You must login to vote.
0 found this helpful, 0 did not
Thank you for your feedback!

Related Articles

ScriptsTribe https://scriptstribe.com