italiano
  • english
  •  
     
     
    BEdita | Semantic Content Management Framework

    My first frontend

    BEdita package contains a folder named frontend. 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 (frontend/debug.example.com) to better understand some basic conepts. As you may already know, there are two other frontends available: site.example.com, a simple web site and dummy.example.com, a dummy/empty publishing.

    Suppose that frontend/debug.example.com is reachable at

    http://www.example.com

    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 where you can define the homepage section: normally you will use publication id as default (1).
    If it doesn't work check your webroot/index.php and config/bedita.sys.php, or use bedita shell script (cake.sh bedita checkApp) to check your settings.

    By default Smarty is BEdita's default template engine but you can use CakePHP's View class simply setting in beditaBeforeFilter method of controllers/pages_controller.php

    $this->view = 'View';

    and using .ctp file extension instead of .tpl. In frontend/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

    http://www.example.com/section-nickname

    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/sections/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:

    http://www.example.com/section-nickname
    http://www.example.com/section/section-nickname
    http://www.example.com/section-nickname/sub-section-nickname
    http://www.example.com/section/section-nickname/sub-section-nickname

    And so on... the same using numeric id's instead of nicknames.

    $section array

    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

    languages

    array containing all the available translations.

    [languages] => Array (
       [eng] => Array ( [title] => section title ) ),
       [deu] => Array(....),
    .....

    pathSection

    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.

    path

    canonical section path in the form /main-section/sub-section/sub-subsection...

    childSections

    array containing sections children

    childContents

    array containing all objects, sections excluded

    These last arrays could be divided by object type (see "Frontend: advanced manage")

    currentContent

    array containing current section content

     

    toolbar

    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:

    http://www.example.com/content-nickname

    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 $section["contentRequested"] variable.
    If an object is present in more than one section then you just specify the section in the URL

    http://www.example.com/section-nickname/content-nickname

    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

    relations

    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(0 => object1, 1 => object2, ....)
       [seealso] => array
    (0 => object1, 1 => object2, ....)
       ....
       [place] =>
    array(0 => object1, 1 => object2, ....)
       ....
    )

     

    What else?

    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.

    XML

    Write in address bar:

    http://www.example.com/xml/section-nickname

    or if you prefer having data in XML tags format

    http://www.example.com/xml/section-nickname/format:tags

    JSON

    Likewise it's simple to obtain a JSON object, for example to use in an Ajax call.

    http://www.example.com/json/nickname-section

    Write a comment