phpcms这种需求如何写 难度有点大
象下面这段代码是静态的html文件里的写法
如果我把它写在php文件中,怎么改呢
{pc:content action="lists" catid="6" order="id DESC" thumb="" moreinfo="" return="data" }{loop $data $n $r}<li><a href="{$r['url']}" title="{$r['title']}">{$r['title']}</a></li>{/loop}{/pc}
我试了一下直接放在php文件中是不能解析了,我试图把缓存中的文件复制进来,但一看缓存真是乱七八糟的有很多,多余的代码,有没有写的
干净点的代码呢
回复讨论(解决方案)
{pc:content action="lists" catid="6" order="id DESC" thumb="" moreinfo="" return="data" }
的含义是:
查询内容数据表(lists)
条件为分类号为 6
按 id 降序排列
将结果放到名为 data 的数组中
select * from lists where catid=6 order by id desc
{loop $data $n $r}
{/loop}
的含义是:对查询得到的数组循环输出
foeeach($data as $n=>$r) { echo "<li><a href=\"{$r['url']}\" title=\"{$r['title']}\">{$r['title']}</a></li>":}
{pc:content action="lists" catid="6" order="id DESC" thumb="" moreinfo="" return="data" }
的含义是:
查询内容数据表(lists)
条件为分类号为 6
按 id 降序排列
将结果放到名为 data 的数组中
select * from lists where catid=6 order by id desc
{loop $data $n $r}
{/loop}
的含义是:对查询得到的数组循环输出
foeeach($data as $n=>$r) { echo "<li><a href=\"{$r['url']}\" title=\"{$r['title']}\">{$r['title']}</a></li>":}
lists不是一个表,而是一个方法,参见phpcms手册
那你就在手册里找答案呗
我不用 phpcms 所以我在网上找答案 http://bbs.phpcms.cn/thread-287675-1-1.html
方法1:找到phpcms的模板引擎,单独解析这段字符串
方法2:手动将模板标签改写成php脚本
PC标签的编译,可以看下系统类库中的模板引擎phpcms/libs/classes/template_cache.class.php中的pc_tag()方法
{pc:模块名/操作方式 参数名="参数值"}{/pc}
像{pc:content action="lists" catid="6" order="id DESC" thumb="" moreinfo="" return="data" },实际上是调用内容模块的内容列表。
通过catid确定栏目所属的模型及表名,return则为返回的查询结果的变量名。
这一步,可以看phpcms/modules/classes/content_tag.class.php。这是pc标签调用content模块时用的类。
方法1:找到phpcms的模板引擎,单独解析这段字符串
方法2:手动将模板标签改写成php脚本
能说说方法吗,如何单独解析,有点晕
方法1:找到phpcms的模板引擎,单独解析这段字符串
方法2:手动将模板标签改写成php脚本
能说说方法吗,如何单独解析,有点晕
所以我写了方法2...
不过更好奇为什么要把模板内容转到php中
方法1:找到phpcms的模板引擎,单独解析这段字符串
方法2:手动将模板标签改写成php脚本
能说说方法吗,如何单独解析,有点晕
所以我写了方法2...
不过更好奇为什么要把模板内容转到php中
方法二在哪里呢,最好别太笼统了,象我们这样的菜鸟要具体 的方法,
菜鸟...都是谦虚且懂礼貌的
#1已经回答你了
菜鸟...都是谦虚且懂礼貌的
#1已经回答你了
菜鸟...都是谦虚且懂礼貌的
#1已经回答你了
你能不能别捣乱啊,不说话你不会死的,相信我
#1已经回答你了啊,你自己去找lists方法,看用的是哪张表,把表名替换一下不久好了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Alipay PHP...

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.
