Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
Theme-WordPress-Adullact-org
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Adullact
Theme-WordPress-Adullact-org
Commits
ab271ae9
Commit
ab271ae9
authored
Aug 02, 2019
by
Nathan Peraldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add pagination functionality
parent
8aebc9b8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
38 deletions
+87
-38
category-adherent.php
category-adherent.php
+66
-21
functions.php
functions.php
+3
-9
style.css
style.css
+18
-8
No files found.
category-adherent.php
View file @
ab271ae9
<?php
<?php
//nombre max d'adhérents par page
//nombre max d'adhérents par page
$maxMembersPerPage
=
"30"
;
$maxMembersPerPage
=
20
;
$page
=
1
;
$page
=
1
;
$order
=
"asc"
;
$order
=
"asc"
;
$link
=
"http://"
.
$_SERVER
[
'SERVER_NAME'
]
.
$_SERVER
[
"REDIRECT_URL"
];
$pagination
=
true
;
//on vérifie bien le numéro de la page
//on vérifie bien le numéro de la page
if
(
isset
(
$_GET
[
"page"
]))
{
if
(
isset
(
$_GET
[
"page"
]))
{
...
@@ -19,14 +22,15 @@ if (isset($_GET["order"])) {
...
@@ -19,14 +22,15 @@ if (isset($_GET["order"])) {
$order
=
"desc"
;
$order
=
"desc"
;
}
}
}
}
get_header
();
get_header
();
$min_member_numero
=
1
+
(
$page
*
$maxMembersPerPage
)
-
$maxMembersPerPage
;
$max_member_numero
=
(
$page
*
$maxMembersPerPage
);
?>
?>
<div
class=
"wrap"
>
<div
class=
"wrap"
>
<main
id=
"main"
class=
"site-main"
role=
"main"
>
<main
id=
"main"
class=
"site-main"
role=
"main"
>
<div
id=
"adullact-sort-buttons"
>
<div
id=
"adullact-sort-buttons"
>
<div
id=
"adullact-sort-by-type-buttons"
>
<div
id=
"adullact-sort-by-type-buttons"
>
<ul
class=
"adullact-member-list"
>
<ul
class=
"adullact-member-list"
>
<?php
<?php
global
$post
;
//variable wp
global
$post
;
//variable wp
...
@@ -37,9 +41,8 @@ get_header();
...
@@ -37,9 +41,8 @@ get_header();
if
(
$url
[
$number_of_words
-
1
]
==
""
)
{
if
(
$url
[
$number_of_words
-
1
]
==
""
)
{
unset
(
$url
[
$number_of_words
-
1
]);
unset
(
$url
[
$number_of_words
-
1
]);
$url
=
array_values
(
$url
);
$url
=
array_values
(
$url
);
$number_of_words
-=
1
;
$number_of_words
-=
1
;
}
}
$category
=
$url
[
$number_of_words
-
1
];
$category
=
$url
[
$number_of_words
-
1
];
childrens_of_member_category
(
$category
);
childrens_of_member_category
(
$category
);
...
@@ -48,31 +51,73 @@ get_header();
...
@@ -48,31 +51,73 @@ get_header();
</div>
</div>
<div
id=
"adullact-sort-by-name"
>
<div
id=
"adullact-sort-by-name"
>
<ul
class=
"adullact-member-list"
>
<ul
class=
"adullact-member-list"
>
<?php
sort_page
(
$order
,
$page
)
?>
<?php
sort_page
(
$order
,
$page
,
$link
)
?>
</ul>
</ul>
</div>
</div>
</div>
</div>
<?php
echo
"<div class='adullact-members-list'>"
;
<?php
echo
"<div class='adullact-members-list'>"
;
$args
=
array
(
'posts_per_page'
=>
-
1
,
'offset'
=>
0
,
'category_name'
=>
$category
,
'orderby'
=>
'title'
,
'order'
=>
$order
);
$args
=
array
(
'posts_per_page'
=>
-
1
,
'offset'
=>
"0"
,
'category_name'
=>
$category
,
'orderby'
=>
'title'
,
'order'
=>
$order
);
$myposts
=
get_posts
(
$args
);
$myposts
=
get_posts
(
$args
);
foreach
(
$myposts
as
$post
)
:
setup_postdata
(
$post
);
$number_of_total_posts
=
count
(
$myposts
);
//pour les pages
$id
=
get_the_id
();
if
((
$number_of_total_posts
==
0
)
||
(
$number_of_total_posts
<
$min_member_numero
))
{
$url
=
get_metadata
(
"post"
,
$id
,
"project_url"
)[
0
];
echo
"<h3>Aucun résultat.</h3>"
;
$count
+=
1
;
$pagination
=
false
;
}
else
{
$counter
=
1
;
foreach
(
$myposts
as
$post
)
:
setup_postdata
(
$post
);
if
(
$counter
>=
$min_member_numero
)
{
if
(
$counter
<=
$max_member_numero
)
{
$id
=
get_the_id
();
$url
=
get_metadata
(
"post"
,
$id
,
"project_url"
)[
0
];
?>
<div
class=
"adullact-member"
>
<div>
<a
href=
"
<?php
echo
$url
;
?>
"
target=
"_blank"
>
<?php
the_post_thumbnail
(
array
(
"200"
,
"200"
));
?>
<br>
</a>
</div>
<p>
<?php
the_title
();
?>
</p><br>
</div>
<?php
}
else
{
//on a dépassé le nombre max d'adhérents à afficher, on peut donc stopper la boucle car elle n'affichera plus rien.
break
;
}
}
$counter
+=
1
;
endforeach
;
echo
"</div></div>"
;
wp_reset_postdata
();
}
if
(
$pagination
)
{
?>
?>
<div
class=
"adullact-member"
>
<div
class=
"pagination"
>
<div>
<?php
<a
href=
"
<?php
echo
$url
;
?>
"
target=
"_blank"
>
<?php
the_post_thumbnail
(
array
(
"200"
,
"200"
));
?>
<br>
$number_of_pages_to_generate
=
intdiv
(
$number_of_total_posts
,
$maxMembersPerPage
);
</a>
$reste
=
$number_of_total_posts
%
$maxMembersPerPage
;
</div>
if
(
$reste
>
0
)
{
$number_of_pages_to_generate
+=
1
;
}
<p>
<?php
the_title
();
?>
</p><br>
for
(
$i
=
1
;
$i
<=
$number_of_pages_to_generate
;
$i
++
)
{
$page_link
=
$link
.
"?page="
.
$i
.
"&order="
.
$order
;
$link_class
=
"adullact-page-link"
;
if
(
$page
==
$i
)
{
$link_class
.=
" adullact-page-link-selected"
;
}
?>
<a
href=
"
<?php
echo
$page_link
?>
"
class=
"
<?php
echo
$link_class
?>
"
>
<?php
echo
$i
?>
</a>
<?php
}
?>
</div>
</div>
<?php
endforeach
;
<?php
}
?>
echo
"</div></div>"
;
wp_reset_postdata
();
?>
</main>
</main>
</div>
</div>
<?php
get_footer
();
?>
<?php
get_footer
();
?>
\ No newline at end of file
functions.php
View file @
ab271ae9
...
@@ -4,7 +4,6 @@ add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles');
...
@@ -4,7 +4,6 @@ add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles');
function
my_theme_enqueue_styles
()
function
my_theme_enqueue_styles
()
{
{
wp_enqueue_style
(
'parent-style'
,
get_template_directory_uri
()
.
'/style.css'
);
wp_enqueue_style
(
'parent-style'
,
get_template_directory_uri
()
.
'/style.css'
);
}
}
$debug_functions
=
false
;
$debug_functions
=
false
;
...
@@ -73,16 +72,13 @@ function childrens_of_member_category($category_to_select)
...
@@ -73,16 +72,13 @@ function childrens_of_member_category($category_to_select)
echo
$my_link
;
echo
$my_link
;
}
}
}
}
function
sort_page
(
$order
,
$page
)
function
sort_page
(
$order
,
$page
,
$link
)
{
{
$link
=
$_SERVER
[
'REQUEST_URI'
];
$for_asc_link
=
$link
.
"?page="
.
$page
.
"&order=asc"
;
$for_asc_link
=
$link
.
"?page="
.
$page
.
"&order=asc"
;
$for_desc_link
=
$link
.
"?page="
.
$page
.
"&order=desc"
;
$for_desc_link
=
$link
.
"?page="
.
$page
.
"&order=desc"
;
if
(
$order
==
"desc"
)
{
if
(
$order
=
"desc"
)
{
?>
?>
<li
class=
"adullact-sort-button"
>
<li
class=
"adullact-sort-button"
>
<a
href=
"
<?php
echo
$for_asc_link
;
?>
"
>
<a
href=
"
<?php
echo
$for_asc_link
;
?>
"
>
...
@@ -110,6 +106,4 @@ function sort_page($order, $page)
...
@@ -110,6 +106,4 @@ function sort_page($order, $page)
<?php
<?php
}
}
}
}
\ No newline at end of file
?>
\ No newline at end of file
style.css
View file @
ab271ae9
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
@media
screen
and
(
min-width
:
67em
)
{
@media
screen
and
(
min-width
:
67em
)
{
.wrap
{
.wrap
{
max-width
:
1200px
;
max-width
:
1200px
;
padding
:
28px
;
padding
:
28px
;
}
}
.navigation-top
.wrap
{
.navigation-top
.wrap
{
...
@@ -28,8 +28,8 @@
...
@@ -28,8 +28,8 @@
/*************************************************************/
/*************************************************************/
#adullact-sort-buttons
{
#adullact-sort-buttons
{
display
:
flex
;
display
:
flex
;
flex-direction
:
row
;
flex-direction
:
row
;
}
}
.adullact-members-list
{
.adullact-members-list
{
...
@@ -133,15 +133,25 @@
...
@@ -133,15 +133,25 @@
margin
:
7px
;
margin
:
7px
;
}
}
#adullact-sort-by-type-buttons
#adullact-sort-by-type-buttons
{
{
width
:
70%
;
width
:
70%
;
}
#adullact-sort-by-name
{
padding-left
:
2%
;
}
}
#adullact-sort-by-name
{
.adullact-page-link
{
padding-left
:
2%
;
padding
:
8px
12px
;
background-color
:
aliceblue
;
margin
:
3px
;
}
}
.adullact-page-link-selected
{
background-color
:
#4891bf
;
}
/*************************************************************/
/*************************************************************/
/*Formulaire d'adhésion*/
/*Formulaire d'adhésion*/
/*************************************************************/
/*************************************************************/
...
...
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