@@ -378,6 +378,11 @@ public static function wrapResult($result = '', $queryObject = '')
378378 public static function contentstackRequest ($ queryObject = '' , $ type = '' )
379379 {
380380 $ server_output = '' ;
381+ STATIC $ live_response = '' ; //static variable
382+ STATIC $ non_live_response = '' ;
383+ STATIC $ live_response_decode = '' ;
384+ STATIC $ entry_uid = '' ;
385+ STATIC $ content_type_uid = '' ;
381386
382387 if ($ queryObject ) {
383388 if (Utility::isLivePreview ($ queryObject )) {
@@ -414,6 +419,19 @@ public static function contentstackRequest($queryObject = '', $type = '')
414419 // close the curl
415420 curl_close ($ http );
416421 if ($ httpcode > 199 && $ httpcode < 300 ) {
422+ if (!Utility::isLivePreview ($ queryObject )) {
423+ $ result = json_decode ($ response , true );
424+ Utility::to_render_content ($ result , $ entry_uid , $ live_response_decode );
425+ $ response = json_encode ($ result , true );
426+
427+ }
428+ else
429+ {
430+ $ entry_uid = $ queryObject ->entryUid ;
431+ $ content_type_uid = $ queryObject ->contentType ->uid ;
432+ $ live_response_decode = json_decode ($ response , true );
433+
434+ }
417435 // wrapper the server result
418436 $ response = Utility::wrapResult ($ response , $ queryObject );
419437 } else {
@@ -423,6 +441,19 @@ public static function contentstackRequest($queryObject = '', $type = '')
423441 return $ response ;
424442 }
425443
444+ public static function to_render_content (&$ resp , $ entry_uid , $ live_response_decode ){
445+ if (is_array ($ resp )) {
446+ if (array_key_exists ('uid ' , $ resp ) && $ resp ['uid ' ] == $ entry_uid ){
447+ $ resp = $ live_response_decode ;
448+ }else
449+ {
450+ foreach ($ resp as $ key => $ value ) {
451+ Utility::to_render_content ($ resp [$ key ], $ entry_uid , $ live_response_decode );
452+ }
453+ }
454+ }
455+ }
456+
426457 /**
427458 * Validate the key is set or not
428459 *
0 commit comments