Jump to content
zaib

page data to json file

Recommended Posts

I've a template which basically consists of some fields (imgs,urls etc..).

after loading page all data is coming and showing in "posts.json" file which is perfect,

issue is title link and and image link is not in the format this is my json code for exporting the page data

$getTags = $page->get("template=tags_template, include=hidden")->children("sort=title");
$json = array();
foreach($getTags as $tag){
	$json[] = array(
      'title' => $tag->title,
      'tag_url' => $tag->url,
      'tag_img' => $tag->categorythumb->url
     );
}
file_put_contents('posts.json', json_encode($json));

and this is what i'm getting in .json file

{  
      "title":"food and drink",
      "tag_url":"\/en\/discover\/food-and-drink\/",
      "tag_img":"\/site\/assets\/files\/1471\/"
   },

see the output , title is fine. But links are not formatted

should be like this

http://10.50.200.58/en/discover/food-and-drink/

http://10.50.200.58/site/assets/files/1471/food-drink.jpg

 

Any help would be appreciated.

Thank you.

Share this post


Link to post
Share on other sites

@BitPoet Thank you for you quick reply, but see the output now after putting httpUrl

{  
      "title":"food and drink",
      "tag_url":"http:\/\/10.50.200.58\/en\/discover\/food-and-drink\/",
      "tag_img":null
   },

link is not formatted

Share this post


Link to post
Share on other sites

i added this parameter, working now

JSON_UNESCAPED_SLASHES
file_put_contents('posts.json', json_encode($json, JSON_UNESCAPED_SLASHES));

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By NehaPillai
      Hello Everyone, I was trying to update SEO meta title, description and meta keywords for my website in Process Wire CMS but it saving in the backend but it is not reflecting on my website, Please help me regarding this error. Please find below attached screen shot for your ref. TIA.


    • By jds43
      Hello,
      Does anyone have experience with migrating content from Django to Processwire? Or are there any suggestions for achieving this?
    • By Mithlesh
      Hi there, 

      How to add Google Recaptcha V 3.0 in the processwire?

      My website has this module: Markup Google reCAPTCHA but I am not sure whether that is V.3 or any other, sharing the SS below:


      Let me know how to update or integrate the same

      Thanks
    • By Varun
      Hi, How to change favicon in Seavuel theme which we have purchased from https://codecanyon.net/item/seavuel-multilingual-hotel-website-with-cms-bootstrap-theme/19316343
×
×
  • Create New...