定制 samsoncms/template 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

samsoncms/template

Composer 安装命令:

composer require samsoncms/template

包简介

SamsonCMS base template

README 文档

README

Latest Stable Version Build Status Code Coverage Scrutinizer Code Quality Total Downloads Stories in Ready

This module is responsible for rendering base HTML template, its styles, icons and images.

All template styles is created with LESS, every entity has it vars.less.

This module should define HTML structure of SamsonCMS, its building blocks and entities which should be used in all other SamsonCMS modules and applications.

This template is basic and included in a SamsonCMS bootstrap, but can be easily changed by custom or modified once, the only limitation that must be met is template structure and its events, as all SamsonCMS ecosystem is based on this structure and entities.

Template is using Font-Awesome for all icons.

Events

All structure blocks have Events(http://github.com/samsonphp/event), and all their filling and rendering should be done via this events.

Template structure

This base SamsonCMS template structure can be defined as next:

  • Menu section .template-menu
  • Sub-menu section .template-sub-menu
  • Container section .template-container

Template menu structure

Index view is located www/menu/index.vphp, menu item view is located www/menu/item.vphp

  • <section>.template-menu
    • <ul>.template-menu-list
      • <li>.text Added .active if item is active
        • <a>.item or <div>.item (for .active element as it cannot be clicked)
        • <i> For icons (do not use it if no icon is needed)
        • <span> For item text (do not use it if no text is needed)

Template sub-menu structure

Index view is located www/menu/index.vphp, menu item view is located www/menu/item.vphp

  • <section>.template-sub-menu
    • <ul>.template-sub-menu-list
      • <li>.collapser For showing/hiding sub-menu
      • <li> You can use any inner item structure

Menu events

Menu created event - template.menu.started: &$html, &$submenu

This event fires before generic menu rendering process has started. Before menu started default template menu item would be automatically added:

  • Main page item
  • Go to site item So in your event you will already receive not an empty menu $html, this gives you ability to remove this default items or change them.

For rendering sub-menu section you need to fill $submenu in your event handler.

Menu rendered event - template.menu.rendered: &$html, &$submenu

This event fires when all menu inner items has been rendered into main container.

Menu event handler example

This is a modified old approach menu & sub-menu render integrated via new menu events

function oldMenuRenderer(&$html, &$subMenu)
{
    // Iterate loaded samson\cms\application
    foreach (\samson\cms\App::loaded() as $app) {
        // Show only visible apps
        if ($app->hide == false) {
            // Render application menu item
            $html .= m('template')
                ->view('menu/item')
                ->active(url()->module == $app->id() ? 'active' : '')
                ->app($app)
                ->icon($app->icon)
                ->name(isset($app->name{0}) ? $app->name : (isset($app->app_name{0}) ? $app->app_name : ''))
                ->output();
        }
    }

    $subMenu = '';

    // Find current SamsonCMS application
    if (\samson\cms\App::find(url()->module, $app/*@var $app App*/)) {
        // Render main-menu application sub-menu
        $subMenu = $app->submenu();

        // If module has sub_menu view - render it
        if ($app->findView('sub_menu')) {
            $subMenu .= $app->view('sub_menu')->output();
        }
    }
}

Template container structure

All elements inside container must be inside .template-block

  • <section>.template-container
    • <div>.template-block

Template container form structure

  • <*>.template-form Should be used for all forms
    • <div>.template-form-group - Form row
      • <div>.template-form-input - Form input field
        • <input,select,textarea>.template-form-input-field
        • <label>.template-form-input-placeholder Used instead of standard placeholder

Container events

Main page created event - template.main.created

This event fires before main page rendering process has started.

Main page rendered event - template.main.rendered

This event fires when main page has been rendered into main container.

samsoncms/template 适用场景与选型建议

samsoncms/template 是一款 基于 CSS 开发的 Composer 扩展包,目前已累计 3.64k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 04 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「samsoncms template」 「samsoncms structure」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 samsoncms/template 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 samsoncms/template 我们能提供哪些服务?
定制开发 / 二次开发

基于 samsoncms/template 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.64k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 9
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 5
  • 开发语言: CSS

其他信息

  • 授权协议: Open
  • 更新时间: 2015-04-08