* templates/posts_list.tpl * extends file="master.tpl" block name="content" <div class="container-fluid"> <h1>$Page->Title</h1>
<!-- Custom HTML/PHP here --> <h2>Monthly Sales</h2> <?php // Your custom query $result = $DB->Execute("SELECT MONTH(publish_date) as month, COUNT(*) as count FROM posts GROUP BY MONTH(publish_date)"); ?>
-- Example schema for a blog system CREATE DATABASE blog_system; USE blog_system; CREATE TABLE categories ( id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100) NOT NULL, description TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
1. Prepare Production Environment # Create production database mysql -u root -p CREATE DATABASE blog_production; GRANT ALL ON blog_production.* TO 'app_user'@'localhost' IDENTIFIED BY 'strong_password'; Export development database mysqldump -u dev_user -p blog_development > database.sql Import to production mysql -u app_user -p blog_production < database.sql 2. Update Configuration // config.php - Production settings $config['db_host'] = 'localhost'; $config['db_user'] = 'app_user'; $config['db_password'] = 'strong_password'; $config['db_name'] = 'blog_production'; $config['debug_mode'] = false; $config['error_reporting'] = E_ALL & ~E_NOTICE & ~E_WARNING; 3. Secure File Permissions # Set proper ownership chown -R www-data:www-data /var/www/blog-admin/ chmod -R 755 /var/www/blog-admin/ chmod -R 770 /var/www/blog-admin/templates_c/ chmod -R 770 /var/www/blog-admin/uploads/ chmod 640 /var/www/blog-admin/config.php 4. Enable Production Cache // config.php $config['smarty_caching'] = true; $config['smarty_cache_lifetime'] = 86400; // 24 hours Troubleshooting Common Issues Problem: White screen after generation Solution: Enable error reporting phprad classic
// Field configuration 'image' => array( 'type' => 'file', 'upload_dir' => 'uploads/', 'allowed_extensions' => 'jpg,jpeg,png,gif', 'max_size' => 5242880, // 5MB 'thumbnail' => array(150, 150), 'medium' => array(800, 600) ) // pages/posts_add.php public function OnAfterSave()
chmod 777 templates_c/ # Clear compiled templates rm -rf templates_c/* Solution: Verify credentials and PDO driver
return true; Modify class files:
// In project settings, set master-detail relationship $config['master_detail'] = array( 'posts' => array( 'master_table' => 'categories', 'master_key' => 'id', 'detail_key' => 'category_id' ) ); // Override the default query in list page public function OnBeforeListQuery(&$sql, &$params)
Create a cron script:
<table class="table"> <thead> <tr><th>Month</th><th>Posts</th></tr> </thead> <tbody> <?php while($row = $result->fetch()): ?> <tr> <td><?= $row['month'] ?></td> <td><?= $row['count'] ?></td> </tr> <?php endwhile; ?> </tbody> </table> * templates/posts_list
* Add custom HTML here * <div class="alert alert-info"> Custom message for all posts </div>
Configure file fields in project:
// Test connection script try $pdo = new PDO("mysql:host=localhost;dbname=test", "user", "pass"); echo "Connected successfully"; catch(PDOException $e) echo "Error: " . $e->getMessage(); Secure File Permissions # Set proper ownership chown
$sql = "SELECT p.*, c.name as category_name FROM posts p LEFT JOIN categories c ON p.category_id = c.id WHERE p.status = 'published'";