CMS永久链接和模板系统如何?

发布于 2024-11-14 07:21:51 字数 1126 浏览 7 评论 0原文

我想了解如何在 php 网站上使用模板系统和永久链接:D!..

让我更多地描述一下我自己,

1.目前我有 20 个文件,每个文件都有自己的 php 逻辑(index.php、wizard.php、search.php)。 PHP 等) 全部使用相同的类并包含。(install.php 包括我的项目中所有类的所有必需的 abd u require_once(install.php) 在所有文件中)

我想将我的网站改造成。

Analyze URL requested ---> IDENTIFY requested page ---> GET TEMPLATE for THIS PAGE -->MODIFY header(meta) and footer(javascript) ---> add logic ---> display page :D.

有人能让我走上正确的学习轨道吗:D!。因为我用 oop 完全编码了我的网站,并使其所有内容从 MYSQL(简单的小型 CMS)动态加载,但我不知道如何将模板和 php 加入索引,而无需重复我自己并为我的网站中的每个页面创建不同的文件! (当然每个文件都做不同的工作,比如文件 users.php 负责登录、注册和用户配置文件等)

希望我的英语不是太差,你能理解我的问题:D!

到目前为止我目前的方法:

Mysql 表:page_tbl 列:页面名称、逻辑文件、模板文件、元标记。

index.php?pagename

将检查是否尚未缓存或未列出以进行追踪:

Mysql:SELECT * WHERE pagename='$_GET['page']'

loginfiles = cars.php,search.php (将用 , 进行分解并包含在内) 模板文件=也会根据MetaTag进行分解和修改。 Metatag:序列化关联数组,['name']=['value'];

然后我开始缓冲输出,用新的描述和关键字替换模板(自动生成) 包含逻辑文件 包括 footer.php (其中包括脚本)

我接近正确的路线还是还很远?还是我失去了踪迹并过度杀戮

I want to understand how to use templating system and permalinks on php websites :D !..

let me describe my self more,

1.currently i have 20 files each have its own php logic (index.php,wizard.php,search.php etc)
ALL use same class's and includes.(install.php include all the required for all class's in my project abd u require_once(install.php) in all files)

i wana remodel my website into.

Analyze URL requested ---> IDENTIFY requested page ---> GET TEMPLATE for THIS PAGE -->MODIFY header(meta) and footer(javascript) ---> add logic ---> display page :D.

can some one put me on right learning track :D !. cuz i hv coded my website fully in oop and made all its content loads dynamically from MYSQL (simple small CMS) but i have no clue how to join template and php into index without repeating my self and create different file for each page in my web ! (each file do different jobs of course like file users.php does login and registration and userprofile etc)

Hope my english wassnt too too bad and u could understand my question :D !

My current approach so far:

Mysql table : page_tbl
columns: pagename,LogicFile,templateFile,MetaTag.

index.php?pagename

will check if not already cached or not listed for chacing it will :

Mysql:SELECT * WHERE pagename='$_GET['page']'

loginfiles = cars.php,search.php (will be exploded with , and included)
Template files = will be also exploded and modified according to MetaTag.
Metatag: Serialized assoc array with ['name']=['value'];

Then i start buffer output , replace template with new descriptions and keywords(auto generated)
include logic files
include footer.php (which include the scripts)

am i near to correct rout or still far away ? or am did i lose my track and over killing

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

遥远的她 2024-11-21 07:21:51

如果您不确定是要自己编写还是使用现有的。

  • 这很可能是一次非常有价值的经历,但编写自己的经历却非常耗时。
  • 如果您手头有一项需要解决的任务,请使用现有的任务。

话虽如此,有很多模板系统,smarty 是最长寿的一个。您可以在 phpbuilder 找到关于 5 个流行的简短讨论< /a>.

您还可能需要考虑整个框架。它们不仅仅是一个模板系统,还包括数据库、ajax 助手等。 ZendCakePHPCodeigniter 是流行的。您可以在 phpframeworks 上找到这些内容的比较。

If you are unsure whether you want to write your own, or use an existing one.

  • It is going to be a quite possibly very rewarding experience but a very time consuming one to write your own.
  • If you have a task at hand that you need to be solved, use an existing one.

That being said there are plenty of templating systems, smarty being the most long-lived one. You can find a short discussion on 5 popular ones at phpbuilder.

You also have entire Frameworks that you might want to consider. They are more than just a templating system, where database stuff, ajax helpers etc are included. Zend, CakePHP, and Codeigniter being popular ones. You can find comparisons of these at phpframeworks.

趁年轻赶紧闹 2024-11-21 07:21:51

最好的方法是采取这种路线:

  • 解析请求数据
  • 确定将
  • 在控制器中使用的控制器选择布局和模板[布局“包含”模板,它保存所有页面通用的内容,模板具有特定于请求的内容]
  • 在控制器中还从数据库中获取数据[MVP方式]
  • 将数据分配给数组并将其传递给布局,它将数据进一步传递给
  • 布局中的模板,模板使用该数组中的数据并构造视图
  • 将所有内容传递给浏览器

这就是框架的工作方式,而且还不错。 ;]

The best way is to take this route:

  • parse request data
  • determine controller which will be used
  • in controller select layout and template [layout "includes" template, it hold the contents that are common to all pages and template has the request-specific content]
  • in controller also fetch the data from database [MVP way]
  • assign data to array and pass it to the layout, it'll pass the data futher to the template
  • in layout and template use data from that array and construct view
  • pass everything to the browser

This is the way the frameworks work, and it isn't that bad. ;]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文