Compare commits
14 Commits
e0f66c0354
...
3b1f83d4c7
Author | SHA1 | Date |
---|---|---|
buttle | 3b1f83d4c7 | |
buttle | 3f9aaa69a5 | |
chris | 90eb660a15 | |
buttle | d89708381d | |
buttle | 591bca7f2b | |
buttle | 5b2d677d17 | |
buttle | 9d3976c1cb | |
buttle | f9d2d65931 | |
buttle | 27ed8e6db5 | |
buttle | f79b7af69c | |
buttle | 3657873be7 | |
buttle | c48a6d5709 | |
buttle | 3f42b2f218 | |
jorge | 41eb169bfb |
|
@ -33,6 +33,15 @@ chown -R www-data:www-data ./
|
|||
|
||||
## Arc-hive theme notes
|
||||
|
||||
### Configure
|
||||
|
||||
The main menu can be retrieved from a wordpress site and rendered. To configure this, edit `view/common/wordpress-menu.phtml`. Optional.
|
||||
|
||||
```
|
||||
# Config
|
||||
$wordpress_site="https://my.wordpress.site";
|
||||
$wordpress_endpoint="https://my.wordpress.site/wp-json/menus/v1/menus/4";
|
||||
```
|
||||
|
||||
For more advanced use, such as customizing the theme with Sass, you'll need to install the tools with [NodeJS](https://nodejs.org/en/) (0.12 or greater). Navigate to your theme directory and run `npm install`.
|
||||
|
||||
|
|
|
@ -18,12 +18,13 @@
|
|||
</main>
|
||||
<nav>
|
||||
<menu class="">
|
||||
<?php /*
|
||||
|
||||
<?php
|
||||
echo $site->publicNav()
|
||||
->menu()
|
||||
->setPartial('common/foundation-navigation.phtml')
|
||||
->setPartial('common/wordpress-menu.phtml')
|
||||
->renderPartialWithParams(['layout' => 'dropdown']);
|
||||
*/
|
||||
|
||||
?>
|
||||
</menu>
|
||||
</nav>
|
||||
|
|
|
@ -42,12 +42,10 @@ $img_src = null;
|
|||
<nav>
|
||||
<menu class="">
|
||||
<?php //
|
||||
// Segun el diseño, este menu no existe
|
||||
// ----------
|
||||
// echo $site->publicNav()
|
||||
// ->menu()
|
||||
// ->setPartial('common/foundation-navigation.phtml')
|
||||
// ->renderPartialWithParams(['layout' => 'dropdown']);
|
||||
echo $site->publicNav()
|
||||
->menu()
|
||||
->setPartial('common/wordpress-menu.phtml')
|
||||
->renderPartialWithParams(['layout' => 'dropdown']);
|
||||
?>
|
||||
</menu>
|
||||
</nav>
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
# Config
|
||||
$wordpress_site="https://dev.arc-hive.zone";
|
||||
$wordpress_endpoint="https://dev.arc-hive.zone/wp-json/menus/v1/menus/4";
|
||||
|
||||
use Zend\Http\Client;
|
||||
|
||||
$items = new ArrayObject;
|
||||
$items[0] = new ArrayObject(); // top level menu items go here
|
||||
|
||||
if ($wordpress_endpoint) {
|
||||
try {
|
||||
$client = new Client($wordpress_endpoint);
|
||||
$client->setOptions(array("timeout"=>1));
|
||||
$response = $client->send();
|
||||
}
|
||||
catch (exception $e) {
|
||||
$response = null;
|
||||
}
|
||||
if ($response) {
|
||||
$response_data = json_decode($response->getBody());
|
||||
if (!$response->isClientError() && $response_data) {
|
||||
foreach ($response_data as $menu_item) {
|
||||
$lowered_title = strtolower($menu_item->title);
|
||||
$item_url = $menu_item->url;
|
||||
if ($lowered_title == 'login') {
|
||||
// manipulate login url
|
||||
$item_url = "/login";
|
||||
}
|
||||
$item_title = $menu_item->title;
|
||||
if ($lowered_title == 'collections') {
|
||||
if ($wordpress_site) {
|
||||
// change Collections item
|
||||
$item_title = "Project";
|
||||
$item_url = $wordpress_site;
|
||||
} else {
|
||||
continue; // do not render the Collections item
|
||||
}
|
||||
}
|
||||
$item = [
|
||||
"id" => $menu_item->ID,
|
||||
"title" => $item_title,
|
||||
"url" => $item_url
|
||||
];
|
||||
if (!isset($items[$menu_item->menu_item_parent])) {
|
||||
//if (!array_key_exists($menu_item->menu_item_parent, $items)) {
|
||||
$items[$menu_item->menu_item_parent] = new ArrayObject();
|
||||
}
|
||||
$items[$menu_item->menu_item_parent][$menu_item->ID] =$item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($items[0]) == 0) {
|
||||
// we did not retrieve a menu from the wordpress site
|
||||
// let's create a default menu
|
||||
if ($wordpress_site) {
|
||||
$project_item = [
|
||||
"id" => 1,
|
||||
"title" => "Project",
|
||||
"url" => $wordpress_site
|
||||
];
|
||||
$items[0][1] = $project_item;
|
||||
}
|
||||
$login_item = [
|
||||
"id" => 2,
|
||||
"title" => "Login",
|
||||
"url" => "/login"
|
||||
];
|
||||
$items[0][2] = $login_item;
|
||||
}
|
||||
//print_r($items);
|
||||
|
||||
if (!function_exists('render_menu')) {
|
||||
function render_menu($items, $level_id) {
|
||||
if ($level_id == 0) {
|
||||
echo '<ul id="" class="dropdown menu" data-dropdown-menu="dropdown-menu" role="menubar">'.
|
||||
PHP_EOL;
|
||||
} else {
|
||||
echo '<ul class="dropdown menu vertical submenu is-dropdown-submenu first-sub" data-toggle="" data-submenu="" role="">'.
|
||||
PHP_EOL;
|
||||
}
|
||||
foreach ($items[$level_id] as $menu_item) {
|
||||
if ($level_id == 0) {
|
||||
echo '<li id="" class="" role="">'.PHP_EOL;
|
||||
} else {
|
||||
echo '<li id="" class="is-submenu-item is-dropdown-submenu-item" role="">'.PHP_EOL;
|
||||
}
|
||||
echo '<a role="" href="'.$menu_item['url'].'">'.$menu_item['title'].'</a>'.PHP_EOL;
|
||||
if (isset($items[$menu_item['id']])) {
|
||||
//if (array_key_exists($menu_item['id'], $items)) {
|
||||
render_menu($items, $menu_item['id']); // render sub menu
|
||||
}
|
||||
echo '</li>' . PHP_EOL;
|
||||
}
|
||||
echo '</ul>' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
render_menu($items, 0);
|
||||
|
||||
?>
|
Loading…
Reference in New Issue