Jump to content

Search the Community

Showing results for tags 'JSON'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. Hello, currently I am trying to develop my first iPad app with Xcode. For handling the data on a remote server I want to use ProcessWire as middleware. For synchronizing the data I am trying the Xcode framework Alamofire, which has more convenient functions for handling such requests, especially for a beginner in Swift like me. Now I am wondering how I should output my JSON objects in my template files the right way for Alamofire to recognize them. So far I tried the following: <?php $data = array( 'test' => 'Hello World!' ); header('Content-Type: application/json'); echo json_encode($data); But when I build my app and request the JSON after loading the first view, I don't get a response. Maybe I am missing something. The example URL from GitHub works as expected. Do I have to be more specific with my JSON objects and do you think this is a good solution for handling data in general? Regards, Andreas
  2. isn't it just treat it as plain text string, and the db field declare as, let say varchar type
  3. I'm developing a module to integrate BigCommerce's Stores API (https://developer.bigcommerce.com/api) with PW. After a steep learning curve, I managed to use composer.json to download the latest version of the API into a 'vendor' directory. { "name": "processwire/processwire", "type": "library", "description": "ProcessWire CMS/CMF", "keywords": [ "cms","cmf", "content management system" ], "homepage": "https://processwire.com", "authors": [ { "name": "Ryan Cramer", "email": "ryan@processwire.com", "homepage": "https://processwire.com", "role": "Developer" } ], "require": { "php": ">=5.3.8", "ext-gd": "*", "bigcommerce/api": "*" }, "autoload": { "files": [ "wire/core/ProcessWire.php" ] }, "minimum-stability": "dev" } Using composer.json and its autoload.php feature works great. All I need in my template is: <?php use Bigcommerce\Api\Client as Bigcommerce; Bigcommerce::configure(array( 'store_url' => 'https://www.mybigcommerceshop.com', 'username' => 'admin@mybigcommerceshop.com', 'api_key' => '8fab84ce1776dbba18665xxxxxxxxxxxxf' )); $ping = Bigcommerce::getTime(); if ($ping) echo $ping->format('H:i:s'); My dilemma is that the files are in './vendor', not './site/modules'. Not everyone will use composer.json so looking for recommendations on how to best code the module to first look in './vendor', then if nothing there, look into './site/modules/BigCommerceApi/Api' to load the files (which may be out of date) and instantiate the API. Suggestions? Using: PW v3.0.24
  4. We're recently completed a sizable project for Qatar Racing (www.qatarracingltd.com). This was a bespoke build pulling in a JSON feed of horses from a 3rd party. This feed was then incorporated into a members area where members could comment and reply on horses, effectively a full messaging app. Qatar Racing (www.qatarracingltd.com)
  5. Hi Folks, I am currently building an angular app for creating and displaying polls/surveys: http://embed.plnkr.co/seQfprxQRvjg84bvi2Dy/ The data that needs to be stored in PW comes from JSON and looks like { "title": "My Survey", "questions": [ { "id": 1, "title": "First Question", "answers": [ { "id": 1, "title": "Answer 1" }, { "id": 2, "title": "Answer 2" } ] } ], "file": { "$ngfName": "long-beach-koh-payam.jpg", "$ngfOrigSize": 351901, "$ngfBlobUrl": "blob:http://localhost:8000/8b87de97-549a-4900-8579-71a0d87a9258" } } Now I need to decide how to best store that data with PW. I am also using Angular to build the forms where users can submit the poll from the JSON that is produced by the survey builder. So I would like to create 1 page per poll. The template holds title field, an image file field and one field that stores the data as JSON string. To me this seems an easier approach than having child pages for each question in the poll and again child pages for each answer to a question. Do you see any disadvantages that this approach might bring? And which field type should I use to store the JSON string, textarea?
  6. Hi, I have a JSON feed that I need to grab and update some pages and fields within ProcessWire. I've created a template with my code that I am going to use. I have fallen at the first hurdle though. I need to first select the pages that are using my specific template as those are the ones that I need to update with the JSON data. When I do this: $my_pages = $pages->find("template=my_template"); Error: Call to a member function find() on a non-object Could someone point me in the right direction? Thanks!
  7. Hi, We're looking for a PW freelancer (preferably based around Gloucestershire/South West - but will consider further afield) to build the front-end for a PW site we're currently building. The site has been designed (files available) and prototyped. Currently we are building the backend (members) area which pulls in a JSON feed and stores it in PW. This information is then shown to the Members. A restricted view of the data is shown to the public. Timescales for this project are to go live on W/C 18th April. Please post here with contact details and website URLs and I will contact you. Many thanks Pete Jones Head of Digital www.jfd.co.uk
  8. Hi folks, I want to pass some PHP arrays to JSON. I am managing to do this fine but the issue is that it wraps [] round the array, whereas I need it without [] to use it as geojson within Mapbox (https://www.mapbox.com/mapbox-gl-js/example/popup-on-click/). <?php $programme_array = array(); $programmes = $pages->find('parent=programme, sort=sort'); foreach ($programmes as $programme) { $title = $programme->title; $url = $programme->url; $summary = $programme->programme_summary; $image = $programme->programme_venue_image->url; $long = $programme->programme_location->lng; $lat = $programme->programme_location->lat; $programme_array[] = array( 'type' => 'Feature', 'geometry' => array( 'type' => 'Point', 'coordinates' => [$long,$lat] ), 'properties' => array( 'title' => $title, 'description' => $summary, 'image' => $image, 'url' => $url, "marker-symbol" => "music" ), ); } $programme_json = json_encode($programme_array, true); ?> [{"type":"Feature","geometry":{"type":"Point","coordinates":["-1.466439","53.376842"]},"properties":{"title":"Site Gallery","description":"Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Donec id justo. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Suspendisse feugiat. Etiam rhoncus.","image":"\/Freelance\/art-sheffield-2016\/site\/assets\/files\/1032\/site_gallery.jpg","url":"\/Freelance\/art-sheffield-2016\/programme\/site-gallery\/","marker-symbol":"music"}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-1.477881","53.374798"]},"properties":{"title":"Moore Street Substation","description":"","image":null,"url":"\/Freelance\/art-sheffield-2016\/programme\/moore-street-substation\/","marker-symbol":"music"}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-1.459620","53.380562"]},"properties":{"title":"S1 Artspace","description":"","image":null,"url":"\/Freelance\/art-sheffield-2016\/programme\/s1-artspace\/","marker-symbol":"music"}}] Any thoughts? I know this is perhaps more PHP/JSON related question than a PW question but I just wanted to make sure I had this set up correctly.
  9. Hi, is there actually a function in Processwire to create forms from a JSON array with corresponding attributes, so that something like { "title":"Duck Count", "type": "InputfieldInteger", "label": "How many ducks?" },{ etc ... } would become a form with all the fields? Otherwise it would be a nice-to-have I guess? I will give it a try for a module now - could be enhanced then. Or has anyone already build something like that? cheers, Steffen
  10. MuchDev

    JSON Sitemap

    Hey guys, I know this isn't really a how to, but I am currently working on a system to inline above the fold css and was needing a json pagelist, and figured I would write something to automate it. I included the ability to flatten the tree or keep it expanded. There is also a filter section where you can exclude individual pages by path, parent, id, or template. This is all pretty bare bones and will pretty much just gives you a json array of your page paths, but that is all I needed. This is working code but you will need to clear out the filters for your own site. <?php /* * JSON SITEMAP GENERATOR * By Sam Fleming -- MUCHDEV * This will create a json sitemap for grunt or other purposes * * option includes flat / expanded. Use however you need * * apply whatever filters you need to exclude in the filter array * curently supports excluding by: * Path * Parrent * ID * Template */ ########################################################### ## SET HERE IF YOU WANT AN EXPANDED OR FLATTENED SITEMAP ## ########################################################### $flatten = true; ########################################################### ## YOUR PAGE FILTERS GO HERE ## ########################################################### $filters = array( "paths" => array( "/processwire/" ), "parents" => array( "3211", "5", "55", "98745" ), "ids" => array( "1123", "5985", "321454", "15885", "321115", "39" ), "templates" => array( "template1", "template2" ) ); function buildSitemap($flatten) { $home = wire('pages')->get('/'); $urls[] = $home->httpUrl; $urls[] = getChildren($home->children); if($flatten){ $flatArray = arrayFlatten($urls); return json_encode($flatArray); }else{ return json_encode($urls); } } function getChildren($pages){ foreach($pages as $page){ //iterate through all the filters in array, and if the type matches then set flag to true $flag = false; foreach($filters as $filter){ switch($filter){ case "paths": foreach($filter as $path){ if($page->path == $path) $flag = true; } break; case "parents": foreach($filter as $parrent){ if($page->parrent == $parrent)$flag = true; } break; case "ids": foreach($filter as $id){ if($page->id == $id)$flag = true; } break; case "templates": foreach($filter as $template){ if($page->template == $template)$flag = true; } break; } } if(!$flag) $urls[] = $page->httpUrl; //if page has children then recurse if($page->numChildren){ $urls[] = getChildren($page->children); } } return $urls; } function arrayFlatten($array) { $return = array(); foreach ($array as $key => $value) { if (is_array($value)){ $return = array_merge($return, arrayFlatten($value)); } else { $return[$key] = $value; } } return $return; } echo buildSitemap($flatten); ?>
  11. Hello, I need to connect two PW sites, both with rather big pagetrees. When adding a page to site A, the editor should be able to select one or more related pages from site B (one is an editorial news site, the other a product cataloque) My idea was to build an API for site B which writes JSON data of the applicable pages and feed that into my custom inputfield which would be heavily influenced by PageListSelect. Now my questions: Has anyone built something similar? Since this would be my first custom field / inputfield, where should I look for help? Does this sound like a reasonable approach or are there other ways to connect two PW sites? Thanks for any help, thomas
  12. I have a rather unusual need. I need to have two fields in my template that show the parent and grandparent of the actual page in a plain (readonly) text field. Let me explain. My tree is as such: - State - City - Point of Interest At runtime, it's easy to retrieve the city and state of the point of interest with $page->parent and $page->parent->parent respectively. But what I'd like to have two fields that show the actual output of those queries directly in the editor. For example: City: Hoboken, State: New Jersey. The main reason is that I'm trying to output these two fields in JSON (using Christian's WebServiceTemplate) so that an app developer can grab these results without making two extra calls to the database. A hook would probably do it, but I don't know how to achieve it. Any help would be greatly appreciated.
  13. Hello, I remember recently using processwire's built-in json API in one of the dev builds. I can't seem to find any kind of documentation of that now. Since I switched my machine, I can't even find that code again.(I've been searching for hours) Can anyone please point me or provide me any clue about the above said json api? It worked something like this: If you need to find any pages using template basic-page, you can get it as follows: http://example.com/processwire/?template=basic-page hit above and it'll return the json output. Thanks.
  14. Hello, I recently discovered this tool http://www.kimonolabs.com/ that let you turn a website into an API. So far so good. I'm trying to imagine how to deal with json in PW. I'd like to output the data on a single page. What's the best way of doing this?
  15. My client got their web hosting from a terrible company who poses as IT consultants but really just act as middle men, reselling the cheap web hosting they purchase from a legitimate company... it is VERY frustrating. Anyways, my site won't load and gives the errors that it can't find the json_decode() function. I tried installing a fresh PW, and the checks gave the errors that json support and the php was slightly outdated. but in the end it installed, but got errors on load. same as when I load my pages. So, is there a way to hack pw so that it doesn't require json support? I tried asking the "IT Consultants" to install json, but they wouldn't. I even gave them the list of command that would do it for them. They obviously don't even have root access to their servers. so lame.
×
×
  • Create New...