Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

A small PHP library for scraping and cloning navigation menus off a website. Supports menu style conversions to Twitter Bootstrap.

License

Notifications You must be signed in to change notification settings

chrisvogt/php-menu-grab-and-convert

Repository files navigation

PHP Menu Grab and Convert

GitHub release Build Status Code Climate License: MIT SensioLabsInsight

PHP Menu Grab and Convert (Mgac) is a small library that makes it easy to clone, convert, and render another site's navigation menu. Uses sunra/php-simple-html-dom-parser/, an adaptation of the PHP Simple HTML DOM Parser.

This project was born as a quick, simple solution to replicate a navigation menu on a top-level domain to a set of static pages underneath, each of which may be in a different style or front-end framework yet need to contain the same menu items and hyperlinks.

Please be free to utilize the suggestion box or read the documentation.

Install

composer.phar

{
    "repositories": [
        {
            "url": "https://github.com/chrisvogt/php-menu-grab-and-convert.git",
            "type": "git"
        }
    ],
    "require": {
        "chrisvogt/php-menu-grab-and-convert": "*"
    }
}

Usage

use \MenuGrabAndConvert;

require_once __DIR__ . '/vendor/autoload.php';

$target  = array( // Required
    'url'       => 'http://sandbox-php.dev/demo/',
    'element'   => 'ul[id=topnav]'
);
$options = array( // Optional, for Bootstrap conversion
    'validateBaseUrl'       => true,
    'convertToBootstrap'    => true,
    'selectors'             => array(
        'top-nav'            => 'ul[id=topnav]',
        'li-with-child'      => 'li.menu-item-has-children',
        'submenu-ul'         => 'ul.sub-menu'
    )
);

$config = new \MenuGrabAndConvert\Configuration($target, $options);
$mgac = new \MenuGrabAndConvert\Mgac($config);

About

A small PHP library for scraping and cloning navigation menus off a website. Supports menu style conversions to Twitter Bootstrap.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages