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

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

主站蜘蛛池模板: 镇远县| 会泽县| 唐河县| 和林格尔县| 宁蒗| 广丰县| 曲松县| 象山县| 资中县| 顺平县| 宁波市| 淮阳县| 宜城市| 丹凤县| 紫阳县| 凤翔县| 莎车县| 红安县| 永修县| 景德镇市| 上虞市| 会宁县| 邢台县| 固原市| 桃园县| 东源县| 余江县| 隆尧县| 湘潭市| 阳原县| 岳阳市| 左权县| 额尔古纳市| 清苑县| 洱源县| 溧水县| 两当县| 烟台市| 乐山市| 棋牌| 德安县|