Vokuro is a good example to start for sure. Invo as well as php-site also can serve as good programming examples for you to learn and move towards your goals.
As for the breadcrumbs the way I would do it is as follows:
Imagine your application structure as follows:
app/
app/controllers
app/models
app/views
library
library/MyNamespace
public
Also in your index.php (the starting point of the application) you have this definition:
if (!defined('ROOT_PATH')) {
define('ROOT_PATH', dirname(dirname(__FILE__)));
}
If your full path of your files is
/var/www/myapplication/
then the above line will give that path to you. You can use it throughout your app to reference files and folders
Create a breadcrumb class. This can reside in a library folder and you can set your autoloader to pick it up from there. Example:
// Creates the autoloader
$loader = new \Phalcon\Loader();
$library = ROOT_PATH . '/library';
$loader->registerDirs([$library]);
// Register the Library namespace
$loader->registerNamespaces(
[
'MyNamespace' => $library,
'MyNamespace\Controllers' => ROOT_PATH . '/app/controllers'
]
);
$loader->register();
Now your application knows to look in the $library path and any namespaced class that you try to load with "MyNamespace" will also look in that library folder.
The breadcrumbs class is very simple to create:
<?php
/**
* Breadcrumbs.php
* MyNamespace\Breadcrumbs
*
* Handles the breadcrumbs for the application
*/
namespace MyNamespace;
class Breadcrumbs
{
/**
* Keeps all the breadcrumbs
*
* @var array
*/
private $elements = [];
/**
* Constructor
*/
public function __construct()
{
$this->reset();
}
public function reset()
{
$this->elements[] = [
'link' => '/',
'text' => 'Home',
];
}
/**
* Adds a new element in the stack
*
* @param string $caption
* @param string $link
*/
public function add($caption, $link)
{
$element = [
'link' => '/' . $link,
'text' => $caption,
];
array_unshift($this->elements, $element);
}
/**
* Returns all the elements back to the caller
*
* @return string
*/
public function generate()
{
return $this->elements;
}
}
All my controllers extend a base controller which in turn extends the Phalcon controller. In there I generate the initial breadcrumb which in our case will be "Home" (set in the breadcrumbs class)
<?php
/**
* Controller.php
* MyNamespace\Controller
*
* The base controller and its actions
*/
namespace MyNamespace;
use \MyNamespace\Breadcrumbs as MyBreadcrumbs;
class Controller extends \Phalcon\Mvc\Controller
{
/**
* Holds the Breadcrumbs object
*
* @var \MyNamespace\Breadcrumbs
*/
protected $bc = null;
protected $viewVars = [];
/**
* Initializes the controller
*/
public function initialize()
{
$this->bc = new MyBreadcrumbs();
}
/**
* This sets all the view variables before rendering
*/
public function afterExecuteRoute()
{
/**
* This effectively will set the breadcrumbs array in the view
* and will allow us to render it
*/
$this->addViewVar('bc', $this->bc->generate());
$this->view->setVars($this->viewVars);
}
protected function addViewVar($variable, $value)
{
$this->viewVars[$variable] = $value;
}
protected function resetViewVars()
{
$this->viewVars = [];
}
}
One of your controllers will look like this:
<?php
/**
* AboutController.php
* AboutController
*
* The about controller and its actions
*/
namespace MyNamespace\Controllers;
use \MyNamespace\Controller as MyController;
class AboutController extends MyController
{
/**
* Initializes the controller
*/
public function initialize()
{
parent::initialize();
/**
* Breadcrumbs for this section
*/
$this->bc->add('About', 'about');
}
/**
* The index action
*/
public function indexAction()
{
/**
* Breadcrumbs
*/
$this->bc->add("Index", 'index');
}
/**
* The index action
*/
public function contactAction()
{
/**
* Breadcrumbs
*/
$this->bc->add("Contact", 'contact');
}
}
Then all you have to do in your view layout is to print those bookmarks:
<div class="breadcrumbs">
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">Navigation <span class="caret"></span></button>
{% if bc is defined %}
<ul class="dropdown-menu">
{% for breadcrumb in bc %}
<li><a href="{{ breadcrumb['link'] }}">{{ breadcrumb['text'] }}</a></li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
The code above assumes you are using bootstrap for your CSS styling but it can be easily changed to whatever you like.
This should be a good starting point for you.
Issues to consider: Do you want to automatically print "Home" as the first breadcrumb? If no then you need to modify the breadcrumbs class. Also, how about checking if the element is the last one on the list so that it does not show a hyperlink...