Jump to content

kixe

Members
  • Posts

    803
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by kixe

  1. @Robin S Useful textformatter in case of multiline content. If you want to hide text without linebreaks you can also use Core TextformatterMarkdownExtra:
  2. @adrian Thanks for pointing on this. I added a fallback to the standard dechex() function for 64-bit systems. In the rare case that neither the BCMath extension is installed nor the system can handle 64-bit integers, the module is not installable.
  3. Once I made a nice Fieldtype for this. Please try out http://modules.processwire.com/modules/fieldtype-button/
  4. With PW this is only possible for subdomains. $this->config->sessionCookieDomain = '.example.org'; This setting includes: example.org subdomain.example.org
  5. Just to clarify: Usually there is only one instance/ object of ProcessWire which is the ProcessWire boot object represented by the variable $wire. ProcessWire is a child class of Wire. Assuming you are talking about all Wire objects the answer is YES and more: // Access to a wire object from inside a wire derived class: $pages = $this->wire('pages'); // Access to the current ProcessWire instance: $wire = $this->wire(); // Create new wire object inside your ready.php $this->wire('ferry', '/site/translations.php'); Read more: https://processwire.com/api/ref/wire/wire/
  6. You can set flags and apply roles allowed to 'view' or 'edit' this field. $field->setRoles(string $type, $roles); // $type = 'edit' or 'view' $field->addFlag(int $flag); $field->removeFlag(int $flag); Reference: https://processwire.com/api/ref/field/ https://processwire.com/api/ref/field/set-roles/ https://processwire.com/api/ref/field/add-flag/ https://processwire.com/api/ref/field/remove-flag/
  7. I have to correct myself. I missed a hook that triggered the 404. Everything is working as expected and as it should work.
  8. Getting wrong header if 404 is triggered inside template file. Calling a not existing page http://example.org/not/existing/page the correct http status header is sent: 404 Page Not Found The following code inside the template file renders properly page with id=27 but sends header 200 OK instead of 404 throw new Wire404Exception(); Would like to see 404.
  9. Tried to add an item to an array, which is a page property. The common way doesn't work. Is there a PHP expert out there who can explain that to me? Thanks. $page->prop = array('a','b','c'); $page->prop[] = 'd'; var_dump($page->prop); // output: array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" } $page->prop = array('a','b','c'); $page->prop = array_merge($page->prop, array('d')); var_dump($page->prop); // output: array(4) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" }
  10. Namespace problem. Somewhere in your files (ready.php?) the namespace ProcessWire is defined. You need to remove this. Don't mix files of installations (PW 3.0.x) using namespace with non namespace installations (PW 2.7 or 2.8)
  11. I tested my code and it works. Maybe there is a namespace issue. Which PW Version do you use? Did you place the code in the right file and folder?
  12. Enable debug mode to get the error messages and figure out the problem. in /site/config.php $config->debug = true;
  13. @PWaddict Thanks https://github.com/processwire/processwire/commit/79fa81d8a87a1d026d8f763021b8df191f48a4e0
  14. If you need this for the backend (result available in frontend too) you can use FieldtypeMarkup for the result. Grab the code from here: https://github.com/kixe/FieldtypeMarkup Create a hook with your formula and place the code in /site/ready.php The result will be populated after saving the page. /** * https://github.com/kixe/FieldtypeMarkup * FieldypeMarkup as concat field with formula * EXAMPLE * */ $wire->addHookAfter('FieldtypeMarkup::formatValue', function($e) { $page = $e->arguments[0]; $field = $e->arguments[1]; // quick exit if ($field->name != 'result') return; if ($page->template != 'calculator') return; $value1 = $page->inputfield1; $value2 = $page->inputfield2; $value3 = $page->inputfield3; $value4 = $pages->get(12345)->inputfield1; // get value from another page $result = $value3 * ($value2 - $value3) / $value4; // formula $e->return = $result; });
  15. Set up a page which just return the cookie banner, put it in an iframe and add it to the other sites. You would have to change (loosen) the x-frame options in your .htaccess file of the framed page to get this work. All-in-all not the best solution.
  16. It looks like PW is searching for PHP\CustomHooksForVariations, but this class doesn't exists. Namespace settings ok?
  17. @Fuzzy Place this code in /site/ready.php Create this file if it doesn't exist.
  18. @Pete This thread should be appended to the support thread of ProcessSetupPageName https://processwire.com/talk/topic/8576-name-format-children/ @pppws Which PHP version doesn't work? which one works? Which module version do you use? Which ProcessWire Version?
  19. You can change the module service url in your config.php file. $config->moduleServiceURL = 'http://modules.processwire.com/export-json/'; $config->moduleServiceKey = (__NAMESPACE__ ? 'pw300' : 'pw280'); Format of the complete url: {moduleServiceURL}/{moduleClassName}/?apikey={moduleServiceKey} Example: http://modules.processwire.com/export-json/MarkupCookieConsent/?apikey=pw300 If you provide this service (json format) for your module by your own you could hook in ProcessModule::execute if ($input->get->update) { $this->addHookBefore('ProcessModule::execute', function($e) { $moduleClassName = $this->wire('sanitizer')->name($this->wire('input')->get->update); if ($moduleClassName != 'MySuperPrivateModule') return; // change service url here $this->wire('config')->moduleServiceURL = 'http://example.com/export-json/'; }); } Another solution: Symlink your module if all sites using this module are hosted on the same server.
  20. For security reasons, a cookie can not be set for a different domain. There may be ways to trigger this, but this could open security holes. The cookie set by this module also applies to subdomains.
  21. @wbmnfktr The reason is the invalid token: https://github.com/processwire/processwire/blob/bdaf8810cbb71944820c45e0b297d0b75f1e60be/wire/core/SessionCSRF.php#L176-L191 Make sure that the session cookie is set and valid and that the current valid token is sent with the form.
  22. All forms in the backend of processwire are secured against CSRF attacks by assigning them a one-time token. This will ensure that the page and the current session that generates the form is the same as the one that receives the form. E. g. The error message appears when a backend page (also Login) is open and the session has expired, or the session cookie has been deleted from the browser or could not be set in the browser.
  23. Try this hook in hook $this->addHookBefore('PageRender::renderPage', function($e) { $event = $e->arguments[0]; $page = $event->object; $user = $this->wire('user'); // QUICK EXIT if ($user->isSuperuser()) return; // superuser if (!empty($page->template) && $page->template->id == 2) return; // backend if ($user->language->isDefault()) return; // default language $language = $user->language; $currentLanguageStatus = $page->get("status$language"); if ($currentLanguageStatus == 0) { $otherPage = $this->wire('pages')->get(1234); // get page to be rendered instead $event = new HookEvent(array('object' => $otherPage)); $e->arguments(0, $event); } });
  24. 1. Use the right sanitizer $email = $sanitizer->email($email); $pagename = $sanitizer->pageName($pagename); // OR $pagename = $sanitizer->pageNameUTF8($pagename); 2. Set adjustName to true in the save options array to make your page name unique $np = new Page() // ... $np->save(array('adjustName' => true));
  25. The banner is always displayed at the bottom of the page. You can limit the appearance to certain pages via module settings. e. g. Do you use iframes for your forms? If yes, each iframe has its own body tag. The banner is prepended to each closing body tag. Disable the banner by module settings (using selectors) for the framed pages.
×
×
  • Create New...