Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
V
views
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
3
Merge Requests
3
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
views
Commits
b5cecab3
Commit
b5cecab3
authored
Apr 21, 2008
by
merlinofchaos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Spiffy improvements to grid view
parent
cb1b8e01
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
5 deletions
+40
-5
includes/plugins.inc
includes/plugins.inc
+8
-0
theme/theme.inc
theme/theme.inc
+32
-5
No files found.
includes/plugins.inc
View file @
b5cecab3
...
...
@@ -2473,6 +2473,7 @@ class views_plugin_style_grid extends views_plugin_style {
function
options
(
$display
)
{
return
array
(
'columns'
=>
4
,
'alignment'
=>
'horizontal'
,
);
}
...
...
@@ -2485,6 +2486,13 @@ class views_plugin_style_grid extends views_plugin_style {
'#title'
=>
t
(
'Number of columns'
),
'#default_value'
=>
$this
->
options
[
'columns'
],
);
$form
[
'alignment'
]
=
array
(
'#type'
=>
'radios'
,
'#title'
=>
t
(
'Alignment'
),
'#options'
=>
array
(
'horizontal'
=>
t
(
'Horizontal'
),
'vertical'
=>
t
(
'Vertical'
)),
'#default_value'
=>
$this
->
options
[
'alignment'
],
'#description'
=>
t
(
'Horizontal alignment will place items starting in the upper left and moving right. Vertical alignment will place items starting in the upper left and moving down.'
),
);
}
}
...
...
theme/theme.inc
View file @
b5cecab3
...
...
@@ -274,12 +274,39 @@ function template_preprocess_views_view_grid(&$vars) {
$columns
=
$options
[
'columns'
];
$rows
=
array
();
$row
=
array
();
foreach
(
$vars
[
'rows'
]
as
$count
=>
$item
)
{
$row
[]
=
$item
;
if
((
$count
+
1
)
%
$columns
==
0
)
{
if
(
$options
[
'alignment'
]
==
'horizontal'
)
{
$row
=
array
();
foreach
(
$vars
[
'rows'
]
as
$count
=>
$item
)
{
$row
[]
=
$item
;
if
((
$count
+
1
)
%
$columns
==
0
)
{
$rows
[]
=
$row
;
$row
=
array
();
}
}
if
(
$row
)
{
$rows
[]
=
$row
;
$row
=
array
();
}
}
else
{
$num_rows
=
floor
(
count
(
$vars
[
'rows'
])
/
$columns
);
// The remainders are the 'odd' columns that are slightly longer.
$remainders
=
count
(
$vars
[
'rows'
])
%
$columns
;
$row
=
0
;
$col
=
0
;
foreach
(
$vars
[
'rows'
]
as
$count
=>
$item
)
{
$rows
[
$row
][
$col
]
=
$item
;
$row
++
;
if
(
!
$remainders
&&
$row
==
$num_rows
)
{
$row
=
0
;
$col
++
;
}
else
if
(
$remainders
&&
$row
==
$num_rows
+
1
)
{
$row
=
0
;
$col
++
;
$remainders
--
;
}
}
}
$vars
[
'rows'
]
=
$rows
;
...
...
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