Jump to content


  • Posts

  • Joined

  • Last visited

Recent Profile Visitors

1,054 profile views

nicolant's Achievements

Jr. Member

Jr. Member (3/6)



  1. Solved following BillH's advise: $p->icon->first()->set("modified", time()); $p->save("icon"); But it started to work only after addition of the last line! Thank you!
  2. But when I, for example, upload an image in CMS to that field (set to 1 image only), I can check later $icon->modified and it changed. It can be read on field instead of individual file it contains, why cannot it be overwritten?
  3. If I change code to: $pp = $page->find(); foreach ($pp as $p) { if ($p->icon && $p->icon->count() > 0) { $p->icon->set("modified",time()); } $p->save(); $cache->deleteFor($p->id); } It gives error: Item 'modified' set to ProcessWire\Pageimages is not an allowed type
  4. Please help me to figure out, how to set modified timestamp for PageFiles inside hook. Specifically, I need to mark all files fields in a page and its children as updated on save of that page. $files->modified = time() doesn't work. The only way I have found to modify it is to call $file->install() method on each PageFile. It does the job but duplicates files...
  5. Thank you @mtwebit for that module! But I have a trouble with processwire setup with two site folders: "site" and "site-users". Tasker module is installed in site-users/modules folder. How to force processwire to load that modules instead of site/modules? Because runByCron.sh can't find Tasker module: require "index.php"; if (!wire('modules')->isInstalled('Tasker')) { echo 'Tasker module is missing.'; exit; } Nikolay. SOLVED: By addition of $_SERVER['HTTP_HOST']=$siteDomain; before index.php
  6. It remembers userId after login, but not on next reload of content, when if(wire('user')->isGuest()) in Auth.php returns true. Instead in auth() it should again read userId from token, but since $decoded variable is available only in Router... EDIT: It seems that retrieved JWT should be kept in sessionStorage entirely client-side. In order to do that I'd have to use VuexPersist plugin. I'd have to move setting of authorization header (in my case, axios.defaults.headers.common['Authorization'] = 'Bearer ' + this.$store.state.jwt) from mutations.js to Content.vue. Not sure though that it's an elegant way. I forked your repo with modifications here: https://github.com/nicolant/RestApiProfile
  7. Thank you for the profile. I'm trying to move client vue part to another domain. In order to do that, i had to make a few modifications: to Auth.php: public static function preflight() { return "OK"; } to Router.php: header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers: Authorization, Content-Type'); . . $r->addGroup('/auth', function (\FastRoute\RouteCollector $r) { $r->addRoute('OPTIONS', '', Auth::class . '@preflight'); . . $r->addGroup('/test', function (\FastRoute\RouteCollector $r) { $r->addRoute('OPTIONS', '', Auth::class . '@preflight'); and change axios.defaults.baseURL but after login it stays as "guest" (User logged in: guest) It seems that it's impossible to use session (wire('session')->login) in that situation. Could you advice how to pass and re-use, for example, user ID, bypassing processwire session (may be through encoding it with JWT)? Nikolay
  8. Strange behavior in page select field: select links disappear immediately on hover. Please help to fix!
  9. I'm trying to replace default templates for "templates" CKEditor plugin (in site folder) without any luck. My installation runs templates.js from "dialogs" folder (from wire folder). I have seen others have same problem: Please, help. Nikolay Antoshenkov P.S. Just have found solution: Added line config.templates_files= ['/site/modules/InputfieldCKEditor/plugins/templates/default.js']; to config.js
  10. Ryan, thank you for your efforts. I wonder how do you find a time to answer all the questions! You're right, but I'm planning to add separate "Share" button next to "Save" (or checkbox would even better, I think. By the way, could you direct please how to do that?), and in that case I may press and may not press it, and it would be strange to have a FB login page popping anyway beforehand ( I'm still in the beginning of learning facebook API, and it seems that I have to pass through login page before first manipulation with facebook).
  11. Ryan, thank you! That's the point! But now I have to move all the action to the init method. Is it possible to get there an object of page being edited or I have to save it in the session? Code now looks like this: <?php class MySocialIntegration extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'My Social Networks Integration module', 'version' => 010, 'summary' => 'An example module', 'singular' => true, 'autoload' => true, ); } public function init() { require_once 'facebook-php-sdk/src/facebook.php'; $this->facebook = new Facebook(array('appId' => 'xxxx','secret' => 'xxxx')); $user = $this->facebook->getUser(); if ($user) { try { $user_profile = $this->facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } $this->session->fb_user=$user; if ($user && $this->session->fb_action) { $this->postToFacebook(); } $this->pages->addHookAfter('save', $this, 'afterSave'); } function postToFacebook() { $this->session->remove('fb_action'); $this->message("Facebook: post "); } public function afterSave($event) { $page = $event->arguments[0]; if (($page->template == "portfolio-image") || ($page->template == "portfolio-video")) { if ($this->session->fb_user) { $this->postToFacebook(); } else { $this->session->remove('fb_user'); $this->session->fb_action=1; $loginUrl = $this->facebook->getLoginUrl(); $this->session->redirect($loginUrl); } } } }
  12. Hi. I'm trying to implement ability to post to Facebook after saving a page like this: <?php class MySocialIntegration extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'My Social Networks Integration module', 'version' => 010, 'summary' => 'An example module', 'singular' => true, 'autoload' => true, ); } public function init() { $this->pages->addHookAfter('save', $this, 'afterSave'); } public function afterSave($event) { $page = $event->arguments[0]; if (($page->template == "portfolio-image") || ($page->template == "portfolio-video")) { require 'facebook-php-sdk/src/facebook.php'; // Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array( 'appId' => 'xxxxxxxxxxx', 'secret' => 'xxxxxxxxxxxxxxxxxxx', )); // Get User ID $user = $facebook->getUser(); // We may or may not have this data based on whether the user is logged in. // // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } // Login will be needed depending on current user state. if ($user) { $this->message("Facebook: connected!"); } else { $this->message("Facebook: redirects..."); $loginUrl = $facebook->getLoginUrl(); $this->session->redirect($loginUrl); } } } } If I'm not logged, it's redirecting to facebook login page, and after successfull login redirects back, but $facebook->getUser() still returns 0 (and also on consequent executions). If I do the same in separate php file (changing $this->session->redirect to header('Location: '...), works lika a charm. Help, please!
  • Create New...