BEdita package contains a folder named
frontends. This is where you will find some frontend samples, we'll start from here.
In this article we are going to use a debug frontend (frontends/debug.example.com) to better understand some basic conepts. As you may already know, there are two other frontends available: wp.example.com, a simple web site based on Twenty Ten Wordpress theme, dummy.example.com, a dummy/empty publication and html5.example.com a dummy HTML 5 frontend.
Suppose that frontends/debug.example.com is reachable at
Write it in the browser address bar and you could see a page with the language in use, current section, publication and configuration details, template data available and sections tree.
This root page is defined in config/routes.php that lead to
FrontendController::route() method to load the first section of the publication related to frontend through
$config['frontendAreaId'] variable you can find in config/frontend.ini.php file.
If it doesn't work check your
config/bedita.sys.php, or use bedita shell script (cake.sh bedita checkApp) to check your settings.
$this->view = 'View';
and using .ctp file extension instead of .tpl. In frontends/debug.example.com/view you will find the views/templates. You can play with this frontend and learn how frontends in BEdita work simply by using it.
Nickname and id
In the following paragraphs and examples we will make heavy use of nicknames. A nickname is a unique alphanumeric semantic name for every BEdita object of an instance: you will find it in the Advanced Properties block of every object detail in backend (sections, documents, news, images,....). Let's use that nickname or the object id from now on.
So, for a specific section you've created digit
using a real nickname instead of section-nickname. Now you are on this section page, and you will see how content/section details are changed.
The page you see refers to
views/pages/generic_section.tpl view, but if you create a template named views/pages/section-nickname.tpl then this will be used.
In this way every section is highly customizable and you can be able to create a different template for each section of your site.
Here's a url list on how to reach the same section:
And so on... the same using numeric id's instead of nicknames.
Let's see the main features of $section array that you will have available in the view when you make a call like above. Have a look at "current section: $section" paragraph and click on show/hide.
You will see the array dump that contains section data like "title", "description", etc...
Array ( ['id'] => 2 ['syndicate'] => 'on' ['priority_order'] => 'asc' ['object_type_id'] => 3 ['status'] => 'on' ['created'] => '2008-04-23 08:29:46' ['modified'] => '2008-04-23 08:29:46' ['title'] => 'section title' ['nickname'] => 'section-nickname' ['description'] => ['current'] => 1 ['lang'] => 'ita' ['ip_created'] => '127.0.0.1' ['user_created'] => 1 ['user_modified'] => 1 ['rights'] => ['license'] => ['creator'] => ['publisher'] => ['note'] => ['fixed'] => 0 ['comments'] => 'off' ... );
besides these you'll find
array containing all the available translations.
['languages'] => Array ( ['eng'] => Array ( ['title'] => //section title ), ['deu'] => Array(...), ... );
array that contains the sections parents. It's build using sections id as array keys and ordered by depth: the first element will be the more distant ancient and the last element the parent.
canonical section path in the form /main-section/sub-section/sub-subsection...
array containing sections children
array containing all objects, sections excluded
These last arrays could be divided by object type
array containing the current content of a section. With
currentContent contains the object with nickname as content-nickname. With
currentContent contains the first child of section with nickname as section-nickname
array of pagination data:
['toolbar'] => Array ( ['first'] => 0, ['prev'] => 0, ['next'] => 0, ['last'] => 0, ['size'] => 2, ['pages'] => 1, ['page'] => 1, ['dim'] => 100000, ['start'] => 1, ['end'] => 2 );
Get a specific object
So far we have seen how to get section data, but how can I get another object? Nothing could be easier:
BEdita will understand if the object is a section or a content and if it's a content will search the first section that contains it and load the
$section array like we saw above. Moreover in the
currentContent array will be placed the searched object and will be setted to true the
If an object is present in more than one section then you just specify the section in the URL
What's inside an object?
The array structure of all objects is similar to
$section with regard to general data and object languages. It will have some specific data like GeoTag, Category, Tag, etc... and
this array contains semantic relations between objects, some of these are already defined, but you could build your specific relations. The array structure is:
['relations'] => Array ( ['attach'] => array(  => object1,  => object2, ...) ['seealso'] => array(  => object1, => object2, ...) ... ['place'] => array(  => object1,  => object2, ...) ... ) ;
To finish this first frontend overview we see how to do REST calls to obtain the same $section array but in XML or JSON format.
Write in address bar:
or if you prefer having data in XML tags format
Likewise it's simple to obtain a JSON object, for example to use in an Ajax call.