Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Adullact
Theme-WordPress-Adullact-org
Commits
dfae1e01
Commit
dfae1e01
authored
Aug 02, 2019
by
N. Peraldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit recuperation of ordering
parent
ba8f24c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
28 deletions
+54
-28
category-adherent.php
category-adherent.php
+36
-17
functions.php
functions.php
+18
-11
No files found.
category-adherent.php
View file @
dfae1e01
<?php
get_header
();
?>
<?php
//nombre max d'adhérents par page
$maxMembersPerPage
=
"30"
;
$page
=
1
;
$order
=
"asc"
;
//on vérifie bien le numéro de la page
if
(
isset
(
$_GET
[
"page"
]))
{
if
(
is_numeric
(
$_GET
[
"page"
]))
{
if
((
$_GET
[
"page"
]
>
0
)
&&
(
$_GET
[
"page"
]
<
100
))
{
$page
=
$_GET
[
"page"
];
}
}
}
//on vérifie bien l'ordre donné
if
(
isset
(
$_GET
[
"order"
]))
{
if
(
$_GET
[
"order"
]
==
"desc"
)
{
$order
=
"desc"
;
}
}
get_header
();
?>
<div
class=
"wrap"
>
<main
id=
"main"
class=
"site-main"
role=
"main"
>
<div
id=
"adullact-sort-buttons"
>
...
...
@@ -9,35 +32,31 @@
global
$post
;
//variable wp
$order
=
"asc"
;
//on récup le nom de la catégorie de l'url
$category
=
explode
(
"/"
,
$_SERVER
[
'REQUEST_URI'
])[
2
];
$url
=
explode
(
"/"
,
$_SERVER
[
"REDIRECT_URL"
]);
//on récup le tri croissant / décroissant
if
(
isset
(
$_GET
[
"order"
]))
{
$order
=
$_GET
[
"order"
];
if
(
$order
!=
"asc"
&&
$order
!=
"desc"
)
{
$order
=
"asc"
;
}
//nombre de mots dans l'url, sert à déterminer la catégorie recherchée
$number_of_words
=
count
(
$url
);
if
(
$url
[
$number_of_words
-
1
]
==
""
)
{
unset
(
$url
[
$number_of_words
-
1
]);
$url
=
array_values
(
$url
);
$number_of_words
-=
1
;
}
$args
=
array
(
'posts_per_page'
=>
10
,
'offset'
=>
0
,
'category_name'
=>
$category
,
'orderby'
=>
'title'
,
'order'
=>
$order
);
$myposts
=
get_posts
(
$args
);
$count
=
0
;
//va servir pour les retour à la ligne lorsqu'on a affiché le max d'éléments par ligne
childrens_of_member_category
(
"
$category
"
);
$category
=
$url
[
$number_of_words
-
1
];
childrens_of_member_category
(
$category
);
?>
</ul>
</div>
<div
id=
"adullact-sort-by-name"
>
<ul
class=
"adullact-member-list"
>
<?php
sort_page
()
?>
<?php
sort_page
(
$order
)
?>
</ul>
</div>
</div>
<?php
echo
"<div class='adullact-members-list'>"
;
$args
=
array
(
'posts_per_page'
=>
-
1
,
'offset'
=>
0
,
'category_name'
=>
$category
,
'orderby'
=>
'title'
,
'order'
=>
$order
);
$myposts
=
get_posts
(
$args
);
foreach
(
$myposts
as
$post
)
:
setup_postdata
(
$post
);
$id
=
get_the_id
();
...
...
functions.php
View file @
dfae1e01
...
...
@@ -36,7 +36,7 @@ function childrens_of_member_category($category_to_select)
$id
=
$member_category_object
->
cat_ID
;
$server_link
=
$_SERVER
[
"SERVER_NAME"
];
$link_Category
=
"http://"
.
$server_link
.
"/category/"
;
$current_category
=
explode
(
"/"
,
$_SERVER
[
'REQUEST_URI'
])[
2
]
;
$current_category
=
$category_to_select
;
dump_debug
(
$_SERVER
);
echo_debug
(
"
\n
----------------------
\n
"
);
...
...
@@ -76,30 +76,37 @@ function childrens_of_member_category($category_to_select)
}
function
sort_page
()
function
sort_page
(
$order
,
$page
)
{
$link
=
$_SERVER
[
'REQUEST_URI'
];
$cleanLink
=
explode
(
"?order"
,
$link
)[
0
];
$for_asc_link
=
$link
.
"?page="
.
$page
.
"&order=asc"
;
$for_desc_link
=
$link
.
"?page="
.
$page
.
"&order=desc"
;
if
(
strpos
(
$link
,
"
order
=
desc"
)
)
{
if
(
$
order
=
"
desc"
)
{
?>
<li
class=
"adullact-sort-button"
>
<a
href=
"
<?php
echo
$
cleanLink
;
?>
?order=asc
"
>
<a
href=
"
<?php
echo
$
for_asc_link
;
?>
"
>
Croissant
</a>
</li>
<li
class=
"adullact-sort-button adullact-selected"
><a
href=
"
<?php
echo
$cleanLink
;
?>
?order=desc"
>
<li
class=
"adullact-sort-button adullact-selected"
>
<a
href=
"
<?php
echo
$for_desc_link
;
?>
"
>
Décroissant
</a></li>
</a>
</li>
<?php
}
else
{
?>
<li
class=
"adullact-sort-button adullact-selected"
><a
href=
"
<?php
echo
$cleanLink
;
?>
?order=asc"
>
<li
class=
"adullact-sort-button adullact-selected"
>
<a
href=
"
<?php
echo
$for_asc_link
;
?>
"
>
Croissant
</a></li>
<li
class=
"adullact-sort-button"
><a
href=
"
<?php
echo
$cleanLink
;
?>
?order=desc"
>
</a>
</li>
<li
class=
"adullact-sort-button"
>
<a
href=
"
<?php
echo
$for_desc_link
;
?>
"
>
Décroissant
</a></li>
</a>
</li>
<?php
}
...
...
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