Home Backend Development PHP Tutorial PHPCMS V9 容易的二次开发

PHPCMS V9 容易的二次开发

Jun 13, 2016 pm 01:02 PM
content gt model phpcms

PHPCMS V9 简单的二次开发

更多二次开发技巧,查看phpcms系统帮助 ,前台模板解析后的缓存 caches\caches_template\default

前台控制类index.php,前台标签类*_tag.class.php,前台需要的变量可以在前台控制类,前台标签类配合组合返回

?

添加一个新功能模块,他的信息存储用文章模型字段有些不能满足 ,一般采取哪些方法解决?

1.可以直接在数据库上加字段(后台模型管理--文章模型---字段管理,或数据库中直接加)

2.自定义新的字段模型(后台模型管理--添加模型)

3.直接建个新表

?

二次开发添加数据库表时用其他的标记,已示区分:

数据库配置文件位置:caches/configs/database.php

?<?php return array (
   'default' => array (
     'hostname' => 'localhost',
     'database' => 'phpcms',
     'username' => 'admin',
     'password' => 'admin',
     'tablepre' => 'v9_',
     'charset' => 'gbk',
     'type' => 'mysql',
     'debug' => true,
     'pconnect' => 0,
     'autoconnect' => 0
   ),
    /* 以下默认不存在 */
   'extended' => array (
     'hostname' => 'localhost',
     'database' => 'phpcms',
     'username' => 'admin',
     'password' => 'admin',
     'tablepre' => 'ext_',
     'charset' => 'gbk',
     'type' => 'mysql',
     'debug' => true,
     'pconnect' => 0,
     'autoconnect' => 0
   ),
 );
 ?>
Copy after login

?

URL访问

http : //yourdomain.com/index.php?m=content&c=index&a=show&id=1

m = content 为模型/模块名称 位于phpcms/modules/content
c = index? 为控制器名称?位于phpcms/modules/content/index.php
a = show 为时间名称?位于phpcms/modules/content/index.php 中show()方法
id = 1 为其他参数 与正常get传递参数形式相同

phpcms默认路由会定位到content模块的index控制器中的init操作 ,因为系统在没有指定模块和控制器的时候,会执行默认的模块和操作。

?

1.修改默认主页

修改/caches/configs/route.php文件

?

2.创建model

新建一个model phpcms/model/格式:my_model.class.php my指表名,其基本格式如下:

<?php defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_sys_class('model', '', 0);
class my_model extends model {
    public function __construct()
    {
        $this->db_config = pc_base::load_config('database');
        $this->db_setting = 'default';
        $this->table_name = 'my';
        parent::__construct();
    }
}
?>
Copy after login

3.创建modules

新建一个my目录 其目录下的目录有 classes functions templates -------这里的目录是后台modules,创建一个前台php文件 mytest.php 其基本内容如下:

<?php defined('IN_PHPCMS') or exit('No permission resources.');
class mytest {
    function __construct()
    {
        $this->db = pc_base::load_model('my_model');
    }
    public function init() {
        $result = $this->db->select();
        var_dump($result);
        include template('my', 'my',$result); //my是templates目录,第二个my是文件名,$result为风格名称,默认不填为defalut

    }

    public function mylist()
    {
        $var = 'hello world!this is a example!';
        echo $var;
		$siteid = get_siteid();
		$SEO = seo($siteid, '', $var);
		include $this->admin_tpl("mytest_admin_list");
    }
}
?>
Copy after login

?4.创建templates

后台templates在phpcms\modules\mytest\templates

前台在phpcms\templates

新建一个my目录 my就是include template('my','my',$style);

{template "content","header"}

{loop $result $value}
    用户ID:{$value['id']}<p>
    密码:{$value['username']}</p><p>
{/loop}

{template "content","footer"}</p>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Trezor Cold Wallet: Model One and Model T Features and Usage Guide Trezor Cold Wallet: Model One and Model T Features and Usage Guide Jan 19, 2024 pm 04:12 PM

After problems occurred in many centralized exchanges, more and more cryptocurrency investors began to transfer assets to cold wallets to reduce the risks posed by centralized exchanges. This article will introduce Trezor, the world's earliest cold wallet provider. Since the first cold wallet was launched in 2014, it has been sold in many countries around the world. Trezor's products include Model One launched in 2014 and the advanced version Model T launched in 2018. The following will continue to introduce the differences between these two products and other cold wallets. What is Trezor cold wallet? In 2014, Trezor launched the first cold wallet ModelOne. In addition to common BTC, ETH, USDT and other currencies, the wallet also supports more than 1,000 other currencies.

How to jump to the details page in phpcms How to jump to the details page in phpcms Jul 27, 2023 pm 05:23 PM

How to jump to the details page in phpcms: 1. Use the header function to generate a jump link; 2. Loop through the content list; 3. Get the title and details page link of the content; 4. Generate a jump link.

What framework is phpcms? What framework is phpcms? Apr 20, 2024 pm 10:51 PM

PHP CMS is a PHP-based open source content management system for managing website content. Its features include ease of use, powerful functionality, scalability, high security, and free open source. It can save time, improve website quality, enhance collaboration and reduce development costs, and is widely used in various websites such as news websites, blogs, corporate websites, e-commerce websites and community forums.

WeChat Login Integration Guide: PHPCMS Practical Combat WeChat Login Integration Guide: PHPCMS Practical Combat Mar 29, 2024 am 09:18 AM

Title: WeChat Login Integration Guide: PHPCMS in Action In today’s Internet era, social login has become one of the essential functions of a website. As one of the most popular social platforms in China, WeChat’s login function is also used by more and more websites. This article will introduce how to integrate the WeChat login function in the PHPCMS website and provide specific code examples. Step 1: Register a WeChat Open Platform Account First, we need to register a developer account on the WeChat Open Platform and apply for the corresponding development permissions. Log in [WeChat open platform]

How to Fix Can't Connect to App Store Error on iPhone How to Fix Can't Connect to App Store Error on iPhone Jul 29, 2023 am 08:22 AM

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

Isn't phpcms free? Isn't phpcms free? Mar 01, 2023 am 10:24 AM

phpcms is not completely free. phpcms is an open source cms system, but open source does not mean free. It has two versions: free version and commercial version. The free version is limited to personal non-commercial use, while the commercial version requires purchasing a license; individuals can use it for research, and if it is commercial application , you need to pay a certain fee.

See all articles