Best way to handle saving an item as a favorite
By
ZionBludd, in Getting Started
-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By 997 998 999
Hello,
I'm trying to edit the field of a page with a value from a javascript fetch post request but I can't get the
file_get_contents("php://input") or
$_POST value in my PHP file.
I created a `update` template and a `update` page (to allow access from fetch request and avoid 404/403/... errors) containing this code :
$data = file_get_contents('php://input'); echo $data; # test edit the page field with random value #$home = $pages->get("/"); #$home->of(false); #$home->testfield = "test value"; #$home->save(); # test fetch response with random value #echo "test fetch response"; That I fetch request with my client javascript like this :
fetch('/update', { method: 'POST', body: 'test' }) .then(function(response) { return response.text(); }) .then(function(data) { console.log(data); }) .catch(error => console.log('error')) } The field edit works fine and I get the test response from the `update` file but I can't get the posted value, I only get `<empty string>`. It is working fine outside of ProcessWire so I guess this is related to how PW handle $_POST ?
I found this post where it seems to be working :
Is there any way to get post value from javascript fetch request? What am I doing wrong?
Thank you
-
By dimitrios
Hello,
this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
Minimum Required Facebook App configuration:
on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version (has been tested up to v3.3), add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "https://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
Usage
edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
Download
PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost Note: Facebook SDK for PHP is utilized.
-
By jds43
Hello,
I have a search page loosely based on Skyscrapers where I'm parsing a selector with options 'beds', 'bathrooms', 'size' fields. It is working well until I select 'Any' after I've run a search. This is where no results are returned (/?beds=&bathrooms=&size=&submit=). I want it to reset and show all results.
I hope this isn't too vague.
-
By iipa
Hello forum!
I have a site, where I want to remember two settings defined by user:
1) Theme (light or dark)
2) Language (Finnish or English)
Because user makes changes to these settings on client side, I am a bit lost with how can I save them in ProcessWire $session variable? I would like to use $session for more reliable saving, and since it is only two variables I will use, I doubt it will become too resource-needy.
I have tried using jQuery's post() -method referring to a file in Templates folder (theme.php), but I get 403 Forbidden Error. I don't like the idea of trying to post to same file user currently is in, which is why I thought having a separate file would be good in this.
Contents of theme.php:
<?php namespace ProcessWire; header('Access-Control-Allow-Origin: https://domain.com'); $theme = $input->post['theme']; if(!empty($theme)) $session->theme = $theme; ?> Long story short: Does anybody have any pro tips I could use with setting and getting $session variables?
-
By pwFoo
With JS fetch() it is a bit tricky to get for example $_POST populated (params need to be FormData / forms), but would it possible to get PW $input (get, post, urlSegments, queryString) working for fetch requests?
Is there a fix / hook / workaround to solve it PW side?
-