<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0"><channel><title>BEdita Documents and Resources | Frontends</title><link>http://docs3.bedita.net/frontends</link><description>Developing applications</description><language>eng</language><item><title>URL-friendly content translations</title><description>&lt;hr/&gt;&lt;p&gt;As of version &lt;strong&gt;3.6.0&lt;/strong&gt;, BEdita is distributed with an improved system to serve content translations in a URL-friendly way. This new feature is fully backwards-compatible, though it may need some minor changes in your frontend PHP code to actually gain advantage of it.&lt;/p&gt;

&lt;h1&gt;Routing&lt;/h1&gt;

&lt;p&gt;The first change that will need to be made in your frontend is about routes. To achieve URL consistency in a easy and reliable way, as well as leaving developers some flexibility on how internationalized URLs are shown to end-users, a change needs to be made in your frontend&#039;s &lt;code&gt;config/routes.php&lt;/code&gt;:&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
/***** FROM *****/
Router::connect(&#039;/*&#039;, array(&#039;controller&#039; =&amp;gt; &#039;pages&#039;, &#039;action&#039; =&amp;gt; &#039;route&#039;));
/****** TO ******/
Router::connect(&#039;/lang/:lang/*&#039;, array(&#039;controller&#039; =&amp;gt; &#039;pages&#039;, &#039;action&#039; =&amp;gt; &#039;route&#039;), array(&#039;lang&#039; =&amp;gt; &#039;[a-z]{2,3}&#039;, &#039;persist&#039; =&amp;gt; array(&#039;lang&#039;)));
Router::connect(&#039;/*&#039;, array(&#039;controller&#039; =&amp;gt; &#039;pages&#039;, &#039;action&#039; =&amp;gt; &#039;route&#039;));
&lt;/pre&gt;

&lt;p&gt;Of course, you can change &lt;code&gt;/lang/:lang/*&lt;/code&gt; to whatever you want (you could choose to leave just &lt;code&gt;/:lang/*&lt;/code&gt;, for instance), as long as the &lt;code&gt;:lang&lt;/code&gt; placeholder appears somewhere in your route. You should take care of avoiding conflicts with existing routes and/or other URLs of any kind.&lt;/p&gt;

&lt;h1&gt;Linking to translated content&lt;/h1&gt;

&lt;p&gt;To provide consistent links to translated content, a further update in your code will likely be needed.&lt;/p&gt;

&lt;p&gt;If you took advantage of CakePHP&#039;s &lt;code&gt;HtmlHelper::url()&lt;/code&gt; and &lt;code&gt;HtmlHelper::link()&lt;/code&gt; methods by passing them an array of routing elements as argument, then you are already done.&lt;/p&gt;

&lt;p&gt;On the other hand, if you used pre-built strings to generate links within your frontend (i.e. &lt;code&gt;$html-&amp;gt;url(&#039;/my-section/my-document&#039;)&lt;/code&gt;), you might want to use &lt;code&gt;BeHtmlHelper::url()&lt;/code&gt; and &lt;code&gt;BeHtmlHelper::link()&lt;/code&gt; to achieve URL consistency without having to rewrite all internal links. Please be aware and always keep in mind that this is &lt;strong&gt;not&lt;/strong&gt; the preferred method: you &lt;strong&gt;should always&lt;/strong&gt; pass an array to those function to link internal resources, so consider this as your last resort.&lt;/p&gt;

&lt;h2&gt;Using &lt;code&gt;BeHtmlHelper&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;First of all, your frontend&#039;s&amp;nbsp;&lt;code&gt;PagesController&lt;/code&gt; must declare &lt;code&gt;BeHtmlHelper&lt;/code&gt; in the list of used helpers:&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
public $helpers = array(&#039;BeHtml&#039; =&amp;gt; array(), &#039;BeFront&#039;);
&lt;/pre&gt;

&lt;p&gt;Please note that it should be added &lt;strong&gt;before&lt;/strong&gt; &lt;code&gt;BeFrontHelper&lt;/code&gt; and with an empty array of options. This is due to the way CakePHP handles helpers&#039; instances.&lt;/p&gt;

&lt;p&gt;Now &lt;code&gt;BeHtmlHelper&lt;/code&gt; is loaded and can be used in your view templates. All you have to do is mass-replace any instance of &lt;code&gt;$html-&amp;gt;url(&#039;/some/url&#039;)&lt;/code&gt; and &lt;code&gt;$html-&amp;gt;link(&#039;title&#039;, &#039;/some/url&#039;)&lt;/code&gt; with &lt;code&gt;$beHtml-&amp;gt;url(&#039;/some/url&#039;)&lt;/code&gt; and &lt;code&gt;$beHtml-&amp;gt;link(&#039;title&#039;, &#039;/some/url&#039;)&lt;/code&gt; respectively in your templates to fully achieve URL consistency within and across translations.&lt;/p&gt;

&lt;h1&gt;Generating meta-tags&lt;/h1&gt;

&lt;p&gt;Last of all, you should provide spiders and bots a list of translations available for the current resource. This can easily be achieved with &lt;code&gt;BeFrontHelper::metaAlternate()&lt;/code&gt; function:&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
echo $beFront-&amp;gt;metaAlternate();  // To generate meta-tags for all languages in `$conf[&#039;frontendLangs&#039;]`.
echo $beFront-&amp;gt;metaAlternate([&#039;en&#039;, &#039;it&#039;, &#039;fr&#039;]);  // To generate meta-tags for a list of languages.
echo $beFront-&amp;gt;metaAlternate(false);  // For contents with no translation available.
&lt;/pre&gt;
</description><pubDate>Mon, 31 Aug 2015 11:40:51 +0200</pubDate><link>http://docs3.bedita.net/frontends/url-friendly-content-translations</link><guid>http://docs3.bedita.net/frontends/url-friendly-content-translations</guid></item><item><title>Exception handling</title><description>&lt;hr/&gt;&lt;p&gt;Since 3.6.0 version&amp;nbsp;BEdita&amp;nbsp;ships with a redesigned exception handling system that gives better error responses to client requests.&lt;/p&gt;

&lt;p&gt;With this new design every html/json/xml request will be served with the right response content type (text/html, application/json, text/xml). In this way all errors thrown by an Exception are consistent, output the expected type and set up the same &lt;code&gt;$error&lt;/code&gt; var to the view.&lt;/p&gt;

&lt;p&gt;In order to achieve this the following new components have been introduced:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;new HTTP exceptions&lt;/li&gt;
	&lt;li&gt;a new Exception handler&lt;/li&gt;
	&lt;li&gt;new &lt;a href=&quot;/responsehandler-component&quot;&gt;ResponseHandler&lt;/a&gt; components,&amp;nbsp;&lt;a href=&quot;/jsonview-and-xmlview&quot;&gt;JsonView and XmlView&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;HTTP Exceptions&lt;/h1&gt;

&lt;p&gt;In &lt;code&gt;bedita-app/bedita_exceptions.php&lt;/code&gt;&amp;nbsp; common http error status codes are&amp;nbsp; mapped&amp;nbsp;with exceptions as &lt;code&gt;BeditaBadRequestException&lt;/code&gt;, &lt;code&gt;BeditaNotFoundException&lt;/code&gt;, etc..&lt;/p&gt;

&lt;p&gt;Every Exception sets the right status code and a corresponding message, if any is passed.&lt;br /&gt;
For example&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
/**
* Represents an HTTP 404 error
*/
class BeditaNotFoundException extends BeditaException {
	/**
	* Constructor
	*
	* @param string $message If no message is given &#039;Not Found&#039; will be the message
	* @param mixed $details The exception details
	* @param $res The result status
	* @param int $code Status code, default to 404
	*/
	public function __construct($message = null, $details = null, $res = self::ERROR, $code = 404) {
		if (empty($message)) {
			$message = &#039;Not Found&#039;;
		}
		parent::__construct($message, $details, $res, $code);
	}
}
&lt;/pre&gt;

&lt;h1&gt;Introducing new Exception Handler&lt;/h1&gt;

&lt;p&gt;While previously exceptions were handled through a &lt;code&gt;try {} catch() {}&lt;/code&gt; block in &lt;strong&gt;index.php&lt;/strong&gt; now in &lt;kbd&gt;bedita-app/config/bootstrap.php&lt;/kbd&gt; we are using&amp;nbsp; &lt;code&gt;set_exception_handler()&lt;/code&gt; PHP function.&lt;br /&gt;
For shell scripts the exception handler is defined in &lt;code&gt;BeditaBaseShell::__construct()&lt;/code&gt; instead.&lt;/p&gt;

&lt;p&gt;In order to adopt new errors handling in old frontend apps be sure to remove the &lt;kbd&gt;try catch&lt;/kbd&gt; block from &lt;kbd&gt;app/webroot/index.php &lt;/kbd&gt;replacing it with&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
$Dispatcher = new Dispatcher();
$Dispatcher-&amp;gt;dispatch();
&lt;/pre&gt;

&lt;p&gt;The default exception handler instantiates an &lt;code&gt;AppError&lt;/code&gt;&amp;nbsp;class located at &lt;kbd&gt;bedita-app/app_error.php&lt;/kbd&gt;&amp;nbsp;that takes care of preparing error data for the client and tries to render a view.&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$error&lt;/code&gt; var is identical for any type of response (html/xml/json) and contains the following keys:&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
&#039;status&#039; =&amp;gt; null, // http status code
&#039;code&#039; =&amp;gt; null, // error code
&#039;message&#039; =&amp;gt; null, // error message
&#039;details&#039; =&amp;gt; null, // error details
&#039;moreInfo&#039; =&amp;gt; null, // url to look for more information
&#039;url&#039; =&amp;gt; null // url that caused the error
&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Note that at the current state some keys are always empty&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Following this schema the &lt;code&gt;AppError::setError()&lt;/code&gt; method sets the &lt;code&gt;App::error&lt;/code&gt; property to be serialized and sends the right header to the client based on the http error code thrown.&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
$this-&amp;gt;controller-&amp;gt;ResponseHandler-&amp;gt;sendStatus($this-&amp;gt;error[&#039;status&#039;]);
$this-&amp;gt;controller-&amp;gt;set(array(
	&#039;error&#039; =&amp;gt; $this-&amp;gt;error,
	&#039;_serialize&#039; =&amp;gt; array(&#039;error&#039;)
));
&lt;/pre&gt;

&lt;h2&gt;Setup custom exceptions handler&lt;/h2&gt;

&lt;p&gt;By default &lt;kbd&gt;bedita-app/libs/errors/be_exception_handler.php&lt;/kbd&gt; is used but it is possible to write a custom handler and set it up from configuration. To do so in frontend app you can edit &lt;strong&gt;frontend.cfg.php&lt;/strong&gt; in &lt;kbd&gt;app/config&lt;/kbd&gt; folder&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
Configure::write(&#039;Exception&#039;, array(
	&#039;handler&#039; =&amp;gt; array(
		&#039;class&#039; =&amp;gt; &#039;MyExceptionHandler&#039;,
		&#039;method&#039; =&amp;gt; &#039;myHandleExceptions&#039;
	)
));
&lt;/pre&gt;

&lt;p&gt;The custom class should be placed in &lt;kbd&gt;bedita-app/libs/errors&lt;/kbd&gt; or &lt;kbd&gt;app/libs/errors&lt;/kbd&gt; in frontend app.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Rarely you would use custom exceptions handling&amp;nbsp;in backend, in this case you need to configure it in&lt;/em&gt; &lt;kbd&gt;bedita-app/config/bedita.cfg.php&lt;/kbd&gt; (possible, but NOT recommended)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The custom method accepts an Exception as argument and it has to be defined as public static&lt;/strong&gt;, so following the above configuration we should create the file &lt;kbd&gt;app/libs/errors/my_exception_handler.php&lt;/kbd&gt;&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
class MyExceptionHandler extends Object {

	/**
	* Custom method to handle Exceptions
	*
	* @param Exception $exception
	* @return void
	*/
	public static function myHandleExceptions(Exception $exception) {
		// code here
	}

}
&lt;/pre&gt;

&lt;h1&gt;ResponseHandler Component, JsonView and XmlView&lt;/h1&gt;

&lt;p&gt;It&amp;nbsp;is responsible to respond in the right way to client requests. It&#039;s used by &lt;code&gt;AppError&lt;/code&gt; to send the correct status code and set the &lt;code&gt;$error&lt;/code&gt; var that &lt;a href=&quot;/responsehandler-component&quot;&gt;ResponseHandler&lt;/a&gt;, will eventually serialize it in the right format (json, xml) setting up the right view (&lt;a href=&quot;/jsonview-and-xmlview&quot;&gt;JsonView, XmlView&lt;/a&gt;)&lt;/p&gt;
</description><pubDate>Fri, 10 Apr 2015 11:15:27 +0200</pubDate><link>http://docs3.bedita.net/frontends/exception-handling</link><guid>http://docs3.bedita.net/frontends/exception-handling</guid></item><item><title>Debug toolkit activation</title><description>&lt;hr/&gt;&lt;p&gt;Since BEdita &lt;strong&gt;3.4&lt;/strong&gt; it is possibile to use the&amp;nbsp; &lt;a href=&quot;https://github.com/cakephp/debug_kit&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;CakePHP DebugKit&lt;/strong&gt;&lt;/a&gt;: a debugging toolbar and enhanced debugging tools for CakePHP applications.&lt;/p&gt;

&lt;p&gt;Steps to activate:&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;get the forked version of debug_kit via github (1.3 branch only) simply using:&amp;nbsp;&amp;nbsp;&lt;code&gt;git clone -b 1.3 --single-branch https://github.com/bedita/debug_kit.git bedita-app/plugins/debug_kit &lt;/code&gt;&amp;nbsp; from BEdita core root folder [&lt;strong&gt;NOTE&lt;/strong&gt;: --single-branch option is valid from git version 1.7.10].&lt;/li&gt;
	&lt;li&gt;write&amp;nbsp;&lt;code&gt;$config[&#039;debugKit&#039;] = true;&lt;/code&gt; in &lt;em&gt;bedita-app/config/bedia.cfg.php&lt;/em&gt;&amp;nbsp; (activate for both backend/frontend) or just in frontend.cfg.php (frontend only)&lt;/li&gt;
	&lt;li&gt;now reload your application, you will see the &lt;u&gt;&lt;em&gt;cake&lt;/em&gt;&lt;/u&gt; toolbar in the upper right corner&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Happy debugging :)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; to see sql queries in &lt;u&gt;&lt;em&gt;sql_log&lt;/em&gt;&lt;/u&gt; you should write as usual &lt;code&gt;Configure::write(&#039;debug&#039;, 2);&lt;/code&gt; in &lt;em&gt;config/core.php&lt;/em&gt;&lt;/p&gt;
</description><pubDate>Wed, 08 Apr 2015 17:23:15 +0200</pubDate><link>http://docs3.bedita.net/frontends/debug-toolkit-activation</link><guid>http://docs3.bedita.net/frontends/debug-toolkit-activation</guid></item><item><title>ResponseHandler Component</title><description>&lt;hr/&gt;&lt;p&gt;This component is always attached to any controller and automatically takes care of rendering the right type of view when json or xml are requested. It checks &lt;em&gt;&quot;Accept&quot;&lt;/em&gt; request header, parses url extensions (.json/.xml) and tells the controller to use JsonView or XmlView.&lt;/p&gt;

&lt;p&gt;For example in a frontend app: calling from a client an url like &lt;code&gt;http://example.com/sample.json&lt;/code&gt; or using jQuery&lt;/p&gt;

&lt;pre class=&quot;brush: javascript; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
$.ajax({
	url: &#039;/other_sample&#039;,
	type: &#039;get&#039;,
	dataType: &#039;json&#039;
});
&lt;/pre&gt;

&lt;p&gt;we force ResponseHandler to respond as json to client.&lt;/p&gt;

&lt;p&gt;JsonView and XmlView views check if a special key named &lt;code&gt;_serialize&lt;/code&gt;&amp;nbsp;is in viewVars and&amp;nbsp; serialize all viewVars found in it&amp;nbsp;to present the payload to client.&lt;/p&gt;

&lt;p&gt;Following the example above&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
public function otherSample() {
	$langs = array(&#039;eng&#039; =&amp;gt; &#039;English&#039;, &#039;ita&#039; =&amp;gt; &#039;Italian&#039;);
	$this-&amp;gt;set({
		&#039;langs&#039; =&amp;gt; $langs,
		&#039;_serialize&#039; =&amp;gt; array(&#039;langs&#039;)
	});
}
&lt;/pre&gt;

&lt;p&gt;outputs to client&lt;/p&gt;

&lt;pre class=&quot;brush: javascript; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
{
	&quot;langs&quot;: {
		&quot;eng&quot;: &quot;English&quot;,
		&quot;ita&quot;: &quot;Italian&quot;
	}
}
&lt;/pre&gt;

&lt;h1&gt;Sending&amp;nbsp;Headers&lt;/h1&gt;

&lt;p&gt;The ResponseHandler component is also very useful to send http status code to clients, for example&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
$this-&amp;gt;ResponseHandler-&amp;gt;sendStatus(400);
&lt;/pre&gt;

&lt;p&gt;Sends a &lt;em&gt;&quot;Bad Request&quot;&lt;/em&gt; header.&lt;/p&gt;

&lt;p&gt;or to send any generic header&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
// send content type image/png header to client
$this-&amp;gt;RequestHandler-&amp;gt;sendHeader(&#039;Content-Type: image/png&#039;);
// the same as above
$this-&amp;gt;RequestHandler-&amp;gt;sendHeader(&#039;Content-Type&#039;, &#039;image/png&#039;);
&lt;/pre&gt;

&lt;h1&gt;Setting Type&lt;/h1&gt;

&lt;p&gt;To force a specific type (json or xml)&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
$this-&amp;gt;ResponseHandler-&amp;gt;setType(&#039;json&#039;);&lt;/pre&gt;

&lt;p&gt;or do it globally&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
public $components = array(
	&#039;ResponseHandler&#039; =&amp;gt; array(&#039;type&#039; =&amp;gt; &#039;json&#039;)
);
&lt;/pre&gt;

&lt;h1&gt;Disabling Automatic Response&lt;/h1&gt;

&lt;p&gt;If you don&#039;t want to use ResponseHandler you can disable it in any method of your controller&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
$this-&amp;gt;ResponseHandler-&amp;gt;enabled = false;&lt;/pre&gt;

&lt;p&gt;or globally&lt;/p&gt;

&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
public $components = array(
	&#039;ResponseHandler&#039; =&amp;gt; array(&#039;enabled&#039; =&amp;gt; false)
);&lt;/pre&gt;

&lt;p&gt;Pay attention that disabling ResponseHandler you lose the magic json/xml handling, you have to manage it manually.&lt;/p&gt;
</description><pubDate>Fri, 13 Mar 2015 14:15:20 +0100</pubDate><link>http://docs3.bedita.net/frontends/responsehandler-component</link><guid>http://docs3.bedita.net/frontends/responsehandler-component</guid></item><item><title>JsonView and XmlView</title><description>&lt;hr/&gt;&lt;p&gt;Whenever you need to output json or xml content you can use those special views. Normally BEdita apps automatically use the right View through ResponseHandler component but you can use them whenever you want: for example if you have disabled the ResponseHandler (not recommended) or if you want to force some output.&lt;/p&gt;
&lt;p&gt;To use those views setup them in your controller like&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
$this-&amp;gt;view = &#039;Json&#039;;
&lt;/pre&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
$this-&amp;gt;view = &#039;Xml&#039;;&lt;/pre&gt;
&lt;p&gt;Those views check if a special key named &lt;em&gt;&quot;_serialize&quot;&lt;/em&gt; is in viewVars and if so serialize all viewVars found in &lt;em&gt;&quot;_serialize&quot;&lt;/em&gt; to present the payload to client.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
$this-&amp;gt;view = &#039;Json&#039;;
$this-&amp;gt;set(&#039;section&#039;, $this-&amp;gt;Section-&amp;gt;find(&#039;all&#039;));
$this-&amp;gt;set(&#039;otherData&#039;, array(...));
$this-&amp;gt;set(&#039;_serialize&#039;, array(&#039;section&#039;, &#039;otherData&#039;));
&lt;/pre&gt;
&lt;p&gt;will output the &lt;code&gt;json_encode()&lt;/code&gt; of &lt;code&gt;View::viewVars[&#039;section&#039;]&lt;/code&gt; and &lt;code&gt;View::viewVars[&#039;otherData&#039;]&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Here a frontend app example where ResponseHandler is disabled and json response is handled manually&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
class PagesController extends AppController {
public $components = array(
&#039;ResponseHandler&#039; =&amp;gt; array(&#039;enabled&#039; =&amp;gt; false)
);
public function myMethod() {
$this-&amp;gt;view = &#039;Json&#039;;
$this-&amp;gt;RequestHandler-&amp;gt;respondAs(&#039;json&#039;);
$this-&amp;gt;set(&#039;object&#039;, $this-&amp;gt;loadObj(&#039;nick-object&#039;);
$this-&amp;gt;set(&#039;_serialize&#039;, array(&#039;object&#039;));
}
}&lt;/pre&gt;
&lt;p&gt;If no &lt;em&gt;&quot;_serialize&quot;&lt;/em&gt; view var is found the JsonView or XmlView will try to render a standard view file. It is useful for example if you need to manipulate data before serializing it. Removing &lt;em&gt;&quot;_serialize&quot;&lt;/em&gt;&amp;nbsp;from above example you need to add a view file named &lt;code&gt;my_method.tpl&lt;/code&gt; in &lt;code&gt;views/pages/ folder &lt;/code&gt;and manually build the json you want to output.&lt;/p&gt;
&lt;p&gt;XmlView accepts another special key named &lt;em&gt;&quot;_rootNode&quot;&lt;/em&gt;&amp;nbsp;that you can define to explicit the xml root tag. If it&#039;s not defined the &lt;code&gt;&amp;lt; response &amp;gt;&amp;lt; /response &amp;gt;&lt;/code&gt; tag is used.&lt;br /&gt;
		Example:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
$this-&amp;gt;set(array(
&#039;object&#039; =&amp;gt; $object,
&#039;_serialize&#039; =&amp;gt; &#039;object&#039;,
&#039;_rootNode&#039; =&amp;gt; &#039;object&#039;
));&lt;/pre&gt;
&lt;p&gt;will output &lt;code&gt;$object&lt;/code&gt; in xml format using &lt;i&gt;object&lt;/i&gt; tag as root&lt;/p&gt;
&lt;pre class=&quot;brush: xml; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
&lt;object&gt;
   &lt;id&gt;1&lt;/id&gt;
   ...
&lt;/object&gt;
&lt;/pre&gt;
&lt;p&gt;while&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
$this-&amp;gt;set(array(
&#039;object&#039; =&amp;gt; $object,
&#039;_serialize&#039; =&amp;gt; &#039;object&#039;
));&lt;/pre&gt;
&lt;p&gt;will output&lt;/p&gt;
&lt;pre class=&quot;brush: xml; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;
&lt;response&gt;
  &lt;object&gt;
    &lt;id&gt;1&lt;/id&gt;
    ...
 &lt;/object&gt;
&lt;/response&gt;
&lt;/pre&gt;
</description><pubDate>Fri, 13 Mar 2015 13:43:51 +0100</pubDate><link>http://docs3.bedita.net/frontends/jsonview-and-xmlview</link><guid>http://docs3.bedita.net/frontends/jsonview-and-xmlview</guid></item><item><title>Frontends: a brief overview</title><description>&lt;hr/&gt;&lt;p&gt;A question that sooner or later you will ask yourself using &lt;strong&gt;BEdita&lt;/strong&gt; is:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&quot;Ok, nice software, now I have all my contents, videos, images into BEdita...what can I do with it?&quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Right, now it&#039;s time to find out how &lt;em&gt;frontends &lt;/em&gt;are built.&lt;em&gt; &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;BEdita &lt;/strong&gt;has been developed in a way to let complete freedom in building and setting up frontends: that means, all contents will be used in different ways, and maybe there is not going to be a web interface at all for your publishing. Anyway, a frontend web interface is what you normally would create, and that is what we are going to describe.&lt;/p&gt;
&lt;p&gt;At this stage &lt;strong&gt;BEdita &lt;/strong&gt;has a very simple sample frontend template (you will find it in frontend/site.example.com), but not a predefined reference: a common thing in most Web CMS systems out there. That means: you need at least a basic knowledge of HTML, CSS, PHP to create/setup your own frontend. Sure you can use some of the templates you&#039;ll find... but &lt;strong&gt;BEdita&lt;/strong&gt; is mostly a powerful tool for &lt;em&gt;webdesigners/webdevelopers&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;BEdita &lt;/strong&gt;provides a rich &lt;strong&gt;API&lt;/strong&gt; and tools to model and manipulate your backend contents easily and concentrate only on the visual frontend creation process (also well known as &lt;em&gt;view&lt;/em&gt; in &lt;strong&gt;MVC &lt;/strong&gt;standard pattern).&lt;/p&gt;
&lt;p&gt;Without writing a single line of code you will have contents and sections data available as PHP Arrays or XML or RSS and in few simple steps you will be able to display your contents by type, paginate, order them, etc etc..&lt;/p&gt;
</description><pubDate>Mon, 30 Mar 2009 18:41:32 +0200</pubDate><link>http://docs3.bedita.net/frontends/frontend-overview</link><guid>http://docs3.bedita.net/frontends/frontend-overview</guid></item><item><title>Embedding Images with beEmbedMedia</title><description>A quick look into BEdita helper to show and manipulate images&lt;hr/&gt;&lt;p&gt;Embedding images is probably the most common use of the &lt;em&gt;BeEmbedMedia&lt;/em&gt; Helper. You just have to pass the &lt;code&gt;$object&lt;/code&gt; array corresponding to an image object to the helpers &lt;em&gt;object() &lt;/em&gt;method.&lt;/p&gt;
&lt;p&gt;This helper will generate cached versions of thumbnails (or other image transformations) of your images the first time you call &lt;em&gt;object() &lt;/em&gt;method. Subsequent calls will use cached version and will be obviously much more fast.&lt;/p&gt;
&lt;h1&gt;Imagemagick or GD library&lt;/h1&gt;
&lt;p&gt;The thumbnails can be generated using &lt;a href=&quot;http://www.imagemagick.org&quot; target=&quot;_blank&quot;&gt;Imagemagick&lt;/a&gt; as well as &lt;a href=&quot;http://php.net/manual/en/book.image.php&quot; target=&quot;_blank&quot;&gt;GD library&lt;/a&gt;. Imagemagick is preferred beacuse it consumes less memory and it&#039;s more speedy so the Helper will try to use it, anyway a fallback on GD is present. So at least the GD PHP module must be installed on your system.&lt;br /&gt;Anyhow if you want to force the use of GD you would want override the default configuration option &lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$config[&#039;media&#039;][&#039;image&#039;][&#039;preferImagemagick&#039;] = true;&lt;/pre&gt;
&lt;p&gt;located in in &lt;code&gt;bedita-app/bedita.ini.php&lt;/code&gt; setting it to &lt;code&gt;false&lt;/code&gt; in &lt;code&gt;bedita-app/bedita.cfg.php&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;Using BeEmbedMedia Helper&lt;/h1&gt;
&lt;p&gt;In the following examples we will refer to &lt;strong&gt;BEdita 3.2,&lt;/strong&gt; and we will use the new &lt;strong&gt;Smarty 3&lt;/strong&gt; syntax for arrays.&lt;/p&gt;
&lt;p&gt;T&lt;span id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;he parameters&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;that are used&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;image manipulation are&lt;/span&gt;&lt;/span&gt;:&lt;/p&gt;
&lt;h2&gt;longside, width and height&lt;/h2&gt;
&lt;p&gt;At least, one of this parameters is required for displaying an image, and the value must be an integer. If no parameters has specified, the default values [&#039;image&#039;][&#039;thumbWidth&#039;] and [&#039;image&#039;][&#039;thumbHeight&#039;] in bedita.ini.php will be used. The &lt;strong&gt;longside&lt;/strong&gt; parameter specifies that the longest side of the image will be resized at the specified size and the helper automatically ignores the other two parameters.&lt;br /&gt;Otherwise &lt;strong&gt;width&lt;/strong&gt; and &lt;strong&gt;height&lt;/strong&gt; are used to resize the image in the canonical way but if only one dimension is used, the &lt;strong&gt;mode&lt;/strong&gt; param will be forced to resize.&lt;/p&gt;
&lt;h2&gt;mode and modeparam&lt;/h2&gt;
&lt;p&gt;When we want to display thumbnails, we will write something like:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{$beEmbedMedia-&amp;gt;object($media, [&#039;width&#039;=&amp;gt;200, 
  &#039;height&#039;=&amp;gt;200, &#039;mode&#039;=&amp;gt;&#039;crop&#039;])}
&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;&lt;strong&gt;mode&lt;/strong&gt;&lt;/em&gt; param specifies the type of scaling applied to the image. It&#039;s not mandatory, if not specified default bedita.ini.php parameter [&#039;image&#039;][&#039;thumbMode&#039;] is used. &lt;br /&gt;In the case above, the output result is:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://media.bedita.net/d5/de/gatto2_crop.jpg&quot; alt=&quot;simple crop&quot; /&gt;&lt;/p&gt;
&lt;p&gt;where the image was resized proportionally with the main side of 200px. &lt;br /&gt;Other &lt;strong&gt;mode&lt;/strong&gt; valid parameter type are: &lt;strong&gt;croponly&lt;/strong&gt; and &lt;strong&gt;resize&lt;/strong&gt; as displayed below.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;modeparam&lt;/strong&gt;&lt;/em&gt;&lt;strong&gt; &lt;/strong&gt;&lt;strong&gt;&lt;/strong&gt;parameter is optional and depends on which &lt;strong&gt;mode&lt;/strong&gt; is specified. If the mode is &lt;strong&gt;croponly&lt;/strong&gt; then we can specify the starting point for the zone to crop of the image with a string: &lt;em&gt;&#039;C&#039;, &#039;T&#039;, &#039;B&#039;, &#039;L&#039;, &#039;R&#039;, &#039;TL&#039;, &#039;TR&#039;, &#039;BL&#039;, &#039;BR&#039;&lt;/em&gt; . &lt;br /&gt;For example, the code:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{$beEmbedMedia-&amp;gt;object($media, [ &#039;width&#039;=&amp;gt;300, &#039;height&#039;=&amp;gt;300, 
 &#039;mode&#039;=&amp;gt;&#039;croponly&#039;, &#039;modeparam&#039;=&amp;gt;&#039;BL&#039; ] )}
&lt;/pre&gt;
&lt;p&gt;generates the following images, cropped from the Bottom-Left angle:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://media.bedita.net/de/21/gatto2_croponlyBL.jpg&quot; alt=&quot;croponly BL&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As long as the code:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{$beEmbedMedia-&amp;gt;object($media, [&#039;width&#039;=&amp;gt;300, &#039;height&#039;=&amp;gt;300, 
 &#039;mode&#039;=&amp;gt;&#039;croponly&#039;, &#039;modeparam&#039;=&amp;gt;&#039;TR&#039;] )}
&lt;/pre&gt;
&lt;p&gt;generates the following image, cropped from the Top-Right angle:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://media.bedita.net/93/4e/gatto2_croponlyTR.jpg&quot; alt=&quot;croponly TR&quot; /&gt;&lt;/p&gt;
&lt;p&gt;If &lt;em&gt;&lt;strong&gt;mode&lt;/strong&gt;&lt;/em&gt; is set on &lt;strong&gt;resize&lt;/strong&gt;, then we can specify the type of resize with the &lt;strong&gt;fill&lt;/strong&gt; or &lt;strong&gt;stretch&lt;/strong&gt; string in the &lt;strong&gt;&lt;em&gt;modeparams&lt;/em&gt;&lt;/strong&gt; parameter.&lt;br /&gt;The following code:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{$beEmbedMedia-&amp;gt;object($media, [&#039;width&#039;=&amp;gt;100, &#039;height&#039;=&amp;gt;300, 
  &#039;mode&#039;=&amp;gt;&#039;resize&#039;, &#039;modeparam&#039;=&amp;gt;&#039;stretch&#039;] )}
&lt;/pre&gt;
&lt;p&gt; Will resize the image exactly to the dimension required:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://media.bedita.net/cb/b7/gatto2_stretch.jpg&quot; alt=&quot;strech&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Otherwise, using the &lt;strong&gt;fill&lt;/strong&gt; options in the modeparam:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{$beEmbedMedia-&amp;gt;object($media, [&#039;width&#039;=&amp;gt;400, &#039;height&#039;=&amp;gt;100, 
&#039;mode&#039;=&amp;gt;&#039;resize&#039;, &#039;modeparam&#039;=&amp;gt;&#039;fill&#039;, &#039;bgcolor&#039;=&amp;gt;&#039;CCCCCC&#039; )}
&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;http://media.bedita.net/a2/6a/gatto_2fill.jpg&quot; alt=&quot;fill&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Will resize the image proportionally, filling the remaining space with the color specified in the &lt;strong&gt;bgcolor&lt;/strong&gt; param. Note that the &lt;strong&gt;bgcolor&lt;/strong&gt; param is considered only with the &lt;em&gt;&lt;strong&gt;mode=&quot;resize&quot; modeparam=&quot;fill&quot;&lt;/strong&gt;&lt;/em&gt; combination.&lt;/p&gt;
&lt;h2&gt;type&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;type&lt;/strong&gt; param is used to force the output type of the image as &lt;strong&gt;gif&lt;/strong&gt; or &lt;strong&gt;png&lt;/strong&gt; or &lt;strong&gt;jpg&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;upscale&lt;/h2&gt;
&lt;p&gt;It&#039;s a boolean parameter with the default bedita.ini.php [&#039;image&#039;][&#039;thumbUpscale&#039;] that allows or not the upscaling of an image.&lt;/p&gt;</description><pubDate>Mon, 14 Sep 2009 17:28:00 +0200</pubDate><link>http://docs3.bedita.net/frontends/embedding-images-with-beembedmedia</link><guid>http://docs3.bedita.net/frontends/embedding-images-with-beembedmedia</guid></item><item><title>Filtering section&#039;s objects</title><description>Learn how to filter section&#039;s objects according to your need&lt;hr/&gt;&lt;p&gt;Usually the &lt;dfn class=&quot;glossario&quot;&gt;section&lt;/dfn&gt;&#039;s objects that BEdita loads automatically are what you need for your frontend app, but sometimes you would want filter objects inside a section to obtain a more specific list of items to use in  &lt;dfn class=&quot;glossario&quot;&gt;views&lt;/dfn&gt;.&lt;/p&gt;
&lt;p&gt;In these cases the &lt;code&gt;FrontendController::sectionOptions&lt;/code&gt; attribute is what suits you. Through this attribute you can control &lt;a href=&quot;/customizing-frontend-applications-part-3-time-for-pagination&quot;&gt;pagination&lt;/a&gt; results and other things, like how many and which contents get and in which order you want them.&lt;/p&gt;
&lt;p&gt;Overriding the key &quot;filter&quot; in this class attribute you can easily handle children&#039;s section results. You can override &lt;code&gt;$sectionOptions&lt;/code&gt; for an entire frontend redefining it in PagesController, but usually you&#039;ll override it just in some specific section. To do so you should use the section callback &lt;em&gt;nicknameBeforeFilter,&lt;/em&gt; before section data loading, to set your filter.&lt;/p&gt;
&lt;h1&gt;Default behavior&lt;/h1&gt;
&lt;p&gt;Suppose that you have a section nicknamed &quot;my-section&quot; that contains different kind of &lt;dfn class=&quot;glossario&quot;&gt;object type&lt;/dfn&gt; (documents, galleries, events, ...) and that you want to fetch only documents, then you can set the filter option as&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;protected function my_sectionBeforeFilter() {
	$this-&amp;gt;sectionOptions[&#039;childrenParams&#039;][&#039;filter&#039;] = array(
		&#039;object_type_id&#039; =&amp;gt; Configure::read(&#039;objectTypes.document.id&#039;)
	);
}&lt;/pre&gt;
&lt;p&gt;where &lt;dfn class=&quot;glossario&quot;&gt;object_type_id&lt;/dfn&gt; is a field of objects table. See also &lt;dfn class=&quot;glossario&quot;&gt;$config[objectTypes]&lt;/dfn&gt; definition. Note also that i&lt;strong&gt;n BEdita 3.2 or higher the method name would camelize&lt;/strong&gt; i.e. &lt;code&gt;mySectionBeforeFilter&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The SQL conditions&lt;/p&gt;
&lt;pre class=&quot;brush: sql; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;WHERE object_type_id = &#039;22&#039;&lt;/pre&gt;
&lt;p&gt; will be generated.&lt;/p&gt;
&lt;p&gt;If you want to select galleries too then write&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$this-&amp;gt;sectionOptions[&#039;childrenParams&#039;][&#039;filter&#039;] = array(
	&#039;object_type_id&#039; =&amp;gt; array(
		Configure::read(&#039;objectTypes.document.id&#039;),
		Configure::read(&#039;objectTypes.gallery.id&#039;)
	)
);&lt;/pre&gt;
&lt;p&gt;The SQL conditions&lt;/p&gt;
&lt;pre class=&quot;brush: sql; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;WHERE object_type_id IN (&#039;22&#039;, &#039;29&#039;)&lt;/pre&gt;
&lt;p&gt; will be generated.&lt;/p&gt;
&lt;p&gt;You can of course add other kind of fliters, for example using specific database table fields want to add other filter. Say you want to filter using publication &lt;em&gt;start_date&lt;/em&gt; you may want to use this&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$this-&amp;gt;sectionOptions[&#039;childrenParams&#039;][&#039;filter&#039;] = array(
	&#039;object_type_id&#039; =&amp;gt; array(
		Configure::read(&#039;objectTypes.document.id&#039;),
		Configure::read(&#039;objectTypes.gallery.id&#039;)
	),
	&#039;Content.start_date&#039; =&amp;gt; &quot;&amp;gt;= &#039;2011&#039;&quot;
);&lt;/pre&gt;
&lt;p&gt;In that way a &lt;strong&gt;one to one&lt;/strong&gt; &lt;strong&gt;relation is used to join &lt;em&gt;objects&lt;/em&gt; to &lt;em&gt;contents&lt;/em&gt; table&lt;/strong&gt; and the SQL conditions&lt;/p&gt;
&lt;pre class=&quot;brush: sql; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;WHERE object_type_id IN (&#039;22&#039;, &#039;29&#039;) AND Content.start_date &amp;gt;= &#039;2011&#039;&lt;/pre&gt;
&lt;p&gt;is used.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h1&gt;Other filter rules&lt;/h1&gt;
&lt;p&gt;Some other filter rules are defined in &lt;a href=&quot;http://api.bedita.com/classBuildFilterBehavior.html&quot; target=&quot;_blank&quot;&gt;BuildFilter Behavior&lt;/a&gt; located in &lt;code&gt;bedita-app/models/behaviors&lt;/code&gt; folder. These rules are usually used in BEdita backend but you can use it for your need. Every rule is defined with a method named with the rule name followed by &quot;Filter&quot; word.&lt;/p&gt;
&lt;p&gt;For example you could use the &lt;strong&gt;category filter&lt;/strong&gt; to filter objects by category.&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$this-&amp;gt;sectionOptions[&#039;childrenParams&#039;][&#039;filter&#039;] = array(
	&#039;category&#039; =&amp;gt; &#039;documentation&#039;
);&lt;/pre&gt;
&lt;p&gt;where &quot;documentation&quot; is the name of the category you want to filter for.&lt;/p&gt;
&lt;p&gt;Pay attention on the fact that not all filter rules that you find in BuildFilter Behavior are useful in frontend app, if used through $sectionOptions attribute, because filter results are refined at a later stage. &lt;br /&gt;For example, if you want to use a filter in order to add fields to results you must use &lt;a href=&quot;/get-more-or-less-information-from-your-content&quot;&gt;model bindings&lt;/a&gt; instead.&lt;br /&gt;So if your section&#039;s objects have to show the user that has created them and you apply the filter&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$this-&amp;gt;sectionOptions[&#039;childrenParams&#039;][&#039;filter&#039;] = array(
	&#039;user_created&#039; =&amp;gt; true
);&lt;/pre&gt;
&lt;p&gt;the result does not reflect what you would expect, because it is refined getting objects&#039; details through model bindings. You should instead check that all objects bindings contain UserCreated.&lt;/p&gt;
&lt;h1&gt;Create your own rules&lt;/h1&gt;
&lt;p&gt;From BEdita higher than 3.1.6 the filter is highly customizable extending the BuildFilter Behavior class and following some simple rules.&lt;br /&gt;We&#039;re going to explain how to do it in a next article.&lt;/p&gt;</description><pubDate>Tue, 08 May 2012 15:26:54 +0200</pubDate><link>http://docs3.bedita.net/frontends/filtering-section-s-objects</link><guid>http://docs3.bedita.net/frontends/filtering-section-s-objects</guid></item><item><title>Understand how the View is chosen</title><description>Let&#039;s see which view file is chosen in a BEdita frontend call&lt;hr/&gt;&lt;p&gt;Understand how the &lt;dfn class=&quot;glossario&quot;&gt;view&lt;/dfn&gt; file is chosen is fundamental if you want mastering frontend customization. In the standard frontend flow the requested url is processed by BEdita to load a &lt;dfn class=&quot;glossario&quot;&gt;section&lt;/dfn&gt; or a &lt;dfn class=&quot;glossario&quot;&gt;content&lt;/dfn&gt; by &lt;dfn class=&quot;glossario&quot;&gt;nickname&lt;/dfn&gt; then it renders the view file named &lt;code&gt;section.tpl&lt;/code&gt; located in &lt;code&gt;app/views/pages&lt;/code&gt; folder. This view uses the &lt;code&gt;BeFrontHelper::chooseTemplate()&lt;/code&gt; method to determine which tempate file has to be included following the schema below:&lt;/p&gt;
&lt;h1&gt;1. Check frontendMap currentContent nickname&lt;/h1&gt;
&lt;p&gt;First of all the &lt;code&gt;chooseTemplate()&lt;/code&gt; method checks if you have configured the file &lt;code&gt;app/config/mapping.cfg.php&lt;/code&gt; to map nicknames or ids to views. If so and if the page points to a content nickname (located in view array &lt;code&gt;$section[&#039;currentContent&#039;]&lt;/code&gt;) mapped then the view specified is searched and eventually used.&lt;/p&gt;
&lt;p&gt;Example: &lt;code&gt;app/config/mapping.cfg.php&lt;/code&gt; file contains&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$config[&quot;frontendMap&quot;] = array(
    &quot;example-one&quot; =&amp;gt; &quot;sample_template&quot;
);&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;url:&lt;/em&gt; &lt;code&gt;http://www.example.com/example-one&lt;/code&gt; where &quot;example-one&quot; is the nickname of a content&lt;br /&gt;&lt;em&gt;view file searched:&lt;/em&gt; &lt;code&gt;app/views/pages/sample_template.tpl&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The same view is searched if browser points to &lt;code&gt;http://www.example.com/demo/example-one&lt;/code&gt; where demo is the nickame of the parent section of example-one. &lt;br /&gt;If view file doesn&#039;t exist then it goes on to the next step.&lt;/p&gt;
&lt;h1&gt;2. Check frontendMap section nickname&lt;/h1&gt;
&lt;p&gt;If first check fails then the method checks if the current section is mapped in &lt;code&gt;mapping.cfg.php&lt;/code&gt; and eventually uses it.&lt;/p&gt;
&lt;p&gt;Example: &lt;code&gt;app/config/mapping.cfg.php&lt;/code&gt; file contains&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$config[&quot;frontendMap&quot;] = array(
    &quot;demo&quot; =&amp;gt; &quot;demo_template&quot;
);&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;url:&lt;/em&gt; &lt;code&gt;http://www.example.com/demo/example-one&lt;/code&gt; &lt;br /&gt;&lt;em&gt;view file searched:&lt;/em&gt; &lt;code&gt;app/views/pages/demo_template.tpl&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;3. View with same name as currentContent nickname&lt;/h1&gt;
&lt;p&gt;If point 2 fails, then the method try to search a view named as current content nickname.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;url:&lt;/em&gt; &lt;code&gt;http://www.example.com/demo/example-one&lt;/code&gt; where &quot;example-one&quot; is the nickname of a content.&lt;/p&gt;
&lt;p&gt;If it&#039;s present a view file named &lt;code&gt;example-one.tpl&lt;/code&gt; in &lt;code&gt;app/views/pages&lt;/code&gt; folder then it will be used.&lt;/p&gt;
&lt;h1&gt;4. View with same name as section nickname&lt;/h1&gt;
&lt;p&gt;Successive check is the same of point 3 but with section nickname instead of content nickname. So if view file with the same name as the section nickname is found in &lt;code&gt;app/views/pages&lt;/code&gt; folder then it&#039;s used.&lt;/p&gt;
&lt;h1&gt;5. View with same name as parent sections nickname&lt;/h1&gt;
&lt;p&gt;if point 4 fails the next step is to check the presence of a view file named as one of the parent section of current section using the &lt;code&gt;$section[&#039;pathSection&#039;]&lt;/code&gt; array. First view file&lt;/p&gt;
&lt;h1&gt;6. Object type template name&lt;/h1&gt;
&lt;p&gt;The last check is done with object type of current content. A view file named as the &lt;dfn class=&quot;glossario&quot;&gt;object type&lt;/dfn&gt; is searched. For example, if you create an &lt;code&gt;event.tpl&lt;/code&gt; file in &lt;code&gt;app/views/pages&lt;/code&gt; then it is used every time a BEdita object of type event is loaded as a request of an url.&lt;/p&gt;
&lt;h1&gt;7. Default fallback&lt;/h1&gt;
&lt;p&gt;If none of the previous checks is satisfied then the fallback mode selects the view file &lt;code&gt;app/views/pages/generic_section.tpl&lt;/code&gt;&lt;/p&gt;</description><pubDate>Wed, 25 Jan 2012 14:53:55 +0100</pubDate><link>http://docs3.bedita.net/frontends/understand-how-the-view-is-choosed</link><guid>http://docs3.bedita.net/frontends/understand-how-the-view-is-choosed</guid></item><item><title>Localize your frontend</title><description>&lt;hr/&gt;&lt;p&gt;To localize your frontend app you have to follow the steps below:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Prepare you frontend editing the configurations vars in &lt;code&gt;frontend-app/config/frontend.ini.php&lt;/code&gt; file&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$config[&#039;frontendLang&#039;]&lt;/code&gt; with the default language (i.e. &#039;eng&#039;)&lt;br /&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$config[&#039;frontendLang&#039;] = &#039;eng&#039;;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$config[&#039;frontendLangs&#039;]&lt;/code&gt; with an array of supported languages, for example&lt;br /&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$config[&#039;frontendLangs&#039;] = array(
    &#039;ita&#039; =&amp;gt; &#039;italiano&#039;,
    &#039;eng&#039; =&amp;gt; &#039;english&#039;
);&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Eventually edit the config var &lt;code&gt;$config[&#039;frontendLangsMap&#039;]&lt;/code&gt; according to your needs to add or remove maps of languages to autodetecting language choice&lt;br /&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$config[&#039;frontendLangsMap&#039;] = array(
	&#039;it&#039; =&amp;gt; &#039;ita&#039;,
	&#039;en&#039; =&amp;gt; &#039;eng&#039;,
	&#039;en_us&#039; =&amp;gt; &#039;eng&#039;,
	&#039;en-us&#039; =&amp;gt; &#039;eng&#039;,
	&#039;en_gb&#039; =&amp;gt; &#039;eng&#039;
);&lt;/pre&gt;
where the key is the language comes from HTTP client request and the related value is the language you have defined in &lt;code&gt;$config[&#039;frontendLangs&#039;]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Choose a name for the cookie where the language will be wrote on (always in frontend.ini.php)&lt;br /&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$config[&quot;cookieName&quot;] = array(
	&quot;langSelect&quot; =&amp;gt; &quot;basicExampleLang&quot;
);&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;translate your contents from BEdita backend through out the &lt;em&gt;Translations module&lt;/em&gt;;&lt;/li&gt;
&lt;li&gt;use the Smarty tag &lt;code&gt;{t}text to translate{/t}&lt;/code&gt; and/or the CakePHP method &lt;code&gt;__(&#039;text to translate&#039;, true)&lt;/code&gt; to write all the static parts of your frontend;&lt;/li&gt;
&lt;li&gt;translate these static parts. Read &lt;a href=&quot;/how-to-create-bedita-translations&quot;&gt;&#039;How to Create BEdita translations&#039;&lt;/a&gt; and apply it to your frontend. You have to use the &lt;strong&gt;locale&lt;/strong&gt; frontend folder to put the &lt;strong&gt;.po files&lt;/strong&gt; and launch the shell script&lt;br /&gt;
&lt;pre class=&quot;brush: bash; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;./cake.sh gettext update -frontend path/to/your/frontend&lt;/pre&gt;
to update &lt;strong&gt;.po files&lt;/strong&gt; with the strings to translate;&lt;/li&gt;
&lt;li&gt;if some static translations you have wrote in &lt;strong&gt;.po files &lt;/strong&gt;doesn&#039;t appear you should cleanup the cached file with &lt;br /&gt;
&lt;pre class=&quot;brush: bash; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;./cake.sh bedita cleanup -frontend path/to/your/frontend&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;Now your frontend app is ready to be browsed in different languages.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;When a visitor comes to your frontend app the system tries to autodetect the language choice through &lt;code&gt;$config[&#039;frontendLangsMap&#039;]&lt;/code&gt;. &lt;br /&gt;If autodetecting fails, the default language defined in &lt;code&gt;$config[&#039;frontendLang&#039;]&lt;/code&gt; is used. The language is wrote in session and a cookie with the language used is automatically set, so if a user returns to visit your frontend he starts to navigate with the language of his last visit. The cookie name can be found and edited in &lt;code&gt;$config[&quot;cookieName&quot;][&quot;langSelect&quot;]&lt;/code&gt; variable in &lt;strong&gt;frontend.ini.php&lt;/strong&gt; as indicated in the above point 3.&lt;/p&gt;
&lt;h1&gt;Change language on the fly&lt;/h1&gt;
&lt;p&gt;You can change the frontend language from a language to another, for example from english to italian, simply with:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;http://www.example.com/lang/ita&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The language will be set to italian and the client will be redirected to the referred, so if you have loaded the page &lt;strong&gt;http://www.example.com/my-page &lt;/strong&gt;and you write in the address bar &lt;strong&gt;http://www.example.com/lang/ita&lt;/strong&gt; the language will be changed to italian and the &lt;strong&gt;http://www.example.com/my-page&lt;/strong&gt; will be reloaded.&lt;/p&gt;
&lt;p&gt;Instead to change language and redirect to a specific &lt;dfn class=&quot;glossario&quot;&gt;section&lt;/dfn&gt; (or &lt;dfn class=&quot;glossario&quot;&gt;content&lt;/dfn&gt;) with &lt;dfn class=&quot;glossario&quot;&gt;nickname&lt;/dfn&gt; my-nickname you could write in the address bar&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;http://www.example.com/lang/ita/my-nickname&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;and so on for all the other languages.&lt;/p&gt;
&lt;h1&gt;The view&lt;/h1&gt;
&lt;p&gt;At this point you could add an element to switch language in the &lt;dfn class=&quot;glossario&quot;&gt;view&lt;/dfn&gt; of your frontend app. In the view you&#039;ll have the current language in the &lt;code&gt;$currLang&lt;/code&gt; variable while &lt;code&gt;$conf&lt;/code&gt; is an object that contains all the configuration variables. Therefore a simple example of Smarty view can be:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{foreach from=$conf-&amp;gt;frontendLangs key=&quot;lang&quot; item=&quot;label&quot;}
	{if $currLang == $lang}
		{$label} | 
	{else}
		&amp;lt; a href=&quot;{$html-&amp;gt;url(&#039;/lang/&#039;)}{$lang}&quot; &amp;gt;{$label}&amp;lt; /a &amp;gt; |
	{/if}
{/foreach} &lt;/pre&gt;</description><pubDate>Wed, 04 Jan 2012 16:50:18 +0100</pubDate><link>http://docs3.bedita.net/frontends/localize-your-frontend</link><guid>http://docs3.bedita.net/frontends/localize-your-frontend</guid></item><item><title>Create custom error 404 and error 500 pages</title><description>Create views for common HTTP errors in your frontend&lt;hr/&gt;&lt;p&gt;On your frontend applications you may want to have nice and useful error pages for your users (both human and non-human: bots, spiders...).&lt;/p&gt;
&lt;p&gt;Typical cases of &lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;page not found&lt;/em&gt;&lt;/span&gt; (&lt;a title=&quot;Error 404&quot; href=&quot;http://en.wikipedia.org/wiki/HTTP_404&quot;&gt;Error 404&lt;/a&gt;) or &lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;internal error&lt;/em&gt;&lt;/span&gt; (&lt;a title=&quot;Error 500&quot; href=&quot;http://en.wikipedia.org/wiki/HTTP_500&quot; target=&quot;_blank&quot;&gt;Error 500&lt;/a&gt;) are already handled by &lt;strong&gt;BEdita&lt;/strong&gt;: correct HTTP error codes are sent to user-agent/browser, some basic information is displayed for the user, details of what happened are written to error log file.&lt;/p&gt;
&lt;p&gt;Customizing the view for your users in these cases is straightforward and very easy, you simply have to modify these files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;views/layouts/error.tpl - &lt;/strong&gt;&lt;span style=&quot;font-family: mceinline;&quot;&gt;this is the common layout for your error pages, it could be similar to views/layouts/default.tpl - i.e. your default template layout - here a &lt;em&gt;meta&lt;/em&gt; code snippet example&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;&amp;lt; html&amp;gt;
&amp;lt; head&amp;gt;
	&amp;lt; meta name=&quot;...&quot; content=&quot;...&quot;&amp;gt; 

	&amp;lt; title&amp;gt;There was an error...

	{$html-&amp;gt;css(&#039;....&#039;)}
	{$javascript-&amp;gt;link(&#039;.....&#039;)}
&amp;lt; /head&amp;gt;
&amp;lt; body&amp;gt;
  {$view-&amp;gt;element(&#039;header&#039;)}

  {$content_for_layout}

  {$view-&amp;gt;element(&#039;footer&#039;)}
&amp;lt; /body&amp;gt;
&amp;lt; /html&amp;gt;
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;You don&#039;t have to write this template: if you don&#039;t write it, the default one is used, which contains just&lt;br /&gt;&lt;em&gt;{$content_for_layout}&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;views/errors/error404.tpl - &lt;/strong&gt;&lt;span style=&quot;font-family: mceinline;&quot;&gt;h&lt;/span&gt;ere you can specify what to display in &lt;em&gt;{$content_for_layout}&lt;/em&gt; in case of a page not found/404 error, it could be a complete HTML page if you didn&#039;t create your common error layout, or something like this code snippet&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div&gt;
&lt;h1&gt;This page is missing&lt;/h1&gt;
&lt;p&gt;The page you requested is not available. You may have followed a corrupt external link or mis-typed a URL.&lt;/p&gt;
&lt;p&gt;Please.....&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;views/errors/error500.tpl - &lt;/strong&gt;this is the equivalent page for &quot;internal server error&quot;/500 error page, where you can specify your &lt;em&gt;{$content_for_layout}&lt;/em&gt; in this case - it works exactly like the error404.tpl page&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description><pubDate>Wed, 14 Mar 2012 11:05:08 +0100</pubDate><link>http://docs3.bedita.net/frontends/create-custom-error-404-and-error-500-pages</link><guid>http://docs3.bedita.net/frontends/create-custom-error-404-and-error-500-pages</guid></item><item><title>Routing rules in frontend applications</title><description>This article explains how to build routing rules for redirecting web requests&lt;hr/&gt;&lt;p&gt;This article explains how to build routing rules for redirecting web requests&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;In frontend applications you will normally have just this rule in your &lt;code&gt;config/routes.php&lt;/code&gt; file [standard CakePHP file for routing rules]:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;Router::connect(
   &#039;/*&#039;, 
   array( 
      &#039;controller&#039; =&amp;gt; &#039;pages&#039;, 
      &#039;action&#039; =&amp;gt; &#039;route&#039;
   )
);&lt;/pre&gt;
&lt;p&gt;That means: every URL (/*) should be passed to &lt;code&gt;PagesController::route()&lt;/code&gt; (inherited from &lt;code&gt;FrontendController&lt;/code&gt; class) . This &lt;code&gt;route()&lt;/code&gt; method will decide which actions to take.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Most of the URLs handled will be in the form &lt;code&gt;/my-section-name/my-content-name&lt;/code&gt; - that will cause loading of section with unique name &lt;code&gt;my-section-name&lt;/code&gt; and content with unique name &lt;code&gt;my-content-name&lt;/code&gt; located in &lt;code&gt;my-section-name&lt;/code&gt; section.&lt;/p&gt;
&lt;p&gt;But the general routing rules, in &lt;code&gt;route()&lt;/code&gt; method, are as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;if there aren&#039;t url arguments (i.e. &quot;/&quot;) then will be used the reserved word &lt;strong&gt;&quot;homePage&quot;&lt;/strong&gt; for calling the method with the same name.&lt;br /&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;Url&lt;/em&gt;&lt;/span&gt;: www.example.com&lt;br /&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;Method used&lt;/em&gt;&lt;/span&gt;: &lt;code&gt; FrontendController::homePage()&lt;/code&gt; &lt;br /&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;Action performed&lt;/em&gt;&lt;/span&gt;: load first Section of the relative Publication or the Publication if no section is found (see Publication module on BEdita backend).&lt;br /&gt;You can ovverride this method in your controller to fit your home page at your needs;&lt;/li&gt;
&lt;li&gt;if first url argument is a reserved word (defined in configuration variables &lt;strong&gt;&quot;defaultReservedWords&quot;&lt;/strong&gt; and &lt;strong&gt;&quot;cfgReservedWords&quot;&lt;/strong&gt;) it means that no object will have this unique name. So it will try to call a method with this same reserved name. Some reserved words have an own method in FrontendController that you may override in your controller.&lt;br /&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;Url&lt;/em&gt;&lt;/span&gt;: www.example.com/reservedWord&lt;br /&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;Method used&lt;/em&gt;&lt;/span&gt;: &lt;code&gt;PagesController::reservedWord()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;if first url argument is a public method of your controller then it will be called&lt;br /&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;Url&lt;/em&gt;&lt;/span&gt;: www.example.com/myMethod&lt;br /&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;Method used&lt;/em&gt;&lt;/span&gt;: PagesController::myMethod()&lt;/li&gt;
&lt;li&gt;if first url argument is a valid &lt;em&gt;unique name&lt;/em&gt; and there is a public method of your controller with a corresponding name (as defined in &lt;code&gt;bedita-app/lib/BeLib::variableFromNickname()&lt;/code&gt;), it will be called.&lt;br /&gt;&lt;em&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Url&lt;/span&gt;&lt;/em&gt;: www.example.com/my-beautiful-nickname&lt;br /&gt;&lt;em&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Method used&lt;/span&gt;&lt;/em&gt;: &lt;code&gt;PagesController::myBeautifulNickname()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;if first url argument is a valid &lt;em&gt;unique name, &lt;/em&gt;it calls the corresponding FrontendController::section() or FrontendController::content() method. Here an example:&lt;br /&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;Url&lt;/em&gt;&lt;/span&gt;: www.example.com/my-section/my-content&lt;br /&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;Method used&lt;/em&gt;&lt;/span&gt;: section &lt;em&gt;my-section&lt;/em&gt; will be loaded in &lt;code&gt;FrontendController::section()&lt;/code&gt; method, that will load &lt;em&gt;my-content&lt;/em&gt; object through &lt;code&gt;FrontendController::content()&lt;/code&gt; method&lt;/li&gt;
&lt;li&gt;if none of the above points are matched then an exception is thrown causing a 404 http error&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Before and after every method called from FrontendController::route() (except), two callbacks methods are triggered if they exist: methods with same name and suffix &lt;em&gt;-BeforeFilter&lt;/em&gt; / &lt;em&gt;-BeforeRender &lt;/em&gt;. For example when the &lt;em&gt;homePage()&lt;/em&gt; method is used, the flow will be:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;PagesController::homePageBeforeFilter()&lt;/code&gt; (if it exists)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PagesController::homePage()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PagesController::homePageBeforeRender()&lt;/code&gt; (if it exists)&lt;/li&gt;
&lt;/ol&gt;</description><pubDate>Fri, 25 Nov 2011 10:09:10 +0100</pubDate><link>http://docs3.bedita.net/frontends/routing-rules-in-frontend-applications</link><guid>http://docs3.bedita.net/frontends/routing-rules-in-frontend-applications</guid></item><item><title>Showing a list of tags</title><description>Get a tag cloud or tag list in your frontend application&lt;hr/&gt;&lt;p&gt;Get a tag cloud or tag list in your frontend application&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;Let&#039;s see how you can show a list or cloud of tags in BEdita frontends.&lt;/p&gt;
&lt;p&gt;If you want to show them in every page of your frontend you should use the &lt;strong&gt;beditaBeforeRender()&lt;/strong&gt; callback in your &lt;strong&gt;PagesController&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;protected function beditaBeforeRender() {
   $this-&amp;gt;loadTags();
}
&lt;/pre&gt;
&lt;p&gt;in this way an array named &lt;code&gt;$listTags&lt;/code&gt; will be set for the view. That array will contain all tags ordered by label related to, at least, a content in your publication. You can customize your tags list/cloud with some parameters.&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;loadTags( $tplVar=null, $cloud=true, $shuffle=false, $tagShowed=null )&lt;/pre&gt;
&lt;p&gt;where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;$tplVar&lt;/strong&gt; is the name of view variable&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$cloud&lt;/strong&gt; says if has to be set a css class for cloud view. Possible css class values are  &lt;em&gt;smallestTag&lt;/em&gt;, &lt;em&gt;largestTag&lt;/em&gt;, &lt;em&gt;largeTag&lt;/em&gt;, &lt;em&gt;mediumTag&lt;/em&gt;, &lt;em&gt;smallTag&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$shuffle&lt;/strong&gt; says if the tags have to be shuffled or shown in order by label&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$tagShowed&lt;/strong&gt; is the number of tags that will be in the result array&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So if you want to load 30 tags shuffled in cloud mode you will call&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$this-&amp;gt;loadTags(null, true, true, 30);&lt;/pre&gt;
&lt;h2&gt;Tags view&lt;/h2&gt;
&lt;p&gt;In the view you will have &lt;strong&gt;$listTags&lt;/strong&gt;array as:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false;&quot;&gt;Array (
    [0] =&amp;gt; Array (
       [&#039;id&#039;] =&amp;gt; 1
       [&#039;area_id&#039;] =&amp;gt; 
       [&#039;label&#039;] =&amp;gt; &#039;my tag&#039;
       [&#039;name&#039;] =&amp;gt; &#039;my-tag&#039;
       [&#039;object_type_id&#039;] =&amp;gt; 
       [&#039;priority&#039;] =&amp;gt; 
       [&#039;parent_id&#039;] =&amp;gt; 
       [&#039;parent_path&#039;] =&amp;gt; 
       [&#039;status&#039;] =&amp;gt; &#039;on&#039;
       [&#039;url_label&#039;] =&amp;gt; &#039;my-tag&#039;
       [&#039;weight&#039;] =&amp;gt; 100
       [&#039;class&#039;] =&amp;gt; &#039;largeTag&#039;
    ),
   [1] =&amp;gt; Array(...)
   ...
);&lt;/pre&gt;
&lt;p&gt;where you can see that tag named &quot;my tag&quot; is related to 100 items (&lt;em&gt;weight&lt;/em&gt;) and the css class &lt;em&gt;largeTag&lt;/em&gt; should be applied to &quot;my tag&quot; to generate the cloud. The &lt;em&gt;name&lt;/em&gt; and &lt;em&gt;url_label&lt;/em&gt; fields are equal for backward compatibility but we suggest to use only &lt;em&gt;name&lt;/em&gt; field because &lt;em&gt;url_label&lt;/em&gt; will be deprecated in the future.&lt;br /&gt;&lt;br /&gt;A new element to use in views named tag_cloud will be added soon, but for now you can create one by your own. It&#039;s straightforward: add the file &lt;strong&gt;app/views/elements/tag_cloud.tpl&lt;/strong&gt; and, for example, add the code:&lt;/p&gt;
&lt;pre class=&quot;brush: js; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{if !empty($listTags)}
    &amp;lt; h2 &amp;gt;{t}Tag cloud{/t}&amp;lt; /h2 &amp;gt;
    {foreach from=$listTags item=tag}
        &amp;lt; a class=&quot;tagCloud {$tag.class|default:&quot; title=&quot;{$tag.weight}&quot; 
             href=&quot;{$html-&amp;gt;url(&#039;/tag/&#039;)}{$tag.name}&quot; &amp;gt;{$tag.label}&amp;lt; /a &amp;gt;
    {/foreach}
{/if}&lt;/pre&gt;
&lt;p&gt;add to your CSS something as:&lt;/p&gt;
&lt;pre class=&quot;brush: css; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;.smallestTag {
    font-size:1em;
}
.smallTag {
    font-size:1.2em;
}
.mediumTag {
    font-size:1.4em;
}
.largeTag {
    font-size:1.8em;
}
.largestTag {
    font-size:2.2em;
}
&lt;/pre&gt;
&lt;p&gt;and you will have your tag cloud ready to use. Now you can call the element wherever you want using:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{$view-&amp;gt;element(&#039;tag_cloud&#039;)}&lt;/pre&gt;
&lt;p&gt;in your views.&lt;/p&gt;</description><pubDate>Thu, 19 Jan 2012 11:15:07 +0100</pubDate><link>http://docs3.bedita.net/frontends/showing-a-list-of-tags</link><guid>http://docs3.bedita.net/frontends/showing-a-list-of-tags</guid></item><item><title>Managing Users History</title><description>Manage easly users history in frontend applications (and in backend too)&lt;hr/&gt;&lt;p&gt;Manage easly users history in frontend applications (and in backend too)&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;Manage users navigation history is a common scenario developing frontend applications and BEdita comes with an integrated system to handle it.&lt;/p&gt;
&lt;p&gt;To activate history tracking just edit &lt;strong&gt;config/frontend.ini.php&lt;/strong&gt; in your frontend application and uncomment:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$config[&quot;history&quot;] = array(
   &quot;sessionEntry&quot; =&amp;gt; 5,
   &quot;showDuplicates&quot; =&amp;gt; false,
   &quot;trackNotLogged&quot; =&amp;gt; false
);&lt;/pre&gt;
&lt;p&gt;where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;sessionEntry&lt;/strong&gt; is the number of history items you want to have in session&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;showDuplicates&lt;/strong&gt; says if duplicate history items have to show in session&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;trackNotLogged&lt;/strong&gt; says if history of unsigned users has to be active&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Automatically BEdita will trace users activity in &lt;em&gt;history&lt;/em&gt; table and fill &lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;em&gt;History&lt;/em&gt;&lt;/span&gt; array in session.&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;$BEAuthUser&lt;/code&gt; variable (views variable for user session info) you will have for example:&lt;/p&gt;
&lt;pre class=&quot;brush: javascript; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;[&#039;History&#039;] =&amp;gt; Array(
   [0] =&amp;gt; Array(
      [&#039;area_id&#039;] =&amp;gt; 1
      [&#039;object_id&#039;] =&amp;gt; 3
      [&#039;title&#039;] =&amp;gt; //This is the title of content
      [&#039;url&#039;] =&amp;gt; //url-to-that-content
      [&#039;user_id&#039;] =&amp;gt; 1
      [&#039;id&#039;] =&amp;gt; 1
   ),
   [1] =&amp;gt; Array(...)
   ...
);&lt;/pre&gt;
&lt;p&gt;Ajax and Flash calls are not inserted in history and you can always control what you want to end up in history through out the &lt;code&gt;AppController::historyItem&lt;/code&gt; property. Setting it to null you avoids to register history in some cases.&lt;/p&gt;
&lt;p&gt;For example if you don&#039;t want access to a content with unique name &quot;mycontent&quot; to be tracked, then you can add to PagesController:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;protected function mycontentBeforeFilter() {
   $this-&amp;gt;historyItem = null;
}&lt;/pre&gt;
&lt;p&gt;If you need you can also manage users history in BEdita backend: just uncomment from &lt;strong&gt;bedita-app/config/bedita.cfg.php&lt;/strong&gt; &lt;code&gt;$config[&quot;history&quot;]&lt;/code&gt; array.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description><pubDate>Wed, 18 Jan 2012 13:05:02 +0100</pubDate><link>http://docs3.bedita.net/frontends/manage-users-history</link><guid>http://docs3.bedita.net/frontends/manage-users-history</guid></item><item><title>Frontend Application Flow and callback methods</title><description>To help the frontend developers BEdita comes with a series of callback methods that allowing to filter and handling data. Understanding how the flow of frontend applications works and which callbacks the developer has in hand is one of the fundamental things to start developing a custom frontend&lt;hr/&gt;&lt;p&gt;To help the frontend developers BEdita comes with a series of callback methods that allowing to filter and handling data. Understanding how the flow of frontend applications works and which callbacks the developer has in hand is one of the fundamental things to start developing a custom frontend&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;To fit variegated needs that you can encounter developing a frontend application, BEdita comes with a series of callback methods that allows to find and handle data. Before having a look at this callbacks let&#039;s go to see what happens in a standard frontend flow.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h2&gt;Frontend Application Flow&lt;/h2&gt;
&lt;p&gt;Supposing we have a BEdita publication reachable from &lt;code&gt;http://www.example.com&lt;/code&gt; and we want to see the contents of a section with nickname &lt;em&gt;section-one&lt;/em&gt;, in browser address bar we&#039;ll write&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/section-one&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Everything is handled by &lt;strong&gt;route&lt;/strong&gt; method that decide what to do. So if you have a custom method in Pages Controller you can call it in standard CakePHP mode&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/myCustomMethod&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;route&lt;/strong&gt; method gets first parameters passed by URL (in our case &lt;em&gt;section-1&lt;/em&gt;), check if it&#039;s a reserved word as defined in configuration files and eventually try to call method with that name.&lt;/p&gt;
&lt;p&gt;If none reserved word or controller public method is found then BEdita consider the parameter a nickname, check if it corresponds to a section object or not and call respectively &lt;strong&gt;section&lt;/strong&gt; method or &lt;strong&gt;content&lt;/strong&gt; method. These two methods will load all section and contents data and set to view the array &lt;code&gt;$section&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Finally the view is rendered.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; for the complete list of route rules followed in frontend apps it&#039;s raccomended to read &lt;a href=&quot;/routing-rules-in-frontend-applications&quot;&gt;Routing rules in frontend applications&lt;/a&gt; article.&lt;/p&gt;
&lt;h2&gt;Callback Methods&lt;/h2&gt;
&lt;p&gt;There are four main callbacks always called that can be used to insert logic before or after controller actions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;beforeCheckLogin&lt;/strong&gt; called by FrontendController::initAttributes method is executed before check login operation is performed. It&#039;s useful if you want to skip the user check login operation for specific items setting to true the AppController::$skipCheck attribute. Note that the checkLogin method is called before beditaBeforeFilter.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;beditaBeforeFilter&lt;/strong&gt; called by AppController::&lt;strong&gt;beforeFilter&lt;/strong&gt; method is executed before every action in the controller;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;beditaBeforeRender &lt;/strong&gt;called by&lt;strong&gt; &lt;/strong&gt;AppController::&lt;strong&gt;beforeRender &lt;/strong&gt;method is executed after controller action but before view is rendered.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;beditaAfterFilter&lt;/strong&gt; called by AppController::afterFilter method is executed after the render is done. It&#039;s the last thing made by controller.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition some specific callbacks are called if respective method exists. If exists a callback &lt;strong&gt;[methodToCallBeforeFilter&lt;/strong&gt; is called before the main method (&lt;em&gt;for example sectionBeforeFilter is called before section method&lt;/em&gt;) and another callback &lt;strong&gt;[&lt;/strong&gt;&lt;strong&gt;methodToCall&lt;/strong&gt;&lt;strong&gt;]&lt;/strong&gt;&lt;strong&gt;BeforeRender&lt;/strong&gt; is called soon after the main method.&lt;/p&gt;
&lt;p&gt;Similar callbacks are handled in &lt;strong&gt;section&lt;/strong&gt; and &lt;strong&gt;contents&lt;/strong&gt; methods using the section/content unique name as defined in &lt;code&gt;bedita-app/lib/BeLib::variableFromNickname()&lt;/code&gt;, i.e. &lt;strong&gt;[sectionNickname]&lt;/strong&gt;&lt;strong&gt;BeforeFilter&lt;/strong&gt; and &lt;strong&gt;[contentNickname]BeforeFilter&lt;/strong&gt; and &lt;strong&gt;[sectionNickname]BeforeRender&lt;/strong&gt; and &lt;strong&gt;[contentNickname]BeforeRender&lt;/strong&gt;. In our example the callbacks will be &lt;em&gt;sectionOneBeforeFilter()&lt;/em&gt; and &lt;em&gt;sectionOneBeforeRender()&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;So you can define these callback methods in Pages Controller to customize punctually the way to find results and manipulate the &lt;code&gt;$section&lt;/code&gt; array before render view.&lt;/p&gt;
&lt;p&gt;In particular the &lt;strong&gt;[sectionNickname]&lt;/strong&gt;&lt;strong&gt;BeforeFilter&lt;/strong&gt; callback can be used to set parameters and class attributes to put the section method in the condition to find the expected result. For example changing the &lt;code&gt;FrontendController::$sectionOptions&lt;/code&gt; attribute like you can see in the blog posts &quot;Customizing Frontend Applications&quot; part &lt;a title=&quot;Customizing Frontend Applications [part 1]: divide objects by type in a section&quot; href=&quot;/customizing-frontend-applications-part-1-divide-objects-by-type-in-a-section&quot;&gt;1&lt;/a&gt;, &lt;a title=&quot;Customizing Frontend Applications [part 2]: how to load only selected content in a section&quot; href=&quot;/customizing-frontend-applications-part-2-load-only-selected-content&quot;&gt;2&lt;/a&gt; and &lt;a title=&quot;Customizing Frontend Applications [part 3]: time for pagination&quot; href=&quot;/customizing-frontend-applications-part-3-time-for-pagination&quot;&gt;3&lt;/a&gt; you can paginate sections&#039; contents, group BEdita objects for type, etc... .&lt;/p&gt;
&lt;p&gt;Instead the &lt;strong&gt;[sectionNickname]&lt;/strong&gt;&lt;strong&gt;BeforeRender&lt;/strong&gt; callback usually can be used to manipulate the &lt;code&gt;$section&lt;/code&gt; array that is set in section method (you can find it in &lt;code&gt;$this-&amp;gt;viewVars[&quot;section&quot;]&lt;/code&gt;).&lt;/p&gt;
&lt;h2&gt;Recap&lt;/h2&gt;
&lt;p&gt;The frontend flow of a section/content request can be summarized in this way:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;browser request&lt;/li&gt;
&lt;li&gt;call &lt;strong&gt;beforeCheckLogin&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;call &lt;strong&gt;beditaBeforeFilter&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;if exists call &lt;strong&gt;sectionBeforeFilter &lt;/strong&gt;or &lt;strong&gt;contentBeforeFilter &lt;/strong&gt;through &lt;strong&gt;route&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;routing section/content method through &lt;strong&gt;route&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;if exists call &lt;strong&gt;[sectionNickname]BeforeFilter&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;if exists and content is requested call &lt;strong&gt;[contentNickname]BeforeFilter&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;recover section and content data by nickname&lt;/li&gt;
&lt;li&gt;if exists call &lt;strong&gt;[sectionNickname]BeforeRender&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;if exists and content is requested call &lt;strong&gt;[contentNickname]BeforeRender&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;if exists call &lt;strong&gt;sectionBeforeRender &lt;/strong&gt;or &lt;strong&gt;contentBeforeRender &lt;/strong&gt;through &lt;strong&gt;route&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;call &lt;strong&gt;beditaBeforeRender&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;render view&lt;/li&gt;
&lt;li&gt;call &lt;strong&gt;beditaAfterFilter&lt;/strong&gt; method&lt;/li&gt;
&lt;/ol&gt;</description><pubDate>Tue, 03 Jan 2012 14:51:16 +0100</pubDate><link>http://docs3.bedita.net/frontends/frontend-application-flow-and-callback-methods-32</link><guid>http://docs3.bedita.net/frontends/frontend-application-flow-and-callback-methods-32</guid></item><item><title>Get more or less information from your content</title><description>How to handle BEdita objects model bindings in frontend applications&lt;hr/&gt;&lt;p&gt;How to handle BEdita objects model bindings in frontend applications&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;In frontend application you can control how many informations you want from your content. This means to read more or less fields from database throughout CakePHP associations and Containable Behavior. To see the associations of BEdita object models you should have a look at models definitions.&lt;/p&gt;
&lt;p&gt;In every BEdita object model you can also see a class property named &lt;code&gt;$modelBindings&lt;/code&gt; that is an array of different level of bindings. In frontend applications the default modelBindings should be defined from &lt;strong&gt;&quot;frontend&quot;&lt;/strong&gt; key of array, for example in Document model you have:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;$modelBindings = array(
   &quot;detailed&quot; =&amp;gt; array(...),
   &quot;default&quot; =&amp;gt; array(...),
   &quot;minimum&quot; =&amp;gt; array(...),
   &quot;frontend&quot; =&amp;gt; array(
      &quot;BEObject&quot; =&amp;gt; array(
         &quot;LangText&quot;,
         &quot;UserCreated&quot;,
         &quot;RelatedObject&quot;,
         &quot;Category&quot;,
         &quot;Annotation&quot;
      ),
      &quot;GeoTag&quot;
   )
);&lt;/pre&gt;
&lt;p&gt;Document::modelBindings[&quot;frontend&quot;] is the default bindings used when a document is loaded. Of course you can override this default in many way. Every time that a BEdita object is loaded through FrontendController::loadObj() method (that is the standard way to load every BEdita object in frontend applications) BEdita chooses what model bindings to use follow the below order:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;FrontendController::modelBindings[&quot;BEditaObjectName&quot;]&lt;/code&gt;&lt;br /&gt;You can set &lt;code&gt;$modelBindings&lt;/code&gt; property in your controller to define in general or in a specific point what associations have to be used. If you use it in a specific method remember to reset the property to avoid using those model bindings everywhere.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$config[&quot;modelBindings&quot;]&lt;/code&gt; in &lt;code&gt;app/config/frontend.ini.php&lt;/code&gt;&lt;br /&gt;This is useful if you want that your default model bindings for a frontend are different from those defined in the respective model.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;BEditaObjectModel::modelBindings[&quot;frontend&quot;]&lt;/code&gt; the default as explained above&lt;br /&gt;Example: &lt;code&gt;Document::modelBindings[&quot;frontend&quot;]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;BEditaObjectModel::modelBindings[&quot;minimum&quot;]&lt;/code&gt;, this is the fallback if default above is not defined&lt;/li&gt;
&lt;li&gt;if it also miss &quot;minimum&quot; model bindings then an exception is thrown. In this case your model is buggy. Fix it.&lt;/li&gt;
&lt;/ol&gt;</description><pubDate>Thu, 20 Oct 2011 17:55:51 +0200</pubDate><link>http://docs3.bedita.net/frontends/get-more-or-less-information-from-your-content</link><guid>http://docs3.bedita.net/frontends/get-more-or-less-information-from-your-content</guid></item><item><title>How to subscribe users to frontend apps</title><description>This article explains what you have to do to register users through a frontend application&lt;hr/&gt;&lt;p&gt;This article explains what you have to do to register users through a frontend application&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;Register users in a frontend application is a common scenario. The subscribing action is handled out of the box by BEdita 3.1 through two methods of FrontendController. The first one is &lt;strong&gt;FrontendController::subscribe() &lt;/strong&gt;action that takes care of showing the proper signup form in the view.&lt;/p&gt;
&lt;p&gt;Assuming your frontend app is www.example.com then point your browser to &lt;strong&gt;www.example.com/subscribe/user&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you are developing your frontend starting from bedita/frontends/dummy.example.com (if not you should) you will have &lt;strong&gt;views/pages/subscribe.tpl&lt;/strong&gt; that uses &lt;strong&gt;views/elements/signup.tpl&lt;/strong&gt;, view templates that you can easily modify if necessary&lt;strong&gt;.&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In the browser you should see a subscribtion form with some data to fill. Form submission will start the subscribe process calling &lt;strong&gt;FrontendController::hashjob() &lt;/strong&gt;method. &lt;br /&gt;A user and an associated card object (that you can see/handle in Addressbook module) will be created and an email will be sent to the user to confirm the subscription through a link with unique hash. The user will be in &quot;invalid&quot; mode (login blocked) until the subscription will be confirmed. If you don&#039;t want to create the card object remove the input:&lt;/p&gt;
&lt;pre class=&quot;brush: xml; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;&lt;input type=&quot;text&quot; name=&quot;data[Card][name]&quot; /&gt;&lt;/pre&gt;
&lt;p&gt;Instead if you want more card details add others input according to &lt;em&gt;&lt;strong&gt;cards&lt;/strong&gt;&lt;/em&gt; table, for example:&lt;/p&gt;
&lt;pre class=&quot;brush: xml; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;&lt;input type=&quot;text&quot; name=&quot;data[Card][street_address]&quot; /&gt;

&lt;input type=&quot;text&quot; name=&quot;data[Card][company_name]&quot; /&gt;&lt;/pre&gt;
&lt;p&gt;The fields &lt;em&gt;street_address&lt;/em&gt; and &lt;em&gt;company_name&lt;/em&gt; of &lt;em&gt;&lt;strong&gt;cards&lt;/strong&gt;&lt;/em&gt; table will be populated by the input form data.&lt;/p&gt;
&lt;p&gt;By default a subscribed user will be associated also to the groups defined in &lt;strong&gt;&quot;authorizedGroups&quot;&lt;/strong&gt; array in &lt;strong&gt;frontendapp/config/frontend.ini.php&lt;/strong&gt; file. If the array is empty the user will be associated to all non-backend groups, that you can manage in &lt;strong&gt;Administration &lt;/strong&gt;&lt;span style=&quot;font-family: mceinline;&quot;&gt;module&lt;/span&gt; .&lt;/p&gt;
&lt;p&gt;Alternatively you can use the hashjobBeforeFilter() callback, writing in PagesController something like:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;function hashjobBeforeFilter() {
   if (!empty($this-&amp;gt;passedArgs[0]) &amp;amp;&amp;amp; $this-&amp;gt;passedArgs[0] == &quot;user_sign_up&quot;) {
      $this-&amp;gt;data[&quot;groups&quot;] = array(&quot;group_1&quot;, &quot;group_2&quot;);
   }
} &lt;/pre&gt;
&lt;p&gt;Once user is activated he can log in frontend app pointing to &lt;strong&gt;www.example.com/login&lt;/strong&gt;&lt;/p&gt;</description><pubDate>Wed, 23 Feb 2011 10:25:05 +0100</pubDate><link>http://docs3.bedita.net/frontends/how-to-subscribe-users-to-frontend-app</link><guid>http://docs3.bedita.net/frontends/how-to-subscribe-users-to-frontend-app</guid></item><item><title>Template development - beFront helper</title><description>This article explains how to use BeFrontHelper in frontend template development&lt;hr/&gt;&lt;p&gt;This article explains how to use BeFrontHelper in frontend template development&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;When you work on templates using CakePhp, you use (or should use) cake helpers (for instance: &lt;code&gt;FormHelper&lt;/code&gt;, &lt;code&gt;HtmlHelper&lt;/code&gt;, &lt;code&gt;JavascriptHelper&lt;/code&gt;, etc.). If you don&#039;t know what an &lt;code&gt;Helper&lt;/code&gt; is, take a look at &lt;a href=&quot;http://book.cakephp.org/#!/view/1095/Helpers&quot;&gt;cakephp documentation page about helpers&lt;/a&gt;, before continuing to read this article.&lt;br /&gt;&lt;br /&gt;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 &lt;a href=&quot;http://www.smarty.net/docs/en/&quot;&gt;Smarty Documentation&lt;/a&gt;). BEdita helper names start with &quot;Be&quot;: &lt;code&gt;BeEmbedFlashHelper&lt;/code&gt;, &lt;code&gt;BeEmbedMediaHelper&lt;/code&gt;, &lt;code&gt;BeFrontHelper&lt;/code&gt;, &lt;code&gt;BeThumbHelper&lt;/code&gt;, &lt;code&gt;BeTimeHelper&lt;/code&gt;, &lt;code&gt;BeToolbarHelper&lt;/code&gt;, &lt;code&gt;BeTreeHelper&lt;/code&gt;, &lt;code&gt;BeurlHelper&lt;/code&gt; (check them in &lt;a href=&quot;http://api.bedita.com/&quot;&gt;BEdita API documentation&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;BeFrontHelper&#039;s aim is to help template developer with most common tasks, dealing with &quot;templates topics&quot; more than &quot;controller/business logic&quot;. Developing BeFrontHelper, BEdita staff studied deeply SEO issues and metadata management: business logic reflects some decisions taken by BEdita developers discussing SEO documentation.&lt;/p&gt;
&lt;p&gt;Let&#039;s see an example from dummy example site in bedita &quot;ulmus&quot; release: &lt;code&gt;bedita-3.1-ulmus/frontends/dummy.example.com/views/layouts/default.tpl&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;brush: xml; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{$html-&amp;gt;docType(&#039;xhtml-trans&#039;)}
&amp;lt; html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; lang=&quot;{$currLang}&quot; dir=&quot;ltr&quot; &amp;gt;
   &amp;lt; head &amp;gt;
      {$html-&amp;gt;charset()}
      &amp;lt; title &amp;gt;
         {$beFront-&amp;gt;title()}
      &amp;lt; / title &amp;gt;
      {$beFront-&amp;gt;metaAll()}
      {$beFront-&amp;gt;metaDc()}
      &amp;lt; link rel=&quot;icon&quot; href=&quot;{$html-&amp;gt;webroot}favicon.png&quot; type=&quot;image/png&quot; / &amp;gt;
      {$beFront-&amp;gt;feeds()}
      {$scripts_for_layout}
   &amp;lt; / head &amp;gt;
   &amp;lt; body &amp;gt;
      {$view-&amp;gt;element(&#039;header&#039;)}
      {$content_for_layout}
      {$view-&amp;gt;element(&#039;footer&#039;)}
      {$beFront-&amp;gt;stats()}
   &amp;lt; / body &amp;gt;
&amp;lt; / html &amp;gt;&lt;/pre&gt;
&lt;p&gt;In this example, BeFrontHelper is used in 5 calls, respectively the methods are &quot;title&quot;, &quot;metaAll&quot;, &quot;metaDc&quot;, &quot;feeds&quot; and &quot;stats&quot;. Lets see what these methods (and some others) do.&lt;/p&gt;
&lt;h1&gt;{$beFront-&amp;gt;title()}&lt;/h1&gt;
&lt;p&gt;BeFrontHelper function title return a default title for a page, according to page content and/or section/publication.&lt;/p&gt;
&lt;p&gt;The title is like: &quot;publication title/publication name&quot; - &quot;section title/current content title&quot;.&lt;br /&gt;A good SEO point: distinguish titles inside a Web application or Website, according to real context content of a page.&lt;br /&gt;This method works in that direction.&lt;/p&gt;
&lt;h1&gt;{$beFront-&amp;gt;metaAll()}&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;{$beFront-&amp;gt;metaAll()}&lt;/code&gt; generates html tags for content metadata: &quot;description&quot;, &quot;author&quot;, &quot;http-equiv&quot; and &quot;generator&quot;.&lt;br /&gt;&quot;Description&quot; is the first not empty value among the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;currentContent[&quot;description&quot;]&lt;/li&gt;
&lt;li&gt;currentContent[&quot;abstract&quot;] truncated to 255 characters&lt;/li&gt;
&lt;li&gt;currentContent[&quot;body&quot;] truncated to 255 characters&lt;/li&gt;
&lt;li&gt;section[&quot;description&quot;]&lt;/li&gt;
&lt;li&gt;publication[&quot;description&quot;]&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note: meta &quot;description&quot; can be obtained separately calling the method:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;{$beFront-&amp;gt;metaDescription()}&lt;/pre&gt;
&lt;p&gt;&quot;Author&quot; meta tag can be omitted, in case &quot;license&quot; field is not found in the following objects:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;currentContent&lt;/li&gt;
&lt;li&gt;section&lt;/li&gt;
&lt;li&gt;publication&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;{$beFront-&amp;gt;metaDc()}&lt;/h1&gt;
&lt;p&gt;It returns html-DC tags &lt;code&gt;DC.title&lt;/code&gt;, &lt;code&gt;DC.description&lt;/code&gt;, &lt;code&gt;DC.format&lt;/code&gt;, &lt;code&gt;DC.language&lt;/code&gt;, &lt;code&gt;DC.creator&lt;/code&gt;, &lt;code&gt;DC.publisher&lt;/code&gt;, &lt;code&gt;DC.date&lt;/code&gt;, &lt;code&gt;DC.modified&lt;/code&gt;, &lt;code&gt;DC.identifier&lt;/code&gt;, &lt;code&gt;DC.rights&lt;/code&gt;, &lt;code&gt;DC.license&lt;/code&gt;. For more details about Dublin Core Html Tags, look at &lt;a href=&quot;http://www.dublincore.org/documents/dcq-html/&quot;&gt;Expressing Dublin Core in HTML/XHTML meta and link elements&lt;/a&gt;.&lt;/p&gt;
&lt;h1&gt;{$beFront-&amp;gt;feeds()}&lt;/h1&gt;
&lt;p&gt;When there are feeds, this method display feeds links; for instance:&lt;/p&gt;
&lt;pre class=&quot;brush: xml; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;&amp;lt; link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;Blog&quot; href=&quot;/rss/blog&quot; / &amp;gt;
&amp;lt; link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;News&quot; href=&quot;/rss/news&quot; / &amp;gt;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h1&gt;{$beFront-&amp;gt;stats()}&lt;/h1&gt;
&lt;p&gt;It returns publication stats code, if set (only if frontend app is not staging site).&lt;/p&gt;
&lt;h1&gt;{$beFront-&amp;gt;menu()}&lt;/h1&gt;
&lt;p&gt;Tree structure returned in html unordered list, with links to the contents.&lt;/p&gt;
&lt;h1&gt;{$beFront-&amp;gt;breadcrumb()}&lt;/h1&gt;
&lt;p&gt;It returns the breadcrumb trail for the page.&lt;/p&gt;
&lt;p&gt;--&lt;br /&gt;Let&#039;s say something about smarty variables used in the examples of this article.&lt;br /&gt;&lt;br /&gt;The variables &lt;code&gt;{$currentContent}&lt;/code&gt;, &lt;code&gt;{$section}&lt;/code&gt;, &lt;code&gt;{$publication}&lt;/code&gt; refer to BEdita objects set by FrontendController.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;{$currentContent}&lt;/code&gt; is the main object of the page (can be referred directly through url like &lt;a href=&quot;http://www.bedita.com/blog/template-development-befront-helper&quot;&gt;http://www.bedita.com/blog/template-development-befront-helper&lt;/a&gt;). &lt;code&gt;{$currentContent[&quot;description&quot;]}&lt;/code&gt;, &lt;code&gt;{$currentContent[&quot;abstract&quot;]}&lt;/code&gt; and &lt;code&gt;{$currentContent[&quot;body&quot;]}&lt;/code&gt; refer to the content of Document-&amp;gt;description, Document-&amp;gt;short text and Document-&amp;gt;long text of the Document view in Bedita backend application (for example &lt;code&gt;http://mybeditaapp/documents/view/&lt;/code&gt;).&lt;br /&gt;&lt;br /&gt;&lt;code&gt;{$section}&lt;/code&gt; and &lt;code&gt;{$publication}&lt;/code&gt; are respectively Section and Publication objects for the url, if any. For example this document is inside Section &quot;blog&quot; of Publication &quot;BEditafrontsite&quot;, and the &lt;code&gt;{$currentContent}&lt;/code&gt; in this page is the Document that you are reading.&lt;code&gt;&lt;code&gt;&lt;code&gt;&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;/code&gt;&lt;/code&gt;&lt;/p&gt;</description><pubDate>Wed, 09 Mar 2011 09:17:03 +0100</pubDate><link>http://docs3.bedita.net/frontends/template-development-befront-helper</link><guid>http://docs3.bedita.net/frontends/template-development-befront-helper</guid></item><item><title>Migrating frontends from BEdita 3.1 to 3.2</title><description>A brief guide to upgrade your frontends from 3.1&lt;hr/&gt;&lt;p&gt;A brief guide to upgrade your frontends from 3.1&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;BEdita 3.2 comes with CakePHP 1.3.x series that introduces some changes. You can see a full guide to migrate CakePHP 1.2.x to 1.3.x in &lt;a href=&quot;http://book.cakephp.org/#!/view/1561/Migrating-from-CakePHP-1-2-to-1-3&quot; target=&quot;_blank&quot;&gt;CakePHP cook book&lt;/a&gt;, here instead we&#039;ll discuss what you have to change in your frontend apps to work properly.&lt;/p&gt;
&lt;p&gt;First of all replace in your frontend apps &lt;strong&gt;config/core.php&lt;/strong&gt; and &lt;strong&gt;webroot/index.php&lt;/strong&gt;. You can use the corresponding files bundles in BEdita 3.2, for example copy &lt;strong&gt;frontends/dummy.example.com/config/core.php&lt;/strong&gt; and &lt;strong&gt;frontends/dummy.example.com/webroot/index.php&lt;/strong&gt; to the corresponding paths of your frontend apps.&lt;/p&gt;
&lt;h1&gt;Router&lt;/h1&gt;
&lt;p&gt;A small change has also been done to routing params. Routed params should now only consist of alphanumeric chars, - and _ or &lt;code&gt;/[A-Z0-9-_+]+/&lt;/code&gt;. This involve &lt;strong&gt;frontend-app/config/route.php&lt;/strong&gt; because the old rule:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;Router::connect(
   &#039;/(?!pages)(.*)&#039;, 
   array(
      &#039;controller&#039; =&amp;gt; &#039;pages&#039;, 
      &quot;action&quot; =&amp;gt; &quot;route&quot;
   )
);&lt;/pre&gt;
&lt;p&gt;will not work anymore. Replace it with:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;Router::connect(
   &#039;/*&#039;, 
   array(
      &#039;controller&#039; =&amp;gt; &#039;pages&#039;, 
      &#039;action&#039; =&amp;gt; &#039;route&#039;
   )
);&lt;/pre&gt;
&lt;p&gt;It has to be the last router rule and it delegates routing to FrontendController::route() method.&lt;/p&gt;
&lt;h1&gt;&lt;br /&gt;Config&lt;/h1&gt;
&lt;p&gt;The bootstrap chain is changed, now all necessary configurations file are included from bedita.ini.php, so edit &lt;strong&gt;frontend-app/config/frontend.ini.php&lt;/strong&gt; replacing:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;require_once(BEDITA_CORE_PATH . DS . &quot;config&quot; . DS . &quot;bedita.ini.php&quot;) ;

if (file_exists (BEDITA_CORE_PATH . DS . &quot;config&quot; . DS . &quot;bedita.cfg.php&quot;) ) {
   include(BEDITA_CORE_PATH . DS . &quot;config&quot; . DS . &quot;bedita.cfg.php&quot;) ;
}

if (file_exists (APP. &quot;config&quot; . DS . &quot;mapping.cfg.php&quot;) ) {
   include(APP. &quot;config&quot; . DS . &quot;mapping.cfg.php&quot;) ;    
}&lt;/pre&gt;
&lt;p&gt;with:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;require BEDITA_CORE_PATH . DS . &quot;config&quot; . DS . &quot;bedita.ini.php&quot;;
include(APP. &quot;config&quot; . DS . &quot;mapping.cfg.php&quot;);&lt;/pre&gt;
&lt;p&gt;The modelBinding structure has changed: GeoTag is part of BEObject. In &lt;strong&gt;frontend-app/config/frontend.ini.php&lt;/strong&gt; use GeoTag &#039;inside&#039; BEObject, like in the following example:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;$config[&#039;modelBindings&#039;] = array(
   &#039;Document&#039;=&amp;gt;array(
      &#039;BEObject&#039;=&amp;gt;array(
         &quot;LangText&quot;,
         &quot;RelatedObject&quot;,
         &quot;GeoTag&quot;
      )
   ),
//...
);&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h1&gt;View and Helpers&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;HtmlHelper::css()&lt;/code&gt; no longer has an &lt;code&gt;$inline&lt;/code&gt; parameter. Use &lt;code&gt;$options[&#039;inline&#039;]&lt;/code&gt; instead, for example if you had:&lt;br /&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;{$html-&amp;gt;css(&quot;ui.datepicker&quot;, null, null, false)}&lt;/pre&gt;
you have to change it to:&lt;br /&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;{$html-&amp;gt;css(&quot;ui.datepicker&quot;, null, [&#039;inline&#039;=&amp;gt;false])}&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;flash()&lt;/code&gt; no longer auto echos. If you used Smarty as a template engine you should replace:&lt;br /&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;{if $session-&amp;gt;flash(&#039;error&#039;)}{/if}&lt;/pre&gt;
with:&lt;br /&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;{$session-&amp;gt;flash(&#039;error&#039;)}&lt;/pre&gt;
and similar. &lt;br /&gt;Moreover in &lt;code&gt;SessionComponent::setFlash()&lt;/code&gt; second param is used for setting an element instead of layout, so in your applications you will need to:&lt;br /&gt;&lt;ol&gt;
&lt;li&gt;Move &lt;strong&gt;message.tpl&lt;/strong&gt; from &lt;strong&gt;views/layouts&lt;/strong&gt; into &lt;strong&gt;views/elements&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;message.tpl&lt;/strong&gt; rename &lt;code&gt;$content_for_layout&lt;/code&gt; variable to &lt;code&gt;$message&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;JavascriptHelper is deprecated, you should replace:  &lt;br /&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;$javascript-&amp;gt;link() &lt;/pre&gt;
with: &lt;br /&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;$html-&amp;gt;script()&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;The array of smarty &lt;code&gt;assign_concat &lt;/code&gt;function now must begin from 1&lt;/li&gt;
&lt;li&gt;&lt;code&gt;MediaProviderHelper::$themeWeb&lt;/code&gt; no longer exist&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;BEdita modules (CakePHP plugins)&lt;/h1&gt;
&lt;p&gt;Support for &lt;strong&gt;vendors/css, vendors/js, and vendors/img &lt;/strong&gt; in plugin (bedita module) has been removed. They have been replaced with plugin (bedita module) webroot directories. &lt;br /&gt;If you are using some additional modules you should update them. &lt;br /&gt;If you created a personalized module you have to move your_module/vendors/css, your_module/vendors/js, your_module/vendors/img folders in your_module/webroot relative folders.&lt;/p&gt;
&lt;h1&gt;Frontend callbacks&lt;/h1&gt;
&lt;p&gt;If you used the nickname&#039;s callback feature in your PagesController you have to change the name because now the nickname is camelized to make the callbacks consistent with other methods names. In practice:&lt;/p&gt;
&lt;h2&gt;3.1 (old)&lt;/h2&gt;
&lt;p&gt;With &lt;code&gt;this-is-my-content&lt;/code&gt; it called &lt;code&gt;this_is_my_contentBeforeFilter()&lt;/code&gt;, ....&lt;/p&gt;
&lt;h2&gt;3.2 (new)&lt;/h2&gt;
&lt;p&gt;With &lt;code&gt;this-is-my-&lt;/code&gt;&lt;code&gt;content&lt;/code&gt; it calls &lt;code&gt;thisIsMyContentBeforeFilter()&lt;/code&gt;, ...&lt;/p&gt;</description><pubDate>Thu, 17 Feb 2011 12:19:46 +0100</pubDate><link>http://docs3.bedita.net/frontends/migrating-frontends-from-3-2-to-3-1</link><guid>http://docs3.bedita.net/frontends/migrating-frontends-from-3-2-to-3-1</guid></item><item><title>Frontend Application Flow and callback methods</title><description>To help the frontend developers BEdita comes with a series of callback methods that allowing to filter and handling data. Understanding how the flow of frontend applications works and which callbacks the developer has in hand is one of the fundamental things to start developing a custom frontend&lt;hr/&gt;&lt;p&gt;To help the frontend developers BEdita comes with a series of callback methods that allows to filter and handle data. Understanding how the flow of frontend applications works and which callbacks the developer has in hand is one of the fundamental things to start developing a custom frontend&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;To fit variegated needs that you can encounter developing a frontend application, BEdita comes with a series of callback methods that allow to find and handle data. Before having a look at this callbacks let&#039;s go to see what happens in a standard frontend flow.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;note:&lt;/strong&gt; the &lt;em style=&quot;color: grey;&quot;&gt;italic grey text parts&lt;/em&gt; referred to BEdita 3.1 version. In BEdita 3.0.x series is missing.&lt;/p&gt;
&lt;h1&gt;Frontend Application Flow&lt;/h1&gt;
&lt;p&gt;Supposing we have a BEdita publication reachable from &lt;code&gt;http://www.example.com&lt;/code&gt; and we want to see the contents of a section with nickname &lt;em&gt;section-1&lt;/em&gt;, in browser address bar we&#039;ll write&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/section-1&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Everything that doesn&#039;t start with &lt;em&gt;pages&lt;/em&gt; is handled by &lt;strong&gt;route&lt;/strong&gt; method that decide what to do. So if you have a custom method in Pages Controller you can call it in standard CakePHP mode&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/pages/myCustomMethod&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;route&lt;/strong&gt; method gets first parameters passed by URL (in our case &lt;em&gt;section-1&lt;/em&gt;), check if it&#039;s a reserved word as defined in configuration files and eventually try to call method with that name. So you could put in your &lt;strong&gt;bedita-app/config/bedita.cfg.php&lt;/strong&gt; the reserved word &lt;em&gt;myCustomMethod&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;$config[&quot;cfgReservedWords&quot;] = array(&quot;myCustomMethod&quot;);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;and call directly &lt;code&gt;http://www.example.com/myCustomMethod&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If none reserved word is found then BEdita consider the parameter a nickname, check if it corresponds to a section object or not and call respectively &lt;strong&gt;section&lt;/strong&gt; method or &lt;strong&gt;content&lt;/strong&gt; method. These two methods will load all section and contents data and set to view the array &lt;code&gt;$section&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Finally the view is rendered.&lt;/p&gt;
&lt;h1&gt;Callback Methods&lt;/h1&gt;
&lt;p&gt;There are two (&lt;em style=&quot;color: grey;&quot;&gt;four in 3.1 release&lt;/em&gt;) main callbacks always called that can be used to insert logic before or after controller actions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em style=&quot;color: grey;&quot;&gt;&lt;strong style=&quot;color: grey;&quot;&gt;beforeCheckLogin&lt;/strong&gt; (present from 3.1 release) called by FrontendController::initAttributes method is executed before check login operation is performed. It&#039;s useful if you want to skip the user check login operation for specific items setting to true the AppController::$skipCheck attribute. Note that the checkLogin method is called before beditaBeforeFilter.&lt;br /&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;beditaBeforeFilter&lt;/strong&gt; called by AppController::&lt;strong&gt;beforeFilter&lt;/strong&gt; method is executed before every action in the controller;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;beditaBeforeRender &lt;/strong&gt;called by&lt;strong&gt; &lt;/strong&gt;AppController::&lt;strong&gt;beforeRender &lt;/strong&gt;method is executed after controller action but before view is rendered.&lt;/li&gt;
&lt;li&gt;&lt;em style=&quot;color: grey;&quot;&gt;&lt;strong style=&quot;color: grey;&quot;&gt;beditaAfterFilter&lt;/strong&gt; (present from 3.1 release) called by AppController::afterFilter method is executed after the render is done. It&#039;s the last thing made by controller.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition some specific callbacks are called if respective method exists. When a reserved word is found a callback &lt;strong&gt;[reservedWord]BeforeFilter&lt;/strong&gt; (&lt;em&gt;my_custom_methodBeforeFilter&lt;/em&gt;) is called before reservedWord method and another callback &lt;strong&gt;[reservedWord]&lt;/strong&gt;&lt;strong&gt;BeforeRender&lt;/strong&gt; (&lt;em&gt;my_custom_methodBeforeRender&lt;/em&gt;) is called soon after reservedWord method.&lt;/p&gt;
&lt;p&gt;Similar callbacks are handled in &lt;strong&gt;section&lt;/strong&gt; method using the section &lt;em style=&quot;color: grey;&quot;&gt;(and content from 3.1 release)&lt;/em&gt; nickname replacing &lt;em&gt;&quot;-&quot;&lt;/em&gt; with &lt;em&gt;&quot;_&quot;&lt;/em&gt; in method name, i.e. &lt;strong&gt;[section-nickname]&lt;/strong&gt;&lt;strong&gt;BeforeFilter&lt;/strong&gt; &lt;em style=&quot;color: grey;&quot;&gt;(and &lt;strong style=&quot;color: grey;&quot;&gt;[content-nickname]BeforeFilter&lt;/strong&gt; from 3.1 release)&lt;/em&gt; and &lt;strong&gt;[section-nickname]BeforeRender&lt;/strong&gt; &lt;em style=&quot;color: grey;&quot;&gt;(and &lt;strong style=&quot;color: grey;&quot;&gt;[content-nickname]BeforeRender&lt;/strong&gt; from 3.1 release)&lt;/em&gt;. In our example the callbacks will be &lt;em&gt;section_1BeforeFilter()&lt;/em&gt; and &lt;em&gt;section_1BeforeRender()&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;So you can define these callback methods in Pages Controller to customize punctually the way to find results and manipulate the &lt;code&gt;$section&lt;/code&gt; array before render view.&lt;/p&gt;
&lt;p&gt;In particular the &lt;strong&gt;[section-nickname]&lt;/strong&gt;&lt;strong&gt;BeforeFilter&lt;/strong&gt; callback can be used to set parameters and class attributes to put the section method in the condition to find the expected result. For example changing the &lt;code&gt;FrontendController::$sectionOptions&lt;/code&gt; attribute like you can see in the blog posts &quot;Customizing Frontend Applications&quot; part &lt;a title=&quot;Customizing Frontend Applications [part 1]: divide objects by type in a section&quot; href=&quot;/customizing-frontend-applications-part-1-divide-objects-by-type-in-a-section&quot;&gt;1&lt;/a&gt;, &lt;a title=&quot;Customizing Frontend Applications [part 2]: how to load only selected content in a section&quot; href=&quot;/customizing-frontend-applications-part-2-load-only-selected-content&quot;&gt;2&lt;/a&gt; and &lt;a title=&quot;Customizing Frontend Applications [part 3]: time for pagination&quot; href=&quot;/customizing-frontend-applications-part-3-time-for-pagination&quot;&gt;3&lt;/a&gt; you can page sections&#039; contents, group BEdita objects for type, etc... .&lt;/p&gt;
&lt;p&gt;Instead the &lt;strong&gt;[section-nickname]&lt;/strong&gt;&lt;strong&gt;BeforeRender&lt;/strong&gt; callback usually can be used to manipulate the $section array that is setted in section method (you can find it in $this-&amp;gt;viewVars[&quot;section&quot;]).&lt;/p&gt;
&lt;h1&gt;Recap&lt;/h1&gt;
&lt;p&gt;The frontend flow of a section/content request can be summarized in this way:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;browser request&lt;/li&gt;
&lt;li&gt;&lt;em style=&quot;color: grey;&quot;&gt;call &lt;strong style=&quot;color: grey;&quot;&gt;beforeCheckLogin&lt;/strong&gt; method (from 3.1 BEdita version)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;call &lt;strong&gt;beditaBeforeFilter&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;routing section/content method through &lt;strong&gt;route&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;if exists call &lt;strong&gt;[section-nickname]BeforeFilter&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;&lt;em style=&quot;color: grey;&quot;&gt;if exists and content is requested call &lt;strong&gt;[content-nickname]BeforeFilter&lt;/strong&gt; method (from 3.1 BEdita version)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;recover section and content data by nickname&lt;/li&gt;
&lt;li&gt;if exists call &lt;strong&gt;[section-nickname]BeforeRender&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;&lt;em style=&quot;color: grey;&quot;&gt;if exists and content is requested call &lt;strong style=&quot;color: grey;&quot;&gt;[content-nickname]BeforeRender&lt;/strong&gt; method (from 3.1 BEdita version)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;call &lt;strong&gt;beditaBeforeRender&lt;/strong&gt; method&lt;/li&gt;
&lt;li&gt;render view&lt;/li&gt;
&lt;li&gt;&lt;em style=&quot;color: grey;&quot;&gt;call &lt;strong style=&quot;color: grey;&quot;&gt;beditaAfterFilter&lt;/strong&gt; method (from 3.1 BEdita version)&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;</description><pubDate>Mon, 22 Feb 2010 17:38:12 +0100</pubDate><link>http://docs3.bedita.net/frontends/frontend-application-flow-and-callback-methods</link><guid>http://docs3.bedita.net/frontends/frontend-application-flow-and-callback-methods</guid></item><item><title>Customizing Frontend Applications [part 3]: time for pagination</title><description>Paginating items in a frontend application&lt;hr/&gt;&lt;p&gt;Paginating items in a frontend application&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;The third episode of our &lt;em&gt;&quot;Customizing Frontend Applications&quot;&lt;/em&gt; saga will be focused on pagination. Sooner or later each web developer/designer working on a web site will have to deal with contents pagination.&lt;br /&gt;BEdita comes with an easy way to do it, allowing a default pagination setting for the entire frontend application and/or a specific one for each section you want.&lt;/p&gt;
&lt;p&gt;Once again we&#039;ll use the &lt;code&gt;FrontendController::$sectionOptions&lt;/code&gt; attribute, in particular we are interested in &lt;strong&gt;childrenParams&lt;/strong&gt; key.&lt;/p&gt;
&lt;p&gt;Overriding this class attribute in our PagesController we can set a default pagination for all our sections:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;protected $sectionOptions = array(
   &quot;showAllContents&quot; =&amp;gt; true,
   &quot;itemsByType&quot; =&amp;gt; false,
   &quot;childrenParams&quot; =&amp;gt; array(
      &quot;order&quot; =&amp;gt; &quot;title&quot;,
      &quot;dim&quot; =&amp;gt; 10,
      &quot;dir&quot; =&amp;gt; true
   )
); &lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;In this way we are saying to show 10 items for page sorted by title&lt;sup&gt;&lt;a href=&quot;#note1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt; in ascendant mode. Set dir to false to reverse the order of items. The couple &lt;code&gt;&quot;page&quot; =&amp;gt; 1&lt;/code&gt; is implied but if you want to show your items starting from page 2 you can add it to childrenParams.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Change page, sort or page dimension is very very simple&lt;/strong&gt;. We can use the named params convention used by CakePHP, so&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;http://www.example.com/section-1/page:2&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;will switch automagically to page 2 and similary we can change the order&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;http://www.example.com/section-1/order:created&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;the order direction&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;http://www.example.com/section-1/dir:0&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;or several things at once&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;http://www.example.com/section-1/page:2/dir:0&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The only thing you can do it at this point is build your toolbar pagination and to do this you have a toolbar array available inside &lt;code&gt;$section&lt;/code&gt; array, for example:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;[&#039;toolbar&#039;] =&amp;gt; Array (
   [&#039;first&#039;] =&amp;gt; 1
   [&#039;prev&#039;] =&amp;gt; 1
   [&#039;next&#039;] =&amp;gt; 3
   [&#039;last&#039;] =&amp;gt; 5
   [&#039;size&#039;] =&amp;gt; 9
   [&#039;pages&#039;] =&amp;gt; 5
   [&#039;page&#039;] =&amp;gt; 2
   [&#039;dim&#039;] =&amp;gt; 2
   [&#039;start&#039;] =&amp;gt; 3
   [&#039;end&#039;] =&amp;gt; 4
)&lt;/pre&gt;
&lt;p&gt;&lt;code&gt; &lt;/code&gt;where:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;first&lt;/strong&gt; is equal to 0 if we are in the first page&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;prev&lt;/strong&gt; is the previous page&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;next&lt;/strong&gt; is the next page&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;last&lt;/strong&gt; is the last page and is equal to 0 when we are in the last page&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;size&lt;/strong&gt; is the total number of items&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;pages&lt;/strong&gt; is the total number of pages available&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;page&lt;/strong&gt; is the current page number&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;dim&lt;/strong&gt; is the dimension of items for page&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;start&lt;/strong&gt; is the numeric position of first current page&#039;s item&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;end&lt;/strong&gt; is the numeric position of last current page&#039;s item&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So you could build your own helper to show the pagination toolbar or you can use the &lt;a title=&quot;API doc&quot; href=&quot;http://api.bedita.com/classBeToolbarHelper.html&quot; target=&quot;_blank&quot;&gt;BeToolbar&lt;/a&gt; helper of BEdita core.&lt;/p&gt;
&lt;h1&gt;Change the default pagination for a section&lt;/h1&gt;
&lt;p&gt;As usual (if you read the previous articles &lt;a title=&quot;Customizing Frontend Applications [part 1]: divide objects by type in a section&quot; href=&quot;/blog/customizing-frontend-applications-part-1-divide-objects-by-type-in-a-section&quot; target=&quot;_self&quot;&gt;1&lt;/a&gt;-&lt;a title=&quot;Customizing Frontend Applications [part 2]: how to load only selected content in a section&quot; href=&quot;/blog/customizing-frontend-applications-part-2-load-only-selected-content&quot; target=&quot;_self&quot;&gt;2&lt;/a&gt;) you can change the default &lt;code&gt;$sectionOptions[&quot;childrenParams&quot;]&lt;/code&gt; attribute for a specific section thorugh out the &lt;strong&gt;section-nicknameBeforeFilter&lt;/strong&gt; callback.&lt;/p&gt;
&lt;p&gt;That&#039;s it.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;sup&gt;&lt;a name=&quot;note1&quot;&gt;&lt;/a&gt;[1]&lt;/sup&gt; Note that &quot;title&quot; is a field of &quot;objects&quot; table used by BEObject model, so if you want to be sure to avoid ambiguous fields you should specify the model field you want to order by i.e. &lt;/em&gt;&lt;code&gt;&quot;order&quot; =&amp;gt; &quot;BEObject.title&lt;/code&gt;&lt;em&gt;&lt;code&gt;&quot;&lt;/code&gt;. We&#039;ll see in other post how to filter the selection of items using &lt;strong&gt;&quot;filter&quot;&lt;/strong&gt; key in &lt;strong&gt;&quot;childrenParams&quot;&lt;/strong&gt;. This filter can be build using fields of other tables that can collide with BEObject fields.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;</description><pubDate>Mon, 22 Feb 2010 10:41:22 +0100</pubDate><link>http://docs3.bedita.net/frontends/customizing-frontend-applications-part-3-time-for-pagination</link><guid>http://docs3.bedita.net/frontends/customizing-frontend-applications-part-3-time-for-pagination</guid></item><item><title>Customizing Frontend Applications [part 2]: how to load only selected content in a section</title><description>Improve speed performance by narrowing your requests to the API&lt;hr/&gt;&lt;p&gt;Improve speed performance by narrowing your requests to the API&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;While programming, you can request the content of a certain section by URL, with something like &lt;strong&gt;http://www.example.com/section-nickname/content-nickname&lt;/strong&gt;. The requested content is loaded into the &lt;code&gt;$section[&quot;currentContent&quot;]&lt;/code&gt; array, while more content – actually every content in the same section – is placed into the &lt;code&gt;$section[&quot;childContents&quot;]&lt;/code&gt; array. This additional content is loaded in &quot;&lt;em&gt;base level mode&quot;&lt;/em&gt; (cfr. the API manual, &quot;baseLevel&quot;), which means that only basic informations about various objects are given (such as the title, the description, its ID and a few more).&lt;/p&gt;
&lt;p&gt;Now this is indeed useful in standard scenarios: when you are showing a particular &lt;em&gt;content&lt;/em&gt; and listing, at the same time, related contents in the same section. Imagine you are showing an article and you want to put links to more contents in a contextual menu. This is common, but sometimes you are interested only in a single object, while you don&#039;t really need to load all related stuff.&lt;/p&gt;
&lt;p&gt;In these cases you can improve the data loading performance by excluding this additional content (you actually give up the option of having also &lt;code&gt;$section[&quot;childContents&quot;]&lt;/code&gt; array). Obviously the improvement will be much more evident when that particular section is burdened, it has got many objects inside.&lt;/p&gt;
&lt;p&gt;However, moving forward into the discussion started in the previous article &lt;a href=&quot;http://staging.bedita.com/blog/customizing-frontend-applications-part-1-divide-objects-by-type-in-a-section&quot; target=&quot;_blank&quot;&gt;&quot;Customizing Frontend Applications [part 1]: divide objects by type in a section&quot;&lt;/a&gt;, we&#039;re going to use the Frontend Controller attribute &lt;code&gt;$sectionOptions&lt;/code&gt;. This time too, &lt;strong&gt;we may proceed in two different ways, the choice depending on whether we want a custom behavior for a specific section (1) or alternatively we prefer to modify the default behavior for the whole frontend application (2)&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;So I&#039;m showing you both:&lt;/p&gt;
&lt;h2&gt;1. Custom behavior for a section&lt;/h2&gt;
&lt;p&gt;Like we did in the previous post, we are going to use the &lt;strong&gt;nicknameBeforeFilter&lt;/strong&gt; callback: It is automatically called before section data are loaded, so in the controller:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;protected function section-nicknameBeforeFilter() {
   $this-&amp;gt;sectionOptions[&quot;showAllContents&quot;] = false;
}&lt;/pre&gt;
&lt;p&gt;(pay attention to change &quot;section-nickname&quot; with the exact nickname of your section).&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h2&gt;2. Change the default behavior&lt;/h2&gt;
&lt;p&gt;To change the way the API answers to requests, edit your Pages Controller. You have to change the &lt;code&gt;$sectionOptions&lt;/code&gt; attribute, by setting the &lt;span style=&quot;font-weight: bold; font-family: &#039;Courier New&#039;, Courier, monospace;&quot;&gt;showAllContents&lt;/span&gt; property to &lt;span style=&quot;font-style: italic; font-family: &#039;Courier New&#039;, Courier, monospace;&quot;&gt;false&lt;/span&gt;:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;protected $sectionOptions = array(
   &quot;showAllContents&quot; =&amp;gt; false, 
   &quot;itemsByType&quot; =&amp;gt; false, 
   &quot;childrenParams&quot; =&amp;gt; array()
);&lt;/pre&gt;
&lt;p&gt;When &lt;strong&gt;showAllContents&lt;/strong&gt; is set to &lt;strong&gt;false&lt;/strong&gt;, we say to the API not to load all related content when a specific content is requested.&lt;/p&gt;</description><pubDate>Fri, 27 Nov 2009 13:16:47 +0100</pubDate><link>http://docs3.bedita.net/frontends/customizing-frontend-applications-part-2-load-only-selected-content</link><guid>http://docs3.bedita.net/frontends/customizing-frontend-applications-part-2-load-only-selected-content</guid></item><item><title>Customizing Frontend Applications [part 1]: divide objects by type in a section</title><description>Organize your BEdita objects in $section array to have a semantic separation of contents.&lt;hr/&gt;&lt;p&gt;With this post we start a series of documents that explain how customize your frontend application for all your needs.&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;In any &lt;em&gt;Frontend Application&lt;/em&gt; the standard organization of contents in a section reflects the backend visualization. So, supposing to have a section named &quot;section 1&quot; structured like in &lt;em&gt;figure 1&lt;/em&gt;, we&#039;ll have in frontend view the array &lt;code&gt;$section&lt;/code&gt; with different content types mixed together:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;Array(
   [&#039;id&#039;] =&amp;gt; section 1
   [&#039;nickname&#039;] =&amp;gt; section-1
   ...
   [&#039;childContents&#039;] =&amp;gt; Array(
      [0] =&amp;gt; Array(...),
      [1] =&amp;gt; Array(...)
      ...
   )
);&lt;/pre&gt;
&lt;p&gt;This is ok in many situation i.e. when I want to list contents in sequential order, but when I want contents to assume a specific behavior based on their semantic meaning this structure is limited.&lt;br /&gt;&lt;br /&gt;In every object array I have a key named &lt;strong&gt;object_type&lt;/strong&gt; that identify the type of the item (Document, Event, Gallery, etc...) so we can iterate the $childContents array and check that key to choose the right behavior. But this is not a good practice in some situations: for example if I want that in a 3 columns layout documents are shown in the first column, events in the second and galleries in the third column. Infact I should iterate the &lt;em&gt;childContents&lt;/em&gt; array three times. Another example could be this one: we don&#039;t know which types of objects are in a section but we want everyone to behave differently.&lt;/p&gt;
&lt;p&gt;In these cases the &lt;code&gt;$sectionOptions&lt;/code&gt; attribute of the FrontendController class helps us.&lt;/p&gt;
&lt;h3&gt;The first solution: semantic separation for all sections&lt;/h3&gt;
&lt;p&gt;In this first case we want in our frontend application the objects inside every section divided by type. To do this we will override the &lt;code&gt;$sectionOptions&lt;/code&gt; attribute in Pages Controller like this:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;class PagesController extends FrontendController {
   protected $sectionOptions = array(
      &quot;showAllContents&quot; =&amp;gt; true, 
      &quot;itemsByType&quot; =&amp;gt; true, 
      &quot;childrenParams&quot; =&amp;gt; array()
   );
   ...
} &lt;/pre&gt;
&lt;p&gt;setting &lt;strong&gt;itemsByType&lt;/strong&gt; to true we force BEdita objects inside a section to be divided by object type. Instead of &lt;strong&gt;&lt;em&gt;&quot;chidContents&quot;&lt;/em&gt; &lt;/strong&gt;we&#039;ll have &lt;strong&gt;&lt;em&gt;&quot;children&quot;&lt;/em&gt; &lt;/strong&gt;array:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;Array(
   [&#039;id&#039;] =&amp;gt; &#039;section 1&#039;,
   [&#039;nickname&#039;] =&amp;gt; &#039;section-1&#039;,
   ...
   [&#039;children&#039;] =&amp;gt; Array(
      [&#039;Document&#039;] =&amp;gt; Array(
         [0] =&amp;gt; Array(...),
         [1] =&amp;gt; Array(...)
      )
      [&#039;Event&#039;] =&amp;gt; Array(...)
      ...
    )
);&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;The second solution: semantic division only for that section&lt;/h3&gt;
&lt;p&gt;In this case we&#039;ll use the &lt;strong&gt;nicknameBeforeFilter&lt;/strong&gt; callback called automatically before section data are loaded (note that &quot;-&quot; char in nickname is replaced with &quot;_&quot; in method name):&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;protected function section_1BeforeFilter() {
   $this-&amp;gt;sectionOptions[&quot;itemsByType&quot;] = true;
}
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The result will be an array like that above.&lt;/p&gt;</description><pubDate>Mon, 16 Nov 2009 12:08:24 +0100</pubDate><link>http://docs3.bedita.net/frontends/customizing-frontend-applications-part-1-divide-objects-by-type-in-a-section</link><guid>http://docs3.bedita.net/frontends/customizing-frontend-applications-part-1-divide-objects-by-type-in-a-section</guid></item><item><title>Frontend folder structure</title><description>A typical frontend application folder structure&lt;hr/&gt;&lt;p&gt;A typical frontend application folder structure&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;Each frontend application is a CakePHP application. The bigger difference is that a BEdita frontend application comes with a powerful set of API to allow webdesigners/webdevelopers start to work without write any single row of business logic and focusing on views.&lt;/p&gt;
&lt;p&gt;Of course you are free to customize your application editing PagesController or creating other controllers/components/models/plugins like a classic CakePHP application.&lt;/p&gt;
&lt;h1&gt;frontends folder&lt;/h1&gt;
&lt;p&gt;Inside this folder you can find four BEdita frontend applications and here is where you should create yours. BEdita package comes with these frontends:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;debug.example.com&lt;br /&gt;site.example.com&lt;br /&gt;dummy.example.com&lt;br /&gt;wp.example.com &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;In every frontend application you&#039;ll have a configuration file named &lt;strong&gt;frontend.ini.php&lt;/strong&gt; in &lt;strong&gt;config&lt;/strong&gt; folder, a controller named &lt;strong&gt;pages_controller.php&lt;/strong&gt; in controller folder and some templates in views folder.&lt;/p&gt;
&lt;h2&gt;debug.example.com&lt;/h2&gt;
&lt;p&gt;This is a tool to find out how data are structured, how you can use i18n, what helper/views/elements you have available for building a frontend application. Views and elements are available both as Smarty templates (.tpl) and CakePHP native templates (.ctp). In this way when you&#039;re starting a new project you may use your preferred template engine and having a starter kit of templates ready to use.&lt;/p&gt;
&lt;h2&gt;site.example.com&lt;/h2&gt;
&lt;p&gt;This is a simple example of a website.&lt;/p&gt;
&lt;h2&gt;dummy.example.com&lt;/h2&gt;
&lt;p&gt;Use it copying or renaming for create your own frontend application.&lt;/p&gt;
&lt;h2&gt;wp.example.com&lt;/h2&gt;
&lt;p&gt;This is a frontend application example inspired by the 2010 theme &lt;a href=&quot;http://wordpress.org/extend/themes/twentyten&quot; target=&quot;_blank&quot;&gt;TwentyTen&lt;/a&gt; for &lt;a href=&quot;http://www.wordpress.org&quot; target=&quot;_blank&quot;&gt;WordPress&lt;/a&gt;.The main stylesheet is the TwentyTen (twentyten.css) and an adjustament.css is used for some correction. Have a look at README.txt located in the frontend root folder for some tips.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description><pubDate>Tue, 13 Oct 2009 17:19:46 +0200</pubDate><link>http://docs3.bedita.net/frontends/frontend-folder-structure</link><guid>http://docs3.bedita.net/frontends/frontend-folder-structure</guid></item><item><title>Embedding multimedia objects</title><description>An overview on the multimedia embedding feature, using the BeEmbedMedia Helper.&lt;hr/&gt;&lt;p&gt;An overview on the multimedia embedding feature, using the BeEmbedMedia Helper.&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;The BeEmbedMedia helper is used to create and display every type of multimedia object as &lt;strong&gt;Video&lt;/strong&gt;, &lt;strong&gt;Audio&lt;/strong&gt;, &lt;strong&gt;Image&lt;/strong&gt;, &lt;strong&gt;Application&lt;/strong&gt; (like Flash object) or generic multimedia file (&lt;strong&gt;BEFile&lt;/strong&gt;). This helper is always included in backend AppController, as well as in every frontend application by inheritance, so inserting a video, a Flash swf file or an image is as easy as using a CakePHP helper. The helper uses &lt;a href=&quot;http://flowplayer.org&quot; target=&quot;_blank&quot;&gt;Flowplayer&lt;/a&gt; as internal flash player for native visualization of video and audio objects but also allow the embedding of provider players when there&#039;s no direct link to &lt;em&gt;flv&lt;/em&gt; file (i.e youtube see figure 1, 2). &lt;br /&gt;Let&#039;s see how:&lt;br /&gt;&lt;br /&gt;Essentially &lt;strong&gt;this helper provides a function called &quot;object&quot;&lt;/strong&gt; that works generically for any Bedita object:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;public function object ( $obj, $params = null, $htmlAttributes=array() )&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;The &lt;code&gt;$obj&lt;/code&gt; parameter represent the BEdita object that has to be displayed in the frontend. Generically in your view code, you&#039;ll have a multidimensional array:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;$section[&quot;currentContent&quot;][&quot;relations&quot;][&quot;attach&quot;]&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;which contains a list of all related media objects, i.e. all the media objects which share a &quot;&lt;strong&gt;relation&quot;&lt;/strong&gt; of type &quot;&lt;strong&gt;attach&quot;&lt;/strong&gt; with &lt;strong&gt;&quot;currentContent&quot;&lt;/strong&gt; inside the &lt;strong&gt;&quot;section&quot;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h2&gt;$params&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;$params&lt;/code&gt; represent an array of specific parameters related to the type of object to display. There&#039;s few parameters handled internally by BEdita. The main of those is &lt;strong&gt;&quot;presentation&quot;&lt;/strong&gt; params which define how the multimedia objects have to be shown. This parameter has a default value for any multimedia object so while for an image object will be create a thumbnail, for video object will be loaded the flash player.&lt;br /&gt;&lt;br /&gt;You can force presentation type passing the value in &lt;code&gt;$params&lt;/code&gt; associative array. It can be &lt;strong&gt;&quot;thumb&quot;&lt;/strong&gt; , &lt;strong&gt;&quot;full&quot;&lt;/strong&gt; or &lt;strong&gt;&quot;link&quot;&lt;/strong&gt;.&lt;br /&gt;For example, the code:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{assign_associative var=&quot;params&quot; presentation=&quot;thumb&quot; width=200 mode=&quot;crop&quot;}
{foreach from=$section.currentContent.relations.attach item=&quot;media&quot;}
   {$beEmbedMedia-&amp;gt;object($media,$params)}
{/foreach}&lt;/pre&gt;
&lt;p&gt;Will try to show the contents of array &quot;attach&quot; with thumbnails, regardless of the specific object. For example in case of a video object, will display the associated thumbnail if present, while in case of an image stored on BEdita, will try to generate thumbnail runtime or reusing a thumbnail previously created. &lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;&quot;presentation=full&quot;&lt;/strong&gt; type will display the full visualization of the object embedding directly the video or the audio or the images object.&lt;br /&gt;The code:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{assign_associative var=&quot;params&quot; presentation=&quot;full&quot;}
{foreach from=$section.currentContent.relations.attach item=&quot;media&quot;}
   {$beEmbedMedia-&amp;gt;object($media,$params)}
{/foreach}&lt;/pre&gt;
&lt;p&gt;Will try to display the video and audio object type with the internal default player, if &lt;strong&gt;&quot;useProviderPlayer&quot;&lt;/strong&gt; variable is present in &lt;code&gt;$params&lt;/code&gt; the function will try to embed the object using directly the related provider player. The image object type will be shown in their real dimension using the original file uploaded.&lt;br /&gt;&lt;br /&gt;Moreover, &lt;code&gt;$params&lt;/code&gt; can contain object-specific parameters such as &lt;strong&gt;flashvar&lt;/strong&gt; variables for customize Flowplayer or, more generically, any type of variable that is required to displaying multimedia objects. &lt;br /&gt;For examples:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{assign_associative var=&quot;clips&quot; autoPlay=true}
{assign_associative var=&quot;flashVars&quot; clip=$clips}
{assign_associative var=&quot;params&quot; flashvars=$flashVars}
{foreach from=$section.currentContent.relations.attach item=&quot;media&quot;}
    {$beEmbedMedia-&amp;gt;object($media,$params)}
{/foreach}&lt;/pre&gt;
&lt;p&gt;Enable the &lt;strong&gt;autoplay&lt;/strong&gt; function, when display a video with flowplayer.&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;&quot;presentation=link&quot;&lt;/strong&gt; parameter will produce a well formatted anchor pointing to the resource itself, with the title of the object inserted inside anchor tag.&lt;br /&gt;Finally the &lt;strong&gt;URLonly&lt;/strong&gt; parameter will force the helper to return only the URL, that can be useful when you want use manually the &lt;code&gt;&lt;img alt=&quot;&quot; /&gt;&lt;/code&gt; &quot;img&quot; tag.&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;{assign_associative var=&quot;params&quot; presentation=link URLonly=true}
{foreach from=$section.currentContent.relations.attach item=&quot;media&quot;}
   &amp;lt; img src=&quot;{$beEmbedMedia-&amp;gt;object($media,$params)}&quot; alt=&quot;&quot; /&amp;gt;
{/foreach}&lt;/pre&gt;
&lt;h2&gt;$htmlAttributes&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;$htmlAttributes&lt;/code&gt; represents the html parameters of the embedding object. Here you can specify all the html attributes like &lt;code&gt;rel&lt;/code&gt;, &lt;code&gt;width&lt;/code&gt;, &lt;code&gt;height&lt;/code&gt;, &lt;code&gt;id&lt;/code&gt;, etc...&lt;/p&gt;
&lt;p&gt;These was just an overview of the main features of the BeEmbedMedia helper, you can try by yourself all options and eventually ask help on the official &lt;a href=&quot;http://forum.bedita.com&quot; target=&quot;_blank&quot;&gt;forum&lt;/a&gt;. Some useful links are reported in the right column.&lt;/p&gt;</description><pubDate>Mon, 28 Sep 2009 17:49:14 +0200</pubDate><link>http://docs3.bedita.net/frontends/embedding-media-object</link><guid>http://docs3.bedita.net/frontends/embedding-media-object</guid></item><item><title>My first frontend</title><description>How to build a simple frontend in BEdita.&lt;hr/&gt;&lt;p&gt;How to build a simple frontend in BEdita.&lt;/p&gt;&lt;hr/&gt;&lt;p&gt;&lt;strong&gt;BEdita&lt;/strong&gt; package contains a folder named &lt;code&gt;frontends&lt;/code&gt;. This is where you will find some frontend samples, we&#039;ll start from here.&lt;/p&gt;
&lt;p&gt;In this article we are going to use a &lt;em&gt;debug&lt;/em&gt; frontend (f&lt;em&gt;rontends/debug.example.com&lt;/em&gt;) to better understand some basic conepts. As you may already know, there are two other frontends available: &lt;em&gt;wp.example.com&lt;/em&gt;, a simple web site based on &lt;a href=&quot;http://wordpress.org/extend/themes/twentyten&quot; target=&quot;_blank&quot;&gt;Twenty Ten Wordpress theme&lt;/a&gt;, &lt;em&gt;dummy.example.com&lt;/em&gt;, a dummy/empty publication and &lt;em&gt;html5.example.com&lt;/em&gt; a dummy HTML 5 frontend.&lt;/p&gt;
&lt;p&gt;Suppose that &lt;em&gt;frontends/debug.example.com&lt;/em&gt; is reachable at&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Write it in the browser address bar and you could see a page with the language in use, current section, publication and&lt;em&gt; &lt;/em&gt;configuration details, template data available&lt;em&gt; &lt;/em&gt;and sections tree.&lt;br /&gt;This root page is defined in &lt;em&gt;config/routes.php&lt;/em&gt; that lead to &lt;code&gt;FrontendController::route()&lt;/code&gt; method to load the first &lt;dfn class=&quot;glossario&quot;&gt;section&lt;/dfn&gt; of the &lt;dfn class=&quot;glossario&quot;&gt;publication&lt;/dfn&gt; related to frontend through &lt;code&gt;$config[&#039;frontendAreaId&#039;]&lt;/code&gt; variable you can find in &lt;em&gt;config/frontend.ini.php&lt;/em&gt; file.&lt;br /&gt;If it doesn&#039;t work check your &lt;code&gt;webroot/index.php&lt;/code&gt; and &lt;code&gt;config/bedita.sys.php&lt;/code&gt;, or use bedita shell script (cake.sh bedita checkApp) to check your settings.&lt;/p&gt;
&lt;p&gt;By default &lt;a href=&quot;http://www.smarty.net/&quot; target=&quot;_blank&quot;&gt;Smarty&lt;/a&gt; is BEdita&#039;s default template engine but you can use &lt;a title=&quot;CakePHP views&quot; href=&quot;http://book.cakephp.org/view/95/View-Templates&quot; target=&quot;_blank&quot;&gt;CakePHP&#039;s&lt;/a&gt; View class simply setting in &lt;code&gt;beditaBeforeFilter&lt;/code&gt; method of &lt;code&gt;controllers/pages_controller.php&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; gutter: false; tab-size: 4; toolbar: false; &quot;&gt;$this-&amp;gt;view = &#039;View&#039;;&lt;/pre&gt;
&lt;p&gt;and using .ctp file extension instead of .tpl. In &lt;em&gt;frontends/debug.example.com/view&lt;/em&gt; you will find the views/templates. You can play with this frontend and learn how frontends in BEdita work simply by using it.&lt;/p&gt;
&lt;h1&gt;&lt;em&gt;Nickname&lt;/em&gt; and &lt;em&gt;id&lt;/em&gt;&lt;/h1&gt;
&lt;p&gt;In the following paragraphs and examples we will make heavy use of &lt;dfn class=&quot;glossario&quot;&gt;nicknames&lt;/dfn&gt;. A &lt;em&gt;nickname&lt;/em&gt; is a unique alphanumeric &lt;em&gt;semantic&lt;/em&gt; name for every BEdita object of an instance: you will find it in the &lt;em&gt;Advanced Properties &lt;/em&gt;block of every object detail in backend (sections, documents, news, images,....). Let&#039;s use that &lt;em&gt;nickname&lt;/em&gt; or the object &lt;em&gt;id&lt;/em&gt; from now on.&lt;/p&gt;
&lt;p&gt;So, for a specific section you&#039;ve created digit&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/&lt;em&gt;section-nickname&lt;/em&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;using a real nickname instead of &lt;em&gt;section-nickname. &lt;/em&gt;Now you are on this section page, and you will see how content/section details are changed.&lt;/p&gt;
&lt;p&gt;The page you see refers to &lt;code&gt;views/pages/generic_section.tpl&lt;/code&gt; view, but if you create a template named views/pages/&lt;em&gt;section-nickname&lt;/em&gt;.tpl then this will be used.&lt;/p&gt;
&lt;p&gt;In this way every section is highly customizable and you can be able to create a different template for each section of your site.&lt;/p&gt;
&lt;p&gt;Here&#039;s a url list on how to reach the same section:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/&lt;em&gt;section-nickname&lt;/em&gt;&lt;br /&gt;http://www.example.com/section/&lt;em&gt;section-nickname&lt;/em&gt;&lt;br /&gt;http://www.example.com/&lt;em&gt;section-nickname&lt;/em&gt;/&lt;em&gt;sub-section-nickname&lt;/em&gt;&lt;br /&gt;&lt;/code&gt;&lt;code&gt;http://www.example.com/section/&lt;/code&gt;&lt;code&gt;&lt;em&gt;section-nickname&lt;/em&gt;/&lt;em&gt;sub-section-nickname&lt;/em&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And so on... the same using numeric id&#039;s instead of nicknames.&lt;/p&gt;
&lt;h1&gt;$section array&lt;/h1&gt;
&lt;p&gt;Let&#039;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 &quot;&lt;strong&gt;current section: $section&lt;/strong&gt;&quot;&lt;strong&gt; &lt;/strong&gt;paragraph and click on show/hide.&lt;/p&gt;
&lt;p&gt;You will see the array dump that contains section data like &quot;title&quot;, &quot;description&quot;, etc...&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;Array (
  [&#039;id&#039;] =&amp;gt; 2
  [&#039;syndicate&#039;] =&amp;gt; &#039;on&#039;
  [&#039;priority_order&#039;] =&amp;gt; &#039;asc&#039;
  [&#039;object_type_id&#039;] =&amp;gt; 3
  [&#039;status&#039;] =&amp;gt; &#039;on&#039;
  [&#039;created&#039;] =&amp;gt; &#039;2008-04-23 08:29:46&#039;
  [&#039;modified&#039;] =&amp;gt; &#039;2008-04-23 08:29:46&#039;
  [&#039;title&#039;] =&amp;gt; &#039;section title&#039;
  [&#039;nickname&#039;] =&amp;gt; &#039;section-nickname&#039;
  [&#039;description&#039;] =&amp;gt;
  [&#039;current&#039;] =&amp;gt; 1
  [&#039;lang&#039;] =&amp;gt; &#039;ita&#039;
  [&#039;ip_created&#039;] =&amp;gt; &#039;127.0.0.1&#039;
  [&#039;user_created&#039;] =&amp;gt; 1
  [&#039;user_modified&#039;] =&amp;gt; 1
  [&#039;rights&#039;] =&amp;gt;
  [&#039;license&#039;] =&amp;gt;
  [&#039;creator&#039;] =&amp;gt;
  [&#039;publisher&#039;] =&amp;gt;
  [&#039;note&#039;] =&amp;gt;
  [&#039;fixed&#039;] =&amp;gt; 0
  [&#039;comments&#039;] =&amp;gt; &#039;off&#039;
  ...
);&lt;/pre&gt;
&lt;p&gt;besides these you&#039;ll find&lt;/p&gt;
&lt;h2&gt;languages&lt;/h2&gt;
&lt;p&gt;array containing all the available translations.&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;[&#039;languages&#039;] =&amp;gt; Array (
  [&#039;eng&#039;] =&amp;gt; Array ( 
     [&#039;title&#039;] =&amp;gt; //section title 
  ),
  [&#039;deu&#039;] =&amp;gt; Array(...),
  ...
);&lt;/pre&gt;
&lt;h2&gt;pathSection&lt;/h2&gt;
&lt;p&gt;array that contains the sections parents. It&#039;s build using sections &lt;em&gt;id&lt;/em&gt; as array keys and ordered by depth: the first element will be the more distant ancient and the last element the parent.&lt;/p&gt;
&lt;h2&gt;canonicalPath&lt;/h2&gt;
&lt;p&gt;canonical section path in the form /main-section/sub-section/sub-subsection...&lt;/p&gt;
&lt;h2&gt;childSections&lt;/h2&gt;
&lt;p&gt;array containing sections children&lt;/p&gt;
&lt;h2&gt;childContents&lt;/h2&gt;
&lt;p&gt;array containing all objects, sections excluded&lt;/p&gt;
&lt;p&gt;These last arrays could be &lt;a href=&quot;/customizing-frontend-applications-part-1-divide-objects-by-type-in-a-section&quot;&gt;divided by object type&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;currentContent&lt;/h2&gt;
&lt;p&gt;array containing the current content of a section. With&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/section-nickname/content-nickname&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;currentContent contains the object with nickname as content-nickname. With&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/section-nickname&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;currentContent contains the first child of section with nickname as section-nickname&lt;/p&gt;
&lt;h2&gt;toolbar&lt;/h2&gt;
&lt;p&gt;array of pagination data:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;[&#039;toolbar&#039;] =&amp;gt; Array (
   [&#039;first&#039;] =&amp;gt; 0,
   [&#039;prev&#039;] =&amp;gt; 0,
   [&#039;next&#039;] =&amp;gt; 0,
   [&#039;last&#039;] =&amp;gt; 0,
   [&#039;size&#039;] =&amp;gt; 2,
   [&#039;pages&#039;] =&amp;gt; 1,
   [&#039;page&#039;] =&amp;gt; 1,
   [&#039;dim&#039;] =&amp;gt; 100000,
   [&#039;start&#039;] =&amp;gt; 1,
   [&#039;end&#039;] =&amp;gt; 2
);&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h1&gt;Get a specific object&lt;/h1&gt;
&lt;p&gt;So far we have seen how to get section data, but how can I get another object? Nothing could be easier:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/content-nickname&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;BEdita&lt;/strong&gt; will understand if the object is a section or a content and if it&#039;s a content will search the first section that contains it and load the &lt;code&gt;$section&lt;/code&gt; array like we saw above. Moreover in the &lt;code&gt;currentContent&lt;/code&gt; array will be placed the searched object and will be setted to &lt;strong&gt;true&lt;/strong&gt; the &lt;code&gt;$section[&quot;contentRequested&quot;]&lt;/code&gt; variable.&lt;br /&gt;If an object is present in more than one section then you just specify the section in the URL&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/section-nickname/content-nickname&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;What&#039;s inside an object?&lt;/h1&gt;
&lt;p&gt;The array structure of all objects is similar to &lt;code&gt;$section&lt;/code&gt; with regard to general data and object languages. It will have some specific data like &lt;strong&gt;GeoTag&lt;/strong&gt;, &lt;strong&gt;Category&lt;/strong&gt;, &lt;strong&gt;Tag&lt;/strong&gt;, etc... and&lt;/p&gt;
&lt;h2&gt;relations&lt;/h2&gt;
&lt;p&gt;this array contains semantic relations between objects, some of these are already defined, but you could build your specific relations. The array structure is:&lt;/p&gt;
&lt;pre class=&quot;brush: php; first-line: 1; tab-size: 4; toolbar: false; &quot;&gt;[&#039;relations&#039;] =&amp;gt; Array (
   [&#039;attach&#039;] =&amp;gt; array( [0] =&amp;gt; object1, [1] =&amp;gt; object2, ...)
   [&#039;seealso&#039;] =&amp;gt; array( [0] =&amp;gt; object1,[1] =&amp;gt; object2, ...)
   ...
   [&#039;place&#039;] =&amp;gt; array( [0] =&amp;gt; object1, [1] =&amp;gt; object2, ...)
   ...
) ;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h1&gt;What else?&lt;/h1&gt;
&lt;p&gt;To finish this first frontend overview we see how to do &lt;strong&gt;REST&lt;/strong&gt; calls to obtain the same $section array but in &lt;strong&gt;XML&lt;/strong&gt; or &lt;strong&gt;JSON&lt;/strong&gt; format.&lt;/p&gt;
&lt;h2&gt;XML&lt;/h2&gt;
&lt;p&gt;Write in address bar:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/xml/section-nickname&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;or if you prefer having data in XML tags format&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/&lt;/code&gt;&lt;code&gt;xml/&lt;/code&gt;&lt;code&gt;section-nickname&lt;/code&gt;&lt;code&gt;/format:tags&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;JSON&lt;/h2&gt;
&lt;p&gt;Likewise it&#039;s simple to obtain a JSON object, for example to use in an Ajax call.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://www.example.com/json/nickname-section&lt;/code&gt;&lt;/p&gt;</description><pubDate>Mon, 30 Mar 2009 18:46:41 +0200</pubDate><link>http://docs3.bedita.net/frontends/my-first-frontend</link><guid>http://docs3.bedita.net/frontends/my-first-frontend</guid></item></channel></rss>