Jump to content

page data to json file


zaib
 Share

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...