如何使用 Zend Framework 提供静态页面

发布于 2024-07-18 16:54:47 字数 241 浏览 6 评论 0原文

目前,我们的网站采用 Zend Framework 和 MVC 模式。 我们有大量静态页面,它们位于网站的随机区域。 这些页面不是可以完全绕过 ZF 的简单 HTML 页面...它们将参与 Zend_Layout 等。

在不为每个随机页面创建单独的操作/控制器的情况下提供这些页面的最佳方法是什么? 重做页面布局,使它们全部落入“杂项”控制器或其他东西的控制下,这不是一个选项,出于 SEO 目的,页面需要保留在 URL 层次结构中的位置。

We currently employ Zend Framework and the MVC pattern on our website. We have large numbers of static pages, which are in random areas of the site. These pages are not simple HTML pages that can bypass ZF altogether... they would participate in the Zend_Layout, etc.

What is the best way to serve these pages without creating a separate action/controller for each random page? Redoing the layout of the pages so that they all fall under a "misc" controller or something is not an option, the pages need to stay where they are in our URL hierarchy for SEO purposes.

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

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

发布评论

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

评论(1

小红帽 2024-07-25 16:54:47

如果我正确理解这个问题:

  • 您有一堆静态内容想要应用布局。
  • 这些静态内容页面已经具有您不想破坏的现有 url,

Zend 实际上将 URL 与 $controller->action() 分开,恰好 Zend 的 MVC 部分有一个默认设置来执行此操作。 您仍然可以创建一个“杂项”控制器来接收任何随机 url,您只需要定义一些自定义路由。

http://framework.zend.com/manual/en/zend.controller .router.html

引用 Zend Framework 站点示例:

$route = new Zend_Controller_Router_Route_Static(
    'login',
    array('controller' => 'auth', 'action' => 'login')
);
$router->addRoute('login', $route);

以上路由将匹配以下网址
http://domain.com/login,然后调度
到 AuthController::loginAction()。

在同一页面上可以找到更多使用模式匹配的示例。

If I understand the question properly:

  • You have a bunch of static content you would like to apply your layout to.
  • These pages of static content already have existing urls you don't want to break

Zend actually separates URL from $controller->action(), it just so happens the MVC part of Zend has a default setting to do this. You can still create a "misc" controller which receives any random url, you just need to define some custom routes.

http://framework.zend.com/manual/en/zend.controller.router.html

quoting example Zend Framework site:

$route = new Zend_Controller_Router_Route_Static(
    'login',
    array('controller' => 'auth', 'action' => 'login')
);
$router->addRoute('login', $route);

Above route will match a URL of
http://domain.com/login, and dispatch
to AuthController::loginAction().

More ambitious examples using pattern matching can be found on the same page.

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