Skip to content

Commit

Permalink
feat: order users (page persone) by last name
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmorgagni authored May 16, 2024
1 parent fc50213 commit c91e548
Showing 1 changed file with 51 additions and 105 deletions.
156 changes: 51 additions & 105 deletions page-templates/persone.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,114 +9,61 @@
get_header();


?>
<main id="main-container" class="main-container redbrown">

<?php get_template_part("template-parts/common/breadcrumb"); ?>

<?php get_template_part("template-parts/hero/persone"); ?>

<?php
$args = array('meta_query' => array(
'relation' => 'AND',
array(
'key' => '_dsi_persona_ruolo_scuola',
'value' => 'dirigente'
),
array(
'key' => '_dsi_persona_privacy_hidden',
'value' => 'false'
)
));
$users = get_users($args);
$number_of_users = count($users);
if ($number_of_users > 0) {
?>
<section class="section mt-4">
<div class="container">
<div class="title-section mb-5">
<h2 class="h4">Dirigente Scolastico</h2>
</div>
<div class="row variable-gutters">
<?php
foreach($users as $user){
$autore = get_user_by("ID", $user->data->ID);
get_template_part("template-parts/autore/card-persona");
}
?>
</div>
</section>
<?php } ?>

<?php
$args = array('meta_query' => array(
'relation' => 'AND',
array(
'key' => '_dsi_persona_ruolo_scuola',
'value' => 'docente'
),
array(
'key' => '_dsi_persona_privacy_hidden',
'value' => 'false'
)
));
$users = get_users($args);
$number_of_users = count($users);
if ($number_of_users > 0) {
?>
<section class="section mt-4">
<div class="container">
<div class="title-section mb-5">
<h2 class="h4">Personale docente</h2>
</div>
<div class="row variable-gutters">
<?php
foreach($users as $user){
$autore = get_user_by("ID", $user->data->ID);
get_template_part("template-parts/autore/card-persona");
}
?>
</div>
</section>
<?php } ?>

function visualizza_utenti($ruolo_utente, $intestazione_sezione) {
// carica tutti gli utenti e li ordina per cognome
$args = array(
'meta_key' => 'last_name',
'orderby' => 'meta_value',
'order' => 'ASC',
//seleziona gli utenti in base al ruolo e privacy
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_dsi_persona_ruolo_scuola',
'value' => $ruolo_utente,
'compare' => '='
),
array(
'key' => '_dsi_persona_privacy_hidden',
'value' => 'false'
)
)
);

<?php
$args = array('meta_query' => array(
'relation' => 'AND',
array(
'key' => '_dsi_persona_ruolo_scuola',
'value' => 'personaleata'
),
array(
'key' => '_dsi_persona_privacy_hidden',
'value' => 'false'
)
));
$users = get_users($args);
$number_of_users = count($users);
if ($number_of_users > 0) {
$number_of_users = count($users);
if ($number_of_users > 0) {
?>
<section class="section mt-4">
<div class="container">
<div class="title-section mb-5">
<h2 class="h4"><?php echo $intestazione_sezione; ?></h2>
</div>
<div class="row variable-gutters">
<?php
foreach ($users as $user) {
global $autore;
$autore = get_user_by("ID", $user->ID);
get_template_part("template-parts/autore/card-persona");
}
?>
</div>
</section>
<?php
}
}
?>
<section class="section mt-4">
<div class="container">
<div class="title-section mb-5">
<h2 class="h4">Personale non docente</h2>
</div>
<div class="row variable-gutters">
<?php
foreach($users as $user){
$autore = get_user_by("ID", $user->data->ID);
get_template_part("template-parts/autore/card-persona");
}
?>
</div>
</section>
<?php } ?>

<?php
<main id="main-container" class="main-container redbrown">
<?php get_template_part("template-parts/common/breadcrumb"); ?>
<?php get_template_part("template-parts/hero/persone"); ?>
<?php visualizza_utenti('dirigente', 'Dirigente Scolastico'); ?>
<?php visualizza_utenti('docente', 'Personale docente'); ?>
<?php visualizza_utenti('personaleata', 'Personale non docente'); ?>
<?php
$contenuto_ulteriore = dsi_get_option("contenuto_ulteriore_sezione_persone", "persone");
if($contenuto_ulteriore!= "") {
?>
?>
<section class="section bg-light py-5">
<div class="container">
<div class="title-section">
Expand All @@ -125,10 +72,9 @@
<?php echo $contenuto_ulteriore; ?>
</div>
</section>
<?php
<?php
}
?>

?>
</main>

<?php
Expand Down

0 comments on commit c91e548

Please sign in to comment.