https://github.com/philecms/philerender
Render the content of a page by passing it's URL
https://github.com/philecms/philerender
philecms-plugin
Last synced: 10 months ago
JSON representation
Render the content of a page by passing it's URL
- Host: GitHub
- URL: https://github.com/philecms/philerender
- Owner: PhileCMS
- License: mit
- Created: 2014-03-17T02:07:15.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-19T13:28:27.000Z (almost 12 years ago)
- Last Synced: 2025-05-18T23:09:51.470Z (about 1 year ago)
- Topics: philecms-plugin
- Language: PHP
- Homepage:
- Size: 195 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
phileRender
===========
Render the content of a page by passing it's URL.
**This plugin requires that you use Twig for your template engine**
### 1.1 Installation (composer)
```
php composer.phar require phile/render:*
```
### 1.2 Installation (Download)
* Install [Phile](https://github.com/PhileCMS/Phile)
* Clone this repo into `plugins/phile/render`
### 2. Activation
After you have installed the plugin. You need to add the following line to your `config.php` file:
```
$config['plugins']['phile\\render'] = array('active' => true);
```
### Usage
There will now be a new twig function called `render`. It takes a URL to a page, and renders the HTML for it!
#### Basic Examples:
The path is the same as the way we load pages via URLs.
Let's say we have a page at `content/special.md`, then we will use:
```html
{{ render('special') }}
```
This will render the HTML of the `special` page.
Let's say we have a page at `content/sub/special-nested.md`, then we will use:
```html
{{ render('sub/special-nested') }}
```
This will render the HTML of the `sub/special-nested` page.
#### Conditional Examples
In the config file you can set conditionals so you don't load a page that may not be setup for loading in this way.
```php
return array(
'conditional_checks' => array(
'template' => 'partial',
'role' => 'custom'
)
);
```
This conditional means: only load pages that have a template of 'partial' and a role that is 'custom'. We can use *any custom meta* for the conditionals. We can also use multiple key => values for checking as you can see from the example.
### Errors
This plugin will fail silently if no page is found, or the conditional is not met.