官术网_书友最值得收藏!

  • concrete5 Cookbook
  • David Strack
  • 548字
  • 2021-08-13 16:15:54

Introduction

At the center of almost any content management system is the concept of pages. concrete5 pages contain reusable portions of content called blocks. Blocks can contain anything from formatted text content that you enter yourself, to photo slideshows, to videos, to custom forms that you have developed that contain special functionality. concrete5 pages are extensions of the internal Collection object, which gets its name from the fact that it contains a collection of blocks that make up the page.

Since pages on a website usually contain repeating areas of information (perhaps a sidebar with some persistent widgets), concrete5 includes the concept of page types. Page types allow you to define different templates for creating new pages in concrete5. They are used to specify a default set of blocks, content, and special attributes that are added to new pages of that type, as well as to create different visual layouts through the concrete5 website.

A common page type would be Left Sidebar, which contains a list of links in the sidebar with an area to add blocks of content on the right. A normal concrete5 installation comes with a few default page types out of the box, including Left Sidebar and Full Width. In code, page types are referred to either by their unique numerical ID in the database, or more commonly, a human readable identifier called a handle. The Left Sidebar page type, for example, would have a handle of left_sidebar.

When adding pages to a concrete5 website through the user interface, you will likely notice that the first step is choosing a page type. Page types are also used by the Composer feature of concrete5, which can assist in creating several pages of the same type (such as blog posts).

There are two types of pages in concrete5, the first being a standard page that gets added to the sitemap and gets assigned a page type, and the second a single page, which is handled a bit differently and does not get assigned a page type. This chapter will deal with pages of the first type.

A note about the code in this chapter

Typically, you will write code that interacts with pages and page types in a block, a controller, or a model in your concrete5 application. For the purpose of these demonstrations, you can place the code anywhere where concrete5 lets you execute arbitrary PHP code.

A great place for this is to add a site_process.php or site_post.php file to your site's root /config directory. concrete5 will execute all of the code in that file once all of the core classes and libraries have been loaded (site_post gets executed before the current page has been loaded, site_process gets executed after the current page has been set). We will use classic PHP debugging techniques to verify that our code is working. Typically, we will dump the contents of a variable using PHP's var_dump or print_r functions followed by an exit command.

Because the debugging techniques used in this book can interrupt the regular functionality of a concrete5 website, it is recommended that you perform these exercises on a development copy of concrete5.

Be sure to comment out or remove the debugging code once you are finished, to resume the normal functionality of your concrete5 website.

主站蜘蛛池模板: 高淳县| 关岭| 南召县| 宝应县| 黄冈市| 高阳县| 当阳市| 襄垣县| 郯城县| 扶风县| 迁西县| 新沂市| 柘荣县| 平武县| 锡林郭勒盟| 望城县| 濮阳市| 夏津县| 宁阳县| 武宁县| 康马县| 黎平县| 荔波县| 德州市| 辽阳县| 宾川县| 望谟县| 平远县| 鄂托克旗| 陈巴尔虎旗| 贵德县| 崇义县| 镇安县| 涟源市| 景德镇市| 昭苏县| 北海市| 东乌珠穆沁旗| 滦南县| 青阳县| 巴南区|