- 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.
- Objective-C應用開發全程實錄
- What's New in TensorFlow 2.0
- Mastering SVG
- Reactive Programming with Swift
- WSO2 Developer’s Guide
- Learning Data Mining with R
- Corona SDK Mobile Game Development:Beginner's Guide(Second Edition)
- Arduino家居安全系統構建實戰
- Kubernetes源碼剖析
- Laravel Application Development Blueprints
- SQL Server 2012 數據庫應用教程(第3版)
- SQL Server實例教程(2008版)
- Ionic3與CodePush初探:支持跨平臺與熱更新的App開發技術
- C/C++代碼調試的藝術
- Parallel Programming with Python