Download the PHP package atk14/menu14 without Composer

On this page you can find all versions of the php package atk14/menu14. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package menu14

Menu14

Menu14 is a menu generator designated for ATK14 applications.

Menu14 has simple configuration that keeps in mind the ATK14 concept of controllers and actions.

Menu14 can build branched navigation structures. There is no limit of submenu levels count.

Menu14 can also be used for breadcrumbs.

Menu14 implements ArrayAccess, Iterator and Countable for easy usage.

Basic usage

In a controller:

$menu = new Menu14();

$submenu = $menu->add("Archive");
$submenu->add("Whole archive",["articles/index"]);
$top_articles = $submenu->add("Top articles","top_articles");
  $top_articles->add("Last Month","top_articles/last_month");
  $top_articles->add("Last Year","top_articles/last_year");

// another submenu
$submenu = $menu->add("Information");
$submenu->add("About us","main/about");
$submenu->add("Contact","main/contact");

// disabled items should be displayed non clickable
$user_menu = $menu->add("User");
$user_menu->add("Login","logins/create_new",["disabled" => $is_user_logged]);
$user_menu->add("Logout","logins/destroy",["disabled" => !$is_user_logged]);
$user_menu->add("Profile","users/detail",["disabled" => !$is_user_logged]);

$this->tpl_data["menu"] = $menu;

In a template:

{* file: shared/_menu.tpl *}
{if !$menu->isEmpty()}
<ul>
  {foreach $menu->getItems() as $item}
    <li{if $item->isActive()} class="active"{/if}{if $item->isDisabled()} class="disabled"{/if}>

      {if $item->getUrl() && !$item->isDisabled()}
        <a href="{$item->getUrl()}">{$item->getTitle()}</a>
      {else}
        {$item->getTitle()}  
      {/if}

      {* recursion *}
      {render partial="shared/menu" menu=$item->getSubmenu()}

    </li>
  {/foreach}
</ul>
{/if}

There are two methods for creating node in a menu.

$menu->add("Label",$targets_or_url,$options); // creates new menu item and return its submenu (which is at the moment empty)
$menu->addItem("Label",$targets_or_url,$options); // creates new menu item - this new menu item is returned

Breadcrumbs

In a controller:

$breadcrumbs = new Menu14();

$breadcrumbs[] = ["Home","main/index"];
$breadcrumbs[] = ["Articles","articles/index"];
if($tag = $article->getPrimaryTag()){
  $breadcrumbs[] = ["$tag",$this->_link_to(["action" => "articles/index", "tag_id" => $tag])];
}
$breadcrumbs[] = $article->getTitle();

$this->tpl_data["breadcrumbs"] = $breadcrumbs;

In a template:

<ol class="breadcrumb">
  {foreach $breadcrumbs as $breadcrumb}
    <li>
      {if $breadcrumb->getUrl()}
        <a href="{$breadcrumb->getUrl()}">{$breadcrumb->getTitle()}</a>
      {else}
        {$breadcrumb->getTitle()}
      {/if}
    </li>
  {/foreach}
</ol>

Check out http://skelet.atk14.net/en/articles/ to see this example live.

Metadata

Metadata can be set on menus or menu items. It may be useful for storing things like colors, images, fade effects...

$menu = new Menu14();

$websites = $menu->add("Frameworks");
$websites->setMeta("image_url","/public/icons/sprockets.png");

$item_atk14 = $website->addItem("Atk14","https://www.atk14.net/",[
  "meta" => [
    "image_url" => "/public/icons/atk14_birdie.png",
    "color" => "black"
  ]
]);

$item_laravel = $website->addItem("Laravel","https://laravel.com/");
$item_laravel->setMeta("image_url","/public/icons/laravel.png");
$item_laravel->setMeta("color","red");

// getting metadata

$websites->getMeta("image_url"); // "/public/icons/sprockets.png"
$websites->getMeta("color"); // null
$item_atk14->getMeta("image_url"); // "/public/icons/atk14_birdie.png"
$item_atk14->getMeta("color"); // "black"
$item_laravel->getMeta("image_url"); // "/public/icons/laravel.png"
$item_laravel->getMeta("color"); // "red"

Installation

Use the Composer to install Menu14

cd path/to/your/project/
composer require atk14/menu14

Licence

Menu14 is free software distributed under the terms of the MIT license


All versions of menu14 with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package atk14/menu14 contains the following files

Loading the files please wait ....