Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
valencia
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
9
Issues
9
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
valencia
Commits
af036d8c
Commit
af036d8c
authored
Jun 07, 2014
by
Riccardo Padovani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added breadcrumb and third level menu
parent
56832962
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
6 deletions
+125
-6
template.php
template.php
+112
-0
tpl/page.tpl.php
tpl/page.tpl.php
+13
-6
No files found.
template.php
View file @
af036d8c
...
@@ -169,6 +169,8 @@ function valencia_links__system_main_menu($vars) {
...
@@ -169,6 +169,8 @@ function valencia_links__system_main_menu($vars) {
return
valencia_header_menu
(
$vars
);
return
valencia_header_menu
(
$vars
);
case
'subheader'
:
case
'subheader'
:
return
valencia_subheader_menu
(
$vars
);
return
valencia_subheader_menu
(
$vars
);
case
'breadcrumb'
:
return
valencia_breadcrumb
(
$vars
);
case
'footer'
:
case
'footer'
:
return
valencia_footer_menu
(
$vars
);
return
valencia_footer_menu
(
$vars
);
}
}
...
@@ -226,6 +228,116 @@ function valencia_subheader_menu($vars) {
...
@@ -226,6 +228,116 @@ function valencia_subheader_menu($vars) {
return
$html
;
return
$html
;
}
}
/**
* Custom breadcrumb and third level menu
* Follows partially http://design.ubuntu.com/web-style-guide/scaffolding#navigation
*
* Breadcrumb is printed only on page with deep level > 1
* Also, if there is, we print third level menu
*/
function
valencia_breadcrumb
(
$vars
)
{
// Var with all HTML
$html
=
''
;
foreach
(
$vars
[
'links'
]
as
$key
=>
$link
)
{
// See Drupal API, is to print every menu voice only one
if
(
is_numeric
(
$key
))
{
// We need only active links
if
(
$link
[
'#original_link'
][
'in_active_trail'
])
{
// If is the first level link and it has children, we have our first
// link of breadcrumb!
if
(
!
empty
(
$link
[
'#below'
])
&&
$link
[
'#original_link'
][
'depth'
]
===
'1'
)
{
$link_title
=
$link
[
'#title'
];
$link_href
=
$link
[
'#href'
];
$html
.=
'<ul class="breadcrumb">'
;
$html
.=
'<li>'
.
l
(
$link_title
,
$link_href
,
array
(
'html'
=>
'true'
))
.
' ›</li>'
;
// Now we need to attach second level menu
$sub_menu
=
theme
(
'links__system_main_menu'
,
array
(
'links'
=>
$link
[
'#below'
],
'id'
=>
'breadcrumb'
));
$html
.=
$sub_menu
;
}
// Second level link: could be the active one, or only a
// breadcrumb for third level (or both)
else
if
(
$link
[
'#original_link'
][
'depth'
]
===
'2'
)
{
// If it hasn't child, is the active link
if
(
empty
(
$link
[
'#below'
]))
{
$link_title
=
$link
[
'#title'
];
$link_href
=
$link
[
'#href'
];
$html
.=
'<li class="active">'
.
l
(
$link_title
,
$link_href
,
array
(
'html'
=>
'true'
))
.
'</li>'
;
// We close the ul with class breadcrumb, as per design
$html
.=
'</ul>'
;
}
else
{
// If it has children could be active or not.
// To check we need to create first the third level
// menu, and check if any of the third level menu links
// is active
list
(
$has_child_active_link
,
$third_level_menu
)
=
valencia_third_level_menu
(
$link
[
'#below'
]);
$link_title
=
$link
[
'#title'
];
$link_href
=
$link
[
'#href'
];
// If a child is active, this one isn't active
if
(
$has_child_active_link
)
{
$html
.=
'<li>'
.
l
(
$link_title
,
$link_href
,
array
(
'html'
=>
'true'
))
.
' ›</li>'
;
}
else
{
$html
.=
'<li class="active">'
.
l
(
$link_title
,
$link_href
,
array
(
'html'
=>
'true'
))
.
'</li>'
;
}
// We close the ul with class breadcrumb, as per design
$html
.=
'</ul>'
;
// Then, third level menu
$html
.=
$third_level_menu
;
}
}
}
}
}
return
$html
;
}
/**
* Create third level menu html
* Follows http://design.ubuntu.com/web-style-guide/scaffolding#navigation
*
* Don't call this function directly, is only for valencia_breadcrumb()
*
* Return an array: the first element is a bool that indicate if there is an
* active link, the second element is the html of third level menu
*/
function
valencia_third_level_menu
(
$vars
)
{
// Var with all HTML
$html
=
'<ul class="third-level">'
;
// This becomes TRUE if there is an active link
$has_active_link
=
FALSE
;
foreach
(
$vars
as
$key
=>
$link
)
{
// See Drupal API, is to print every menu voice only one
if
(
is_numeric
(
$key
))
{
if
(
$link
[
'#original_link'
][
'in_active_trail'
])
{
$has_active_link
=
TRUE
;
$link_title
=
$link
[
'#title'
];
$link_href
=
$link
[
'#href'
];
$html
.=
'<li class="active">'
.
l
(
$link_title
,
$link_href
,
array
(
'html'
=>
'true'
))
.
'</li>'
;
}
else
{
$link_title
=
$link
[
'#title'
];
$link_href
=
$link
[
'#href'
];
$html
.=
'<li>'
.
l
(
$link_title
,
$link_href
,
array
(
'html'
=>
'true'
))
.
'</li>'
;
}
}
}
$html
.=
'</ul>'
;
return
array
(
$has_active_link
,
$html
);
}
/**
/**
* Custom links for footer menu
* Custom links for footer menu
* Follows http://design.ubuntu.com/web-style-guide/scaffolding#footer
* Follows http://design.ubuntu.com/web-style-guide/scaffolding#footer
...
...
tpl/page.tpl.php
View file @
af036d8c
...
@@ -111,13 +111,20 @@
...
@@ -111,13 +111,20 @@
</nav>
</nav>
</header>
</header>
<div
class=
"wrapper"
><div
id=
"page"
>
<div
class=
"wrapper"
>
<div
id=
"main-content"
class=
"inner-wrapper"
>
<?php
if
(
$breadcrumb
)
:
?>
<?php
print
$messages
;
// Error messages ?>
<div
id=
"breadcrumb"
>
<?php
print
$breadcrumb
;
?>
</div>
<?php
endif
;
?>
<?
php
if
(
$breadcrumb
)
:
?>
<nav
role=
"navigation"
class=
"nav-secondary clearfix"
>
<?php
print
theme
(
'links__system_main_menu'
,
array
(
'links'
=>
$valencia_menu
,
'id'
=>
'breadcrumb'
));
?>
</nav>
<?php
endif
;
?>
<?php
print
$messages
;
?>
<div
id=
"main-wrapper"
><div
id=
"main"
class=
"clearfix"
>
<div
id=
"main-wrapper"
><div
id=
"main"
class=
"clearfix"
>
...
@@ -134,7 +141,7 @@
...
@@ -134,7 +141,7 @@
</div></div>
<!-- /#main, /#main-wrapper -->
</div></div>
<!-- /#main, /#main-wrapper -->
</div></div>
<!-- /#
page
, /.wrapper -->
</div></div>
<!-- /#
main-content
, /.wrapper -->
<footer
class=
"global clearfix"
>
<footer
class=
"global clearfix"
>
<nav
role=
"navigation"
>
<nav
role=
"navigation"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment