Kaynağa Gözat

Dynamic global menu is working fine

Md Mozahidur Rahman 1 yıl önce
ebeveyn
işleme
4443bc47cf

+ 105 - 66
css/theme-styles.css

@@ -2170,7 +2170,7 @@ section#lower-nav nav ul > li > a > img {
   margin: 0 !important;
   z-index: 999;
 }
-#navbar #upper-nav nav {
+#navbar #uiu-global-nav nav {
   text-align: center;
   padding: 2px 0 !important;
   margin: 0 !important;
@@ -2180,11 +2180,10 @@ section#lower-nav nav ul > li > a > img {
   z-index: 10;
   transition: 0.5s ease-in-out;
   background-color: #160c0c;
-  border-bottom: 4px solid #F68B1F;
   box-shadow: 0px 5px 12px -5px #2F4858;
 }
 @media (max-width: 1100px) {
-  #navbar #upper-nav nav {
+  #navbar #uiu-global-nav nav {
     display: block !important;
     text-align: unset;
     height: unset;
@@ -2192,63 +2191,78 @@ section#lower-nav nav ul > li > a > img {
     border: unset;
   }
 }
-#navbar #upper-nav nav .logo-close-menu {
+#navbar #uiu-global-nav nav .logo-close-menu {
   display: flex;
   justify-content: space-between;
   align-items: center;
+  z-index: 20;
 }
-#navbar #upper-nav nav .logo-close-menu .logo {
+#navbar #uiu-global-nav nav .logo-close-menu .logo {
   width: auto;
-  margin-right: 30px;
+  padding-right: 30px;
   padding-left: 20px;
   transition-duration: 0.5s;
+  margin-right: 1rem;
 }
-#navbar #upper-nav nav .logo-close-menu .logo img {
+#navbar #uiu-global-nav nav .logo-close-menu .logo img {
   height: 50px !important;
   transition-duration: 0.5s;
 }
-#navbar #upper-nav nav .logo-close-menu .menubars-and-search {
+@media (max-width: 1100px) {
+  #navbar #uiu-global-nav nav .logo-close-menu .logo img {
+    height: 40px !important;
+  }
+}
+#navbar #uiu-global-nav nav .logo-close-menu #menu-bars,
+#navbar #uiu-global-nav nav .logo-close-menu #seacrh {
   display: none !important;
   transition-duration: 0.4s;
   padding-top: 0.25rem;
   padding-right: 0.25rem;
-}
-#navbar #upper-nav nav .logo-close-menu .menubars-and-search span {
-  cursor: pointer;
   font-size: 2.5rem;
+  cursor: pointer;
+  color: #fff;
 }
-#navbar #upper-nav nav .logo-close-menu .menubars-and-search #seacrh {
+@media (max-width: 1100px) {
+  #navbar #uiu-global-nav nav .logo-close-menu #menu-bars,
+  #navbar #uiu-global-nav nav .logo-close-menu #seacrh {
+    display: block !important;
+  }
+}
+#navbar #uiu-global-nav nav .logo-close-menu #menu-bars {
+  padding-left: 0.5rem;
+}
+#navbar #uiu-global-nav nav .logo-close-menu #seacrh {
   font-size: 2.4rem;
   margin-right: 1rem;
 }
-#navbar #upper-nav nav .logo-close-menu .menubars-and-search #seacrh:hover {
+#navbar #uiu-global-nav nav .logo-close-menu #seacrh:hover {
   color: #f3e7e7;
 }
