This repository has been archived by the owner. 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.
PHP
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
src
tests
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
composer.json
composer.lock
phpunit.xml.dist

README.md

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);