Download the PHP package livy/climber without Composer

On this page you can find all versions of the php package livy/climber. 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 climber

🧗 Climber

Why walk when you can climb?

An alternative to WordPress's built-in Nav_Walker, 🧗 Climber creates a more reasonable data structure, which can be interacted with directly or used to generate the HTML for a navigation menu.

Build Status

☠️ Currently in Development ☠️

⚡ Probably not ready for production ⚡

Usage

The simplest implementation of 🧗 Climber looks like this:

...Maybe not quite so simple. There will be convenience functions eventually!

This document doesn't detail all the methods and ways of interaction with 🧗 Climber—only the ones you're most likely to use. The methods themselves are heavily documented inline, so feel free to dive into the code if you're curious how something works.

How Does It Work?

🧗 Climber has three basic components that it needs to work:

Spotter allows for 🧗 Climber to be platform agnostic: While it ships with a WordPress Spotter, you can add whatever Spotters you like to collect and process data. The Spotter's job is to return data in the format that Tree expects.

Tree processes the data recieved from Spotter and implements several methods that can be used to quickly and easily interact with the data it contains. Its organization allows Climber to quickly find the things it needs to generate a navigation menu.

Climber collects a Tree and returns a properly-constructed navigation menu in HTML.

Generally, you'll only be interacting directly with Climber, but you can easily extend or modify the other components to suit your needs—or use them to modify your data.

Show Me

The Usage section at the top illustrates the simplest version, which will return a simple menu. In most situations, though, you'll want to tell the menu what page you're on (so it can highlight that section). Or you might want to hook into some part of the process to add or modify elements, CSS classes, or HTML attributes.

The Climber object will return an HTML menu if treated as a string. Handy!

Hooks

In order to allow you to modify the content and behavior of the menu without having to extend the classes, Climber exposes several hooks. Each hook provides a single variable—$data—to whatever function is hooked to them. The content of that variable depends on the hook you attach it to. Generally, it is an array with keyed values.

Any function that is passed to a hook must return something similar to the $data it recieved. Otherwise things will break. See the Show Me section of this document, or the contents of Climber::__construct() for examples of how to properly construct hooks.

top

This is the 'top' level of the navigation menu: The <nav> element. The array it provides includes:

menu

This hook is run for each submenu. If you want to target a particular submenu, you'll need to run some sort of test in your passed function to target it. The array it provides includes:

item

An individual <li> inside a <ul>. Will ultimately contain a link to a part of your site, and possibly a submenu. The array it provides includes:

itemOutput

This describes the actual content of item. It can be used to add new things to an item (i.e. a <button> to open a submenu) or to modify the order of the things appearing in the item. The array it provides includes:

link

This is a link element in an item. The array it provides includes:

Settings

These settings will be applies to all elements of their type, so they can be useful for setting styling or behavior across your menu. The built-in classes are formatted strings. You can change them all with one line by modifying baseClass. You can also override them completely, if you wish.

Name Type Default
baseClass string 'simpleMenu'
topClass string '%s'
menuClass string '%s__menu'
itemClass string '%s__item'
linkClass string '%s__link'
topAttr array []
menuAttr array []
itemAttr array []
linkAttr array []

You can override or set Climber-wide properties for element classes and attributes. Doing so is very simple:

Keep in mind:

This means that if you want to supplement the existing classes, you would do the following:

You can override and remove array-type property entries as well:

That's Too Complicated

I agree! Fortunately there are some nice, clean, convenience functions to help do what you want without filling your code up with all those Classes and stuff.

(This list will expand as necessary. If you think there should be a function here that isn't here, open an issue or submit a PR to add it!)

All conveninece functions begin with pulley__. They follow a convention (borrowed from WordPress): Functions named get_something will return a value, while functions simply named something will echo that value. For this reason, these functions often come in pairs. If they don't, it's probably because the get_ version returns something that can't be echoed.

General

These functions will work in any context, but they require you to pass a valid Spotter.

pulley__get_menu()

Arguments
Returns

Climber | false A Climber object if successful, boolean false otherwise.

_

pulley__menu()

The same as pulley__get_menu(), except that this will echo the menu automatically.

Arguments
Returns

string | false HTML string of the menu if successful, boolean false otherwise.

WordPress

These functions will only work with WordPress (in fact, Climber will only load them if it believes it is being used in a WordPress context). Because Climber comes packaged with a WordPress Spotter, there's no need to manually pass in a Spotter!

pulley__wp_get_menu()

Returns a Climber for the $menu passed to it.

Arguments
Returns

Climber | false A Climber object if successful, boolean false otherwise.

pulley__wp_menu()

Echoing version of pully__wp_get_menu().

Arguments
Returns

string | false HTML string of the menu if successful, boolean false otherwise.

pulley__wp_get_menu_by_location()

Get a menu based on its location.

Arguments
Returns

Climber | false A Climber object if successful, boolean false otherwise.

pulley__wp_menu_by_location()

Same as pulley__wp_get_menu_by_location(), just echoes.

Arguments
Returns

string | false HTML string of the menu if successful, boolean false otherwise.

That's Not Complicated Enough

All right, fair. Maybe you need something we haven't covered here: Maybe the menu you're passing to Climber only includes the top level of your site, but you want parent items to still be highlighted when their children are being visited. Since Climber is (by design) ignorant of your site's internal organization, it doesn't directly support this: Climber is only aware of the things its aware of.

You can, however, use a bit of logic to tell Climber what it should consider "active".

Set Current URL

The most common usage of Climber involves passing a URL to it on instantiation—either with the class directly, or through one of the helper functions. In either case, internally Climber is using the same method to activate the current URL, and it's a method you can use too!

Climber::setCurrentUrl() can be used to pass a URL directly to Climber. Climber will then look for a leaf (or leaves) that point to that URL, and mark them as "active" (if you have a multi-level menu, it will also mark their ancestors as well). Using it is very simple:

If the Climber you're working with doesn't have that URL, it will do nothing.

It is also worth noting that Climber does not assume there can be only one active leaf: Running setCurrentUrl() does not remove previously active leaves.

Access to setCurrentUrl() means that with some elbow grease, you can make Climber think you're on any page you like! Unfortunately, if you need to do this with a large number of URLs, setCurrentUrl() starts get a little less useful.

That's why there's another way!

Surveyor

The Surveyor class provides you with a simple way of writing lookups for URL patterns that you want to match particular URLs in Climber. It uses an array of regular expressions to determine what URLs match what.

To use Surveyor, instantiate it with an array of regular expressions and URLs, and then call Surveyor::evaluateUrl():

Possible URLs are evaluated in sequence, and returned as soon as a match is found. If no match is found, then the URL originally passe dto evaluateUrl() is returned. This means that you can easily use Surveyor inside a Climber call, and it will fall back to whatever Climber wants to do with that URL if no matches are found. Like so:


All versions of climber with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
zenodorus/arrays Version ^1.1
zenodorus/strings Version ^1.0
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 livy/climber contains the following files

Loading the files please wait ....