Open Source Content Management System

MidCOM component navigation class

In navigation.php the component defines what Navigation Access Point should display in navigation. MidCOM Baseclasses.

Since component gets to decide what information to display, it is possible to both

  1. limit the displayed content
    • eg. show only the future events
  2. display links to virtual pages
    • eg. search events

In navigation.php there must be a call for constructor method, eg. net_nehmer_blog_navigation.

A simple example for how to display leaf elements

function get_leaves()
{
    // Initialize variables
    $leaves = array();

    $qb = midcom_db_article::new_query_builder();
    $qb->add_constraint('topic', '=', $this->_topic->id);

    if ($qb->count() === 0)
    {
        // Return an empty array, no leaves to display
        return $leaves;
    }

    // Initialize the information to ´display the toolbar elements
    // for the viewed article
    $toolbar[50] = Array(
        MIDCOM_TOOLBAR_URL      => '',
        MIDCOM_TOOLBAR_LABEL    => $this->_l10n_midcom->get('edit'),
        MIDCOM_TOOLBAR_HELPTEXT => null,
        MIDCOM_TOOLBAR_ICON     => 'stock-icons/16x16/edit.png',
        MIDCOM_TOOLBAR_ENABLED  => true
    );
    $toolbar[51] = Array(
        MIDCOM_TOOLBAR_URL      => '',
        MIDCOM_TOOLBAR_LABEL    => $this->_l10n_midcom->get('delete'),
        MIDCOM_TOOLBAR_HELPTEXT => null,
        MIDCOM_TOOLBAR_ICON     => 'stock-icons/16x16/trash.png',
        MIDCOM_TOOLBAR_ENABLED  => true
    );

    $articles = $qb->execute();

    // Loop through the articles fetched with query builder
    foreach ($articles as $article)
    {
        // Match the toolbar to the correct URL.
        $toolbar[!!50][MIDCOM_TOOLBAR_URL] = "edit/{$article->id}.html";
        $toolbar[!!50][MIDCOM_TOOLBAR_HIDDEN] = ($_MIDCOM->auth->can_do('midgard:update', $article) == false);
        $toolbar[!!51][MIDCOM_TOOLBAR_URL] = "delete/{$article->id}.html";
        $toolbar[!!51][MIDCOM_TOOLBAR_HIDDEN] = ($_MIDCOM->auth->can_do('midgard:delete', $article) == false);

        $leaves$article->id = array (
            MIDCOM_NAV_SITE => array (
                MIDCOM_NAV_URL  => $article->name.'.html',
                MIDCOM_NAV_NAME => $article->title,
            ),
            MIDCOM_NAV_SITE => array (
                MIDCOM_NAV_URL  => "view/{$article->id}",
                MIDCOM_NAV_NAME => $article->title,
            ),
            MIDCOM_NAV_GUID     => $article->guid,
            MIDCOM_NAV_TOOLBAR  => $toolbar,
            MIDCOM_META_CREATOR => $article->creator,
            MIDCOM_META_EDITOR  => $article->revisor,
            MIDCOM_META_CREATED => $article->created,
            MIDCOM_META_EDITED  => $article->revised
        );
    }

    return $leaves;
}
Designed by Nemein, hosted by Anykey