-@media (max-width: 1100px) {
-  #navbar #upper-nav nav .logo-close-menu .menubars-and-search {
-    display: block !important;
-    margin: 0px auto;
-    margin-right: 10px !important;
-    font-size: 45px;
-    color: #fff;
-  }
-}
-#navbar #upper-nav nav #menu-uiu-header-menu {
+#navbar #uiu-global-nav nav .menu {
   display: flex;
   align-items: center;
   z-index: 10;
 }
 @media (max-width: 1100px) {
-  #navbar #upper-nav nav #menu-uiu-header-menu {
-    display: block !important;
+  #navbar #uiu-global-nav nav .menu {
+    display: none !important;
     padding: 2rem;
+    height: 0px;
+  }
+}
+@media (max-width: 1100px) {
+  #navbar #uiu-global-nav nav .menu.show {
+    display: block !important;
+    height: calc(100vh - 66.594px);
+    overflow-y: auto;
   }
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li {
+#navbar #uiu-global-nav nav .menu > li {
   margin-right: 50px;
 }
 @media (max-width: 1100px) {
-  #navbar #upper-nav nav #menu-uiu-header-menu > li {
+  #navbar #uiu-global-nav nav .menu > li {
     display: block;
     margin: unset;
     text-align: unset;
@@ -2256,17 +2270,17 @@ section#lower-nav nav ul > li > a > img {
   }
 }
 @media (max-width: 1100px) {
-  #navbar #upper-nav nav #menu-uiu-header-menu > li.search {
+  #navbar #uiu-global-nav nav .menu > li.search {
     display: none;
   }
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li:last-child {
+#navbar #uiu-global-nav nav .menu > li:last-child {
   margin-right: 0px;
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li:last-child {
+#navbar #uiu-global-nav nav .menu > li:last-child {
   margin-right: 0;
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li > a {
+#navbar #uiu-global-nav nav .menu > li > a {
   color: #fff;
   transition-duration: 0.3s;
   font-size: 14px;
@@ -2277,7 +2291,7 @@ section#lower-nav nav ul > li > a > img {
   cursor: pointer !important;
 }
 @media (max-width: 1100px) {
-  #navbar #upper-nav nav #menu-uiu-header-menu > li > a {
+  #navbar #uiu-global-nav nav .menu > li > a {
     text-align: unset;
     overflow-y: auto;
     border-bottom: 1px solid #333;
@@ -2285,7 +2299,7 @@ section#lower-nav nav ul > li > a > img {
     border-radius: unset;
   }
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li:after {
+#navbar #uiu-global-nav nav .menu > li:after {
   content: "";
   display: block;
   margin: auto;
@@ -2295,19 +2309,19 @@ section#lower-nav nav ul > li > a > img {
   transition: width 0.3s ease, background-color 0.5s ease;
 }
 @media (max-width: 1100px) {
-  #navbar #upper-nav nav #menu-uiu-header-menu > li:after {
+  #navbar #uiu-global-nav nav .menu > li:after {
     display: none !important;
   }
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li:hover:after {
+#navbar #uiu-global-nav nav .menu > li:hover:after {
   width: 100%;
   background: #fff;
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li.active:after {
+#navbar #uiu-global-nav nav .menu > li.active:after {
   width: 100%;
   background: #fff;
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu {
+#navbar #uiu-global-nav nav .menu .sub-menu {
   background: #FFFBF6 !important;
   color: #160c0c;
   position: fixed;
@@ -2319,71 +2333,96 @@ section#lower-nav nav ul > li > a > img {
   box-shadow: 0 0 10px rgba(0, 0, 0, 0.15), 0 3px 3px rgba(0, 0, 0, 0.15);
 }
 @media (max-width: 1100px) {
-  #navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu {
+  #navbar #uiu-global-nav nav .menu .sub-menu {
     position: unset;
     background: transparent !important;
+    box-shadow: unset !important;
   }
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu .container {
-  -moz-columns: 3;
-       columns: 3;
-  gap: 2rem;
+#navbar #uiu-global-nav nav .menu .sub-menu .container {
   padding: 2rem 0;
+  display: flex;
+  justify-content: space-between;
+  gap: 2rem;
 }
 @media (max-width: 1100px) {
-  #navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu .container {
+  #navbar #uiu-global-nav nav .menu .sub-menu .container {
     -moz-columns: 1;
          columns: 1;
-    padding: 0.25rem 1rem 1rem;
+    padding: 0.25rem 1rem;
     max-width: unset !important;
   }
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu .sub-menu-item {
-  display: block;
-  padding: 0.25rem !important;
+#navbar #uiu-global-nav nav .menu .sub-menu .container .menu-item {
+  margin: unset !important;
+  margin-bottom: 0.5rem !important;
+  padding: 0 !important;
   text-align: start;
   font-size: 0.8rem;
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu .sub-menu-item a {
+#navbar #uiu-global-nav nav .menu .sub-menu .container .menu-item a {
   color: #000;
+  padding: 5px !important;
+  margin: 0 !important;
 }
 @media (max-width: 1100px) {
-  #navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu .sub-menu-item a {
+  #navbar #uiu-global-nav nav .menu .sub-menu .container .menu-item a {
     color: #fff;
+    margin: unset;
+    margin-bottom: 0.25rem;
   }
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu .sub-menu-item a:hover {
+#navbar #uiu-global-nav nav .menu .sub-menu .container .menu-item a:hover {
   color: #994D33;
   opacity: 1;
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu .col-breaker {
-  -moz-column-break-before: column;
-       break-before: column;
+#navbar #uiu-global-nav nav .menu .sub-menu .container .sub-menu-feature {
+  width: 40%;
+  display: block;
+  text-align: left;
+  color: #994D33;
+  padding-right: 2rem;
 }
 @media (max-width: 1100px) {
-  #navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu .col-breaker {
-    -moz-column-break-before: unset;
-         break-before: unset;
+  #navbar #uiu-global-nav nav .menu .sub-menu .container .sub-menu-feature {
+    display: none;
   }
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu .extra-item {
-  width: 100%;
-  flex: 3;
-  text-align: left;
-}
-#navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu .extra-item img {
+#navbar #uiu-global-nav nav .menu .sub-menu .container .sub-menu-feature .menu_feature_image {
   width: 100%;
   max-width: 350px;
 }
+#navbar #uiu-global-nav nav .menu .sub-menu .container .sub-menu-feature .menu_title {
+  margin-top: 1rem;
+  font-weight: 600;
+  font-size: 1rem;
+  text-transform: capitalize;
+  line-height: 1.4;
+}
+#navbar #uiu-global-nav nav .menu .sub-menu .container .sub-menu-feature .menu_description {
+  margin-top: 0.5rem;
+  font-size: 0.8rem;
+  line-height: 1.7;
+  text-align: justify;
+}
+#navbar #uiu-global-nav nav .menu .sub-menu .container .sub-menu-link-container {
+  width: 60%;
+  padding-left: 2rem;
+  display: grid !important;
+  grid-template-columns: repeat(2, 1fr);
+  height: -moz-fit-content;
+  height: fit-content;
+}
 @media (max-width: 1100px) {
-  #navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu .extra-item {
-    display: none;
+  #navbar #uiu-global-nav nav .menu .sub-menu .container .sub-menu-link-container {
+    width: 100% !important;
+    padding-left: 0.75rem;
+    display: block !important;
   }
 }
-#navbar #upper-nav nav #menu-uiu-header-menu > li .sub-menu.show-mega-menu {
+#navbar #uiu-global-nav nav .menu .sub-menu.show-mega-menu {
   display: block !important;
 }
