{php} // 在渲染阶段从主题配置插件读取配置,并覆盖 $data 与 SEO 变量,实现 SSR if (class_exists('\\addon\\theme_configurator\\model\\ThemeConfigModel')) { $cfgModel = new \addon\theme_configurator\model\ThemeConfigModel(); $themeCfg = $cfgModel->getConfig(); if (is_array($themeCfg)) { $site = isset($themeCfg['site_config']) && is_array($themeCfg['site_config']) ? $themeCfg['site_config'] : []; if (!isset($data) || !is_array($data)) { $data = []; } // 覆盖 / 补充首页相关结构数据 if (isset($themeCfg['banner'])) { $data['banner'] = $themeCfg['banner']; } if (isset($themeCfg['honor'])) { $data['honor'] = $themeCfg['honor']; } if (isset($themeCfg['partner'])) { $data['partner'] = $themeCfg['partner']; } if (isset($themeCfg['friendly_link'])) { $data['friendly_link'] = $themeCfg['friendly_link']; } if (isset($themeCfg['header_nav'])) { $data['header_nav'] = $themeCfg['header_nav']; } if (isset($themeCfg['footer_nav'])) { $data['footer_nav'] = $themeCfg['footer_nav']; } if (isset($themeCfg['side'])) { $data['side_floating_window'] = $themeCfg['side']; } // 站点基础信息,供 header/footer 与其他模板直接使用 $data['enterprise_name'] = $site['enterprise_name'] ?? ($data['enterprise_name'] ?? ''); $data['enterprise_telephone'] = $site['enterprise_telephone'] ?? ($data['enterprise_telephone'] ?? ''); $data['enterprise_mailbox'] = $site['enterprise_mailbox'] ?? ($data['enterprise_mailbox'] ?? ''); $data['enterprise_qrcode'] = $site['enterprise_qrcode'] ?? ($data['enterprise_qrcode'] ?? ''); $data['official_website_logo']= $site['official_website_logo']?? ($data['official_website_logo']?? ''); $data['online_customer_service_link'] = $site['online_customer_service_link'] ?? ($data['online_customer_service_link'] ?? ''); $data['icp_info'] = $site['icp_info'] ?? ($data['icp_info'] ?? ''); $data['icp_info_link'] = $site['icp_info_link'] ?? ($data['icp_info_link'] ?? ''); $data['public_security_network_preparation'] = $site['public_security_network_preparation'] ?? ($data['public_security_network_preparation'] ?? ''); $data['public_security_network_preparation_link'] = $site['public_security_network_preparation_link'] ?? ($data['public_security_network_preparation_link'] ?? ''); $data['telecom_appreciation'] = $site['telecom_appreciation'] ?? ($data['telecom_appreciation'] ?? ''); $data['copyright_info'] = $site['copyright_info'] ?? ($data['copyright_info'] ?? ''); $data['terms_service_url'] = $site['terms_service_url'] ?? ($data['terms_service_url'] ?? ''); $data['terms_privacy_url'] = $site['terms_privacy_url'] ?? ($data['terms_privacy_url'] ?? ''); $data['cloud_product_link'] = $site['cloud_product_link'] ?? ($data['cloud_product_link'] ?? ''); $data['dcim_product_link'] = $site['dcim_product_link'] ?? ($data['dcim_product_link'] ?? ''); // SEO:如插件配置了 SEO,则覆盖控制器传入的标题/关键词/描述 if (!empty($themeCfg['seo']['title'])) { $title = $themeCfg['seo']['title']; } if (!empty($themeCfg['seo']['keywords'])) { $keywords = $themeCfg['seo']['keywords']; } if (!empty($themeCfg['seo']['description'])) { $description = $themeCfg['seo']['description']; } } } {/php}