When you work on templates using CakePhp, you use (or should use) cake helpers (for instance: FormHelper, HtmlHelper, JavascriptHelper, etc.). If you don't know what an Helper is, take a look at cakephp documentation page about helpers, before continuing to read this article.

In BEdita you can use CakePhp helpers and BEdita helpers as well, powered by the Smarty Template Engine syntax (more details about Smarty syntax can be found in Smarty Documentation). BEdita helper names start with "Be": BeEmbedFlashHelper, BeEmbedMediaHelper, BeFrontHelper, BeThumbHelper, BeTimeHelper, BeToolbarHelper, BeTreeHelper, BeurlHelper (check them in BEdita API documentation).

No matter the type of the Web application or site or whatever you are building, in frontend templates development you have to face several common tasks: the default template page usually contains a title, a description, a block of keywords, some metadata, a menu, some statistics, feeds, a breadcrumb block, and so on.
BeFrontHelper's aim is to help template developer with most common tasks, dealing with "templates topics" more than "controller/business logic". Developing BeFrontHelper, BEdita staff studied deeply SEO issues and metadata management: business logic reflects some decisions taken by BEdita developers discussing SEO documentation.

Let's see an example from dummy example site in bedita "ulmus" release: bedita-3.1-ulmus/frontends/dummy.example.com/views/layouts/default.tpl.

{$html->docType('xhtml-trans')}
< html xmlns="http://www.w3.org/1999/xhtml" lang="{$currLang}" dir="ltr" >
   < head >
      {$html->charset()}
      < title >
         {$beFront->title()}
      < / title >
      {$beFront->metaAll()}
      {$beFront->metaDc()}
      < link rel="icon" href="{$html->webroot}favicon.png" type="image/png" / >
      {$beFront->feeds()}
      {$scripts_for_layout}
   < / head >
   < body >
      {$view->element('header')}
      {$content_for_layout}
      {$view->element('footer')}
      {$beFront->stats()}
   < / body >
< / html >

In this example, BeFrontHelper is used in 5 calls, respectively the methods are "title", "metaAll", "metaDc", "feeds" and "stats". Lets see what these methods (and some others) do.

{$beFront->title()}

BeFrontHelper function title return a default title for a page, according to page content and/or section/publication.

The title is like: "publication title/publication name" - "section title/current content title".
A good SEO point: distinguish titles inside a Web application or Website, according to real context content of a page.
This method works in that direction.

{$beFront->metaAll()}

{$beFront->metaAll()} generates html tags for content metadata: "description", "author", "http-equiv" and "generator".
"Description" is the first not empty value among the following:

  • currentContent["description"]
  • currentContent["abstract"] truncated to 255 characters
  • currentContent["body"] truncated to 255 characters
  • section["description"]
  • publication["description"]

Note: meta "description" can be obtained separately calling the method:

{$beFront->metaDescription()}

"Author" meta tag can be omitted, in case "license" field is not found in the following objects:

  • currentContent
  • section
  • publication

{$beFront->metaDc()}

It returns html-DC tags DC.title, DC.description, DC.format, DC.language, DC.creator, DC.publisher, DC.date, DC.modified, DC.identifier, DC.rights, DC.license. For more details about Dublin Core Html Tags, look at Expressing Dublin Core in HTML/XHTML meta and link elements.

{$beFront->feeds()}

When there are feeds, this method display feeds links; for instance:

< link rel="alternate" type="application/rss+xml" title="Blog" href="/rss/blog" / >
< link rel="alternate" type="application/rss+xml" title="News" href="/rss/news" / >

 

{$beFront->stats()}

It returns publication stats code, if set (only if frontend app is not staging site).

{$beFront->menu()}

Tree structure returned in html unordered list, with links to the contents.

{$beFront->breadcrumb()}

It returns the breadcrumb trail for the page.

--
Let's say something about smarty variables used in the examples of this article.

The variables {$currentContent}, {$section}, {$publication} refer to BEdita objects set by FrontendController.

{$currentContent} is the main object of the page (can be referred directly through url like http://www.bedita.com/blog/template-development-befront-helper). {$currentContent["description"]}, {$currentContent["abstract"]} and {$currentContent["body"]} refer to the content of Document->description, Document->short text and Document->long text of the Document view in Bedita backend application (for example http://mybeditaapp/documents/view/).

{$section} and {$publication} are respectively Section and Publication objects for the url, if any. For example this document is inside Section "blog" of Publication "BEditafrontsite", and the {$currentContent} in this page is the Document that you are reading.