-
 @media screen and (max-width: 1000px) {
   section#lower-nav nav {
     display: none !important;

+ 57 - 3
functions.php

@@ -263,8 +263,6 @@ add_filter('acf/update_value/name=employeeid', 'uiu_acf_update_user_id', 10, 3);
 /**
  * Make theme option page field value available via REST API
  */
-
-
 function theme_options_route_menu()
 {
 	return get_field('menu_rich_contents', 'option');
@@ -277,11 +275,67 @@ add_action("rest_api_init", function () {
 	]);
 });
 
+
+function fetch_conference_data($limit)
+{
+	$auth_token = get_field('auth_token', 'option');
+	$client_id = get_field('client_id', 'option');
+	$conference_api = get_field('conference_api', 'option');
+
+	$curl = curl_init();
+
+	curl_setopt_array($curl, array(
+		CURLOPT_URL => $conference_api,
+		CURLOPT_RETURNTRANSFER => true,
+		CURLOPT_ENCODING => '',
+		CURLOPT_MAXREDIRS => 10,
+		CURLOPT_TIMEOUT => 0,
+		CURLOPT_FOLLOWLOCATION => true,
+		CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+		CURLOPT_CUSTOMREQUEST => 'POST',
+		CURLOPT_POSTFIELDS => '{
+            "employee_id" : " ",
+            "year" : " ",
+            "auth_token" : "' . $auth_token . '",
+            "user_login_id" : "' . $client_id . '",
+			 "page" : 1,
+			 "limit" : ' . $limit . '
+        }',
+		CURLOPT_HTTPHEADER => array(
+			'Content-Type: application/json'
+		),
+	));
+
+	$response = curl_exec($curl);
+	curl_close($curl);
+	$response = json_decode($response, true);
+
+	return  $response;
+}
+
+function uiu_conference_route_menu_with_params(WP_REST_Request $request)
+{
+	$arg = $request->get_param('limit');
+	//   $params = $request->get_params();
+	//    var_dump( $arg );
+
+	return fetch_conference_data($arg);
+}
+
+
+add_action("rest_api_init", function () {
+	register_rest_route("uiu_api", "/conference", [
+		"methods" => "GET",
+		"callback" => "uiu_conference_route_menu_with_params",
+	]);
+});
+
+
+
 add_action('rest_api_init', function () {
 	header("Access-Control-Allow-Origin: *");
 });
 
-
 /**
  * Custom Walker class to add extra element to sub-menu ul.
  */

+ 1 - 1
header.php

@@ -29,7 +29,7 @@
 
 		<header id="navbar">
 
-			<section id="upper-nav">
+			<section id="uiu-global-nav">
 
 				<nav class="container-fluid">
 

+ 19 - 4
js/theme-settings.js

@@ -46,9 +46,8 @@ window.onscroll = function () {
 //     });
 //   });
 // }
-
 // show mega menu in upper nav
-const menuItem = document.querySelectorAll(".menu-item");
+const menuItem = document.querySelectorAll("#navbar .menu > .menu-item");
 
 // const allMenuBtn = document.querySelectorAll(".menu-btn");
 const allMenuContent = document.querySelectorAll(".sub-menu");
@@ -80,7 +79,20 @@ if (menuItem) {
   });
 }
 
+// toggle responsive menu
+
+const toggleBtn = document.getElementById("menu-bars");
+
+const menuContainer = document.querySelector("#uiu-global-nav .menu");
+
+if (toggleBtn && menuContainer) {
+  toggleBtn.addEventListener("click", () => {
+    menuContainer.classList.toggle("show");
+  });
+}
+
 // fetch submenu extra item data
+
 const fetchMenudata = async () => {
   try {
     const res = await fetch("https://cse.uiu.local/wp-json/options/menu", {
@@ -101,15 +113,18 @@ fetchMenudata().then((data) => {
 
 function addDataToMenu(data) {
   if (data) {
-    console.log(data);
     const menuItem = document.querySelectorAll(".menu-item");
 
     if (menuItem) {
       menuItem.forEach((item) => {
         const targetData = data.find((data) =>
-          item.className.includes(data.menu_parent_class)
+          item.innerHTML
+            .toLowerCase()
+            .includes(data.parent_navigation_label.toLowerCase())
         );
 
+        console.log(targetData);
+
         const menuTitle = item.querySelector(".menu_title");
 
         const menuDesc = item.querySelector(".menu_description");

+ 31 - 17
page-template/page-conference.php

@@ -102,22 +102,36 @@ get_header(); ?>
                             <?php
 
 
-                            // $uniqueTitles = [];
+                            $uniqueTitles = [];
+
+                            // Iterate through the data and remove duplicates
+                            foreach ($response as &$item) {
+                                $conferenceList = &$item['ConferenceList'];
+                                foreach ($conferenceList as &$conference) {
+                                    $paperTitle = $conference['PaperTitle'];
+                                    if (!in_array($paperTitle, $uniqueTitles)) {
+                                        $uniqueTitles[] = $paperTitle;
+                                    } else {
+                                        // Remove duplicate entry
+                                        $conference = null;
+                                    }
+                                }
+                                // Remove null entries from the conference list
+                                $conferenceList = array_filter($conferenceList);
+                            }
 
-                            // // Iterate through the data and remove duplicates
-                            // foreach ($response as &$item) {
-                            //     $conferenceList = &$item['ConferenceList'];
-                            //     foreach ($conferenceList as &$conference) {
-                            //         $paperTitle = $conference['PaperTitle'];
-                            //         if (!in_array($paperTitle, $uniqueTitles)) {
-                            //             $uniqueTitles[] = $paperTitle;
-                            //         } else {
-                            //             // Remove duplicate entry
-                            //             $conference = null;
+                            // $uniqueTitles = [];
+                            // $result = [];
+
+                            // foreach ($response as $item) {
+                            //     $conferenceList = $item['ConferenceList'];
+                            //     foreach ($conferenceList as $conference) {
+                            //         $title = $conference['PaperTitle'];
+                            //         if (!in_array($title, $uniqueTitles)) {
+                            //             $uniqueTitles[] = $title;
+                            //             $result[] = $conference;
                             //         }
                             //     }
-                            //     // Remove null entries from the conference list
-                            //     $conferenceList = array_filter($conferenceList);
                             // }
 
 
@@ -184,10 +198,10 @@ get_header(); ?>
             redirect: 'follow'
         };
 
-        fetch("https://ucamapi.uiu.ac.bd/api/EmployeeConference", requestOptions)
-            .then(response => response.text())
-            .then(result => console.log(result))
-            .catch(error => console.log('error', error));
+        // fetch("https://ucamapi.uiu.ac.bd/api/EmployeeConference", requestOptions)
+        //     .then(response => response.text())
+        //     .then(result => console.log(result))
+        //     .catch(error => console.log('error', error));
     </script>
 
 

+ 22 - 0
page-template/page-journal.php

@@ -40,6 +40,28 @@ get_header(); ?>
     curl_close($curl);
     $response = json_decode($response, true);
 
+
+    // Decode the JSON data
+    $data = json_decode($data, true);
+
+    // Array to store unique paper titles
+    $uniquePaperTitles = [];
+
+    // Iterate over the data and extract unique paper titles
+    foreach ($response as $entry) {
+        foreach ($entry['JournalList'] as $journal) {
+            $paperTitle = $journal['PaperTitle'];
+            if (!in_array($paperTitle, $uniquePaperTitles)) {
+                $uniquePaperTitles[] = $paperTitle;
+            }
+        }
+    }
+
+    // Output the unique paper titles
+    foreach ($uniquePaperTitles as $title) {
+        echo $title . "\n";
+    }
+
 ?>
 
     <main id="main" class="site-main" role="main">