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

  • concrete5 Cookbook
  • David Strack
  • 410字
  • 2021-08-13 16:16:02

Introduction

In addition to robust content editing features, concrete5 comes with a powerful tool to manage static files on your website, called the file manager. The file manager is where you can store any type of static document, including images, videos, PDFs, documents, and audio files. The file manager allows you to create downloadable links to the files, embed photos into your site content, and much more. You can even assign permissions to files inside the file manager to allow for greater control in deciding what files users can download.

Working with files through the concrete5 interface is a delight, but sometimes you will want to integrate the powerful functionality of the file manager into your own custom applications built in concrete5. In this chapter, we will show how to interact with files, upload new files, and even upload new files to the file manager.

A note about the code in this chapter

Much of the code presented in this chapter can go just about anywhere in a concrete5 application. Since we are just going to be trying out simple code snippets, it makes sense to experiment with this code in a sandbox area. There are a few places in concrete5 that make sense for this, but we will be using /config/site_post.php to test out our code.

It is a good idea to erase any experimental and arbitrary code from site_post.php after each recipe, so that your site is ready for the next exercise.

Also, we will need to dump the contents of variables from time to time. Each PHP developer has his or her own way of doing this, but in this chapter we will be using a custom debug function. You may recognize this function from Chapter 1, Pages and Page Types. We will continue using it here, as it makes the output easy to read and saves some time while developing.

Place the following PHP function at the top of /config/site_post.php:

function my_debug($var) {
   echo '<pre>';
   print_r($var);
   echo '</pre>';
   exit;
}

Now we can dump variable contents by calling my_debug($variableName) and see a nicely formatted output of the contents of the variable. Feel free to use print_r or var_dump as an alternative.

Placing debug code in site_post.php is great for experimentation and trying out the concrete5 API, but it will disrupt the regular operation of a concrete5 website. It is recommended that all of the recipes in this chapter be performed on a testing copy of concrete5.

主站蜘蛛池模板: 视频| 固阳县| 泰和县| 安泽县| 城口县| 湖口县| 枣庄市| 望奎县| 深水埗区| 广元市| 栾川县| 沙雅县| 济南市| 贵德县| 周宁县| 博乐市| 泸州市| 嘉义县| 久治县| 岑巩县| 页游| 重庆市| 乌拉特中旗| 棋牌| 岳阳市| 临沧市| 定日县| 菏泽市| 湟中县| 霍山县| 家居| 洪雅县| 金乡县| 馆陶县| 桂平市| 安化县| 宜兰县| 宁城县| 萍乡市| 丰县| 满洲里市|