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

  • 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.

主站蜘蛛池模板: 分宜县| 江城| 郧西县| 乌鲁木齐县| 缙云县| 祁东县| 胶州市| 洪洞县| 航空| 尼勒克县| 常熟市| 台东县| 涟源市| 醴陵市| 固阳县| 渭源县| 宣汉县| 长宁区| 延津县| 陇川县| 布尔津县| 东辽县| 施甸县| 密云县| 宁都县| 故城县| 乾安县| 安泽县| 二手房| 肇源县| 九江市| 五台县| 西青区| 台中市| 德钦县| 浠水县| 满洲里市| 高尔夫| 探索| 新竹县| 辰溪县|