Download the PHP package davidyell/viewbits without Composer
On this page you can find all versions of the php package davidyell/viewbits. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download davidyell/viewbits
More information about davidyell/viewbits
Files in davidyell/viewbits
Package viewbits
Short Description CakePHP 2.x component for dynamically loading content as bits into a page matched by route.
License
Informations about the package viewbits
ViewBits Component
Why?
I needed a way to allow certain blocks of content in a view to be content managed without affecting the layout.
What it does
It will hook beforeRender()
to match a route in order to load the View Bits that you need for that route. So that you can include them in your views.
Compatability
Compatible with CakePHP 2.x
. (Developed on 2.2.3
)
Installation
- Download and unzip into
app/Plugins/ViewBits
- `
- `
Setup
First you will need to create the database table to store your View Bits.
Import the view_bits.sql
file from app/Plugin/ViewBits/Config/Schema/view_bits.sql
OR
You can use CakeDC/migrations to run the migration file.
`
Then you'll want to enable the plugin in your app/Config/bootstrap.php
with CakePlugin::load('ViewBits')
. If you are already using CakePlugin::loadAll()
then you don't have to worry.
To enable the component it will need to be included in your controllers $components
array. I'd suggest adding it to your AppController.php
``
Usage
The component will match based on the routes in the url. So if you add a View Bit with a route of /
it will be loaded on your root or home page. If you add one with a route of /pages/display/about
it will show up on your about page.
Wild cards are also supported in the routing using *
. If you add a route of *
the ViewBit will be loaded on all pages. You can combo them up such as /users/*
which will load on all the UsersController routes.
In order to display your View Bits, you'll need to include the plugin helper which outputs the content. In your controller you must add the helper to your helpers array.
``
Example
``
What you have to do
You'll need to customise the admin interface and deal with hooking it into your current admin. The admin views are based on my NiceAdmin plugin.
Todo
v0.1 Milestone
Create a helper to replace the elementCome up with a better way to manage multiple View Bits in the new HelperOrdering so that bits are loaded in the page orderEnhance the route matching to take regex, wildcards or similarValidate the routes to make sure they existCustom validation function to lookup routes and make sure they existSetup for Composer and add to Packigist
License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.