Explorar o código

working with faculty blcok

Mozahidur Rahman hai 1 ano
pai
achega
6926156e8c

+ 1 - 1
inc/acf-json/group_642aa09ae85e7.json

@@ -203,5 +203,5 @@
     "active": true,
     "description": "",
     "show_in_rest": 0,
-    "modified": 1680617704
+    "modified": 1683188546
 }

+ 21 - 1
inc/acf-json/group_642c30c3d7bd7.json

@@ -27,6 +27,26 @@
             "mime_types": "",
             "preview_size": "medium"
         },
+        {
+            "key": "field_64536b4fcd2d9",
+            "label": "EmployeeID",
+            "name": "employeeid",
+            "aria-label": "",
+            "type": "text",
+            "instructions": "",
+            "required": 0,
+            "conditional_logic": 0,
+            "wrapper": {
+                "width": "",
+                "class": "",
+                "id": ""
+            },
+            "default_value": "",
+            "maxlength": "",
+            "placeholder": "",
+            "prepend": "",
+            "append": ""
+        },
         {
             "key": "field_642c30c3e3387",
             "label": "Designation",
@@ -66,5 +86,5 @@
     "active": true,
     "description": "",
     "show_in_rest": 0,
-    "modified": 1680628858
+    "modified": 1683188574
 }

+ 3 - 3
inc/acf-json/group_64534cae361a7.json

@@ -1,6 +1,6 @@
 {
     "key": "group_64534cae361a7",
-    "title": "Block - Faculty API",
+    "title": "Block - Faculty Member",
     "fields": [
         {
             "key": "field_64535feb0511e",
@@ -28,7 +28,7 @@
             {
                 "param": "block",
                 "operator": "==",
-                "value": "acf\/portfolio-item"
+                "value": "acf\/faculty-member"
             }
         ]
     ],
@@ -41,5 +41,5 @@
     "active": true,
     "description": "",
     "show_in_rest": 0,
-    "modified": 1683186854
+    "modified": 1683188424
 }

+ 8 - 8
inc/custom-blocks.php

@@ -1,6 +1,6 @@
 <?php
 
-function acf_portfolio_item_block()
+function acf_faculty_member_block()
 {
 
     // check function exists
@@ -8,15 +8,15 @@ function acf_portfolio_item_block()
 
         // register a portfolio item block
         acf_register_block(array(
-            'name'                => 'portfolio-item',
-            'title'                => __('Portfolio Item'),
-            'description'        => __('A custom block for portfolio items.'),
-            'render_template'    => 'template-parts/blocks/portfolio-item/block-portfolio-item.php',
+            'name'                => 'faculty_member',
+            'title'                => __('Faculty Member'),
+            'description'        => __('A custom block for faculty information.'),
+            'render_template'    => 'template-parts/blocks/faculty-member/block-faculty-member.php',
             'category'            => 'layout',
-            'icon'                => 'excerpt-view',
-            'keywords'            => array('portfolio'),
+            'icon'                => 'businessperson',
+            'keywords'            => array('faculty'),
         ));
     }
 }
 
-add_action('acf/init', 'acf_portfolio_item_block');
+add_action('acf/init', 'acf_faculty_member_block');

+ 33 - 1
single-faculty.php

@@ -90,12 +90,44 @@ get_header(); ?>
 						<?php endif; ?>
 
 
+						<?php
+						$employeeid = get_field('employeeid');
+
+						$url = 'http://103.109.52.3/webapi/api/EmployeeJournal';
+						$response = wp_remote_post(
+							$url,
+							array(
+								'body' => array(
+									'employee_id' => $employeeid,
+									"year"  => "",
+									'user_login_id' => 'api_user',
+									'auth_token' => 'api_user20230419045143'
+								)
+
+							)
+						);
+
+						$data = json_decode(wp_remote_retrieve_body($response), true);
+
+						// foreach ($data as $query) {
+						// 	$EmployeeID = $query['EmployeeID'];
+						// }
+
+						?>
 						<span class="contact-dets member-api"></span>
 
 						<div class="bio desc-block">
 							<h2 class="m-text">Publication</h2>
 							<p class="m-text">
-								<?php the_content(); ?>
+								<?php
+								if (!empty($employeeid)) {
+
+									print_r($data);
+								} else {
+									echo 'Please insert Login ID of the faculty member</ul></div>';
+								}
+
+								?>
 						</div>
 
 					</div>

+ 6 - 6
template-parts/blocks/portfolio-item/block-portfolio-item.php → template-parts/blocks/faculty-member/block-faculty-member.php

@@ -16,14 +16,14 @@ $response = wp_remote_post(
 
 $data = json_decode(wp_remote_retrieve_body($response), true);
 
-foreach ($data as $query) {
-    $EmployeeID = $query['EmployeeID'];
-}
+// foreach ($data as $query) {
+//     $EmployeeID = $query['EmployeeID'];
+// }
 
 echo '<div class="portfolio-item">';
-if (!empty($logo)) {
-    echo wp_get_attachment_image($logo['ID'], 'thumbnail', null, array('class' => 'portfolio-logo alignleft'));
-}
+// if (!empty($logo)) {
+//     echo wp_get_attachment_image($logo['ID'], 'thumbnail', null, array('class' => 'portfolio-logo alignleft'));
+// }
 if (!empty($login_id)) {
     echo '<h3 class="portfolio-title">Faculty Member Information</h3>';
     echo '<div class="portfolio-description"> <ul>';