
abdus
Members-
Posts
743 -
Joined
-
Last visited
-
Days Won
42
Everything posted by abdus
-
Filter out past events when using pageReference field (front end)
abdus replied to a-ok's topic in General Support
You want find() not filter() (I don't think it even exists) -
Permissions to show only one custom admin page to a role
abdus replied to nixsofar's topic in Getting Started
Create a permission called `mymodule-view`, add it to `editor` role, then in your module add a `permission` property like this class ProcessSimpleAdminPage extends Process { public static function getModuleInfo() { return array( 'title' => 'Process Simple Admin Page', 'summary' => 'Simple Process module that adds new admin page with', 'version' => 001, 'permission' => 'mymodule-view', 'permissions' => [ 'mymodule-view' => 'Can use my module' ] ); } Additionally, you can also add `permissions` property which will create the permissions for you when you install it. -
This is the part that checks session challenge: // Session.php protected function ___isValidSession($userID) { $valid = true; $reason = ''; $sessionName = session_name(); // check challenge cookie if($this->config->sessionChallenge) { if(empty($_COOKIE[$sessionName . "_challenge"]) || ($this->get('_user', 'challenge') != $_COOKIE[$sessionName . "_challenge"])) { $valid = false; $reason = "Error: Invalid challenge value"; } } // ... } I'm guessing it was a one time issue, and somehow user id and its challenge got corrupt/mismatched, which prevented you from logging in. Enabling sessionChallenge again probably will not cause errors anymore once challenge is reset properly. Otherwise there's something wrong with sessions or $_COOKIE isn't set properly, deleting site/assets/sessions/ directory or restarting php service might help
-
If it's hindering your work, you can temporarily disable session challenge by setting $config->sessionChallenge = false; in site/config.php, but it will be less secure.
-
Do you have a cookie set by the name "wire_challenge"? wire_challenge:"qQD3i99Juyx%2Fgpq%2F5PVrGjtRfDCgW37V"
-
The error is output when PW cannot verify session challenge cookie. Try clearing your cookies. On Chrome F12 > Application > Clear Storage
-
Perhaps prepend urls with $page->rootParent->httpUrl? (I haven't used multisite before) Can you post a screenshot of your page tree? Or the output from your code vs how you want it?
-
If you dont want to show pages from other domain roots, you can add has_parent to limit returned pages to one domain only https://processwire.com/api/selectors/#finding2
-
I don't think preventing 404s is a good idea. You can show an explanation + suggest some pages with keywords from the URL, or your popular pages etc. on 404 page too. https://moz.com/blog/are-404-pages-always-bad-for-seo
-
Hmm, you're right. Scripts are output inside <head> during page load. Then it's developer's responsibility to make sure that inputfields are initialized correctly. This requires a <script> tag to be appended to inputfield markup, which sets up the inputfield with given ID. This would also mean having to save the state somewhere (data attributes, ProcessWire.config etc) to prevent initializing an inputfield twice. Or using a library to listen to DOM mutations and initializing the inputfields inside. https://github.com/muicss/sentineljs I agree that a guideline/tutorial from @ryan would be great.
-
True, but still, inside InputfieldWrapper.php where a field is determined to be rendered with ajax or not, it calls renderReady(), it has no effect because Inputfield::renderReady() still uses $config->styles and $config->scripts (via Modules::loadModuleFileAssets() method), and only the inputfield markup is output to the browser. // InputfieldWrapper::renderInputfield $inputfield->renderReady($this, $renderValueMode); // ... if($ajaxID && $ajaxID == $inputfieldID) { // render ajax inputfield $editable = $inputfield->editable(); if($renderValueMode || !$editable) { echo $inputfield->renderValue(); } else { echo $inputfield->render(); echo "<input type='hidden' name='processInputfieldAjax[]' value='$inputfieldID' />"; } exit; } // Inputfield.php public function renderReady(Inputfield $parent = null, $renderValueMode = false) { if($parent) {} if($renderValueMode) {} $result = $this->wire('modules')->loadModuleFileAssets($this) > 0; if($this->wire('hooks')->isMethodHooked($this, 'renderReadyHook')) { $this->renderReadyHook($parent, $renderValueMode); } return $result; } // Modules.php /** * Load module related CSS and JS files (where applicable) * * - Applies only to modules that carry class-named CSS and/or JS files, such as Process, Inputfield and ModuleJS modules. * - Assets are populated to `$config->styles` and `$config->scripts`. * * #pw-internal * * @param Module|int|string $module Module object or class name * @return array Returns number of files that were added * */ public function loadModuleFileAssets($module) {}
-
For inputs that are loaded without ajax, scripts work fine, because they're served inside the whole page markup But for ajax inputs that's not the case. Here's the response to an AJAX request. I removed class, id, name, and for attributes because they were taking up too much space. The only script is at the end which initializes tabs and submit buttons.
-
For inputs that are loaded without ajax, scripts work fine, because they're served inside the whole page markup But for ajax inputs that's not the case. Here's the response to an AJAX request. I removed class, id, name, and for attributes because they were taking up too much space. The only script is at the end which initializes tabs and submit buttons.
-
Call to undefined function wire() with Ajax
abdus replied to entschleunigung's topic in Getting Started
@szabesz in templates, sure, using return $this->halt() is a better solution, but in functions or classes or anywhere outside template context, there's no option but to exit; or die; to stop PHP from processing further. -
I'm having the same issue. It appears that this happens because Repeater fields add new items using AJAX, and InputfieldAceExtended loads its scripts with $config->scripts in render() method. But it doesnt work as PW does not consider rendering the scripts in $config->scripts when loading an input with AJAX. Quick solution is to append <script> and <link> or <style> tags after inputfield markup. From a quick search, native and profields don't seem to have this issue because they use the scripts that are loaded on backend by default. I think solution is up to @ryan at this point. When rendering the field PW should output scripts & styles too. // InputfieldWrapper.php public function ___renderInputfield(Inputfield $inputfield, $renderValueMode = false) { // ... if($ajaxInputfield) { $inputfieldID = $inputfield->attr('id'); if($ajaxID && $ajaxID == $inputfieldID) { // render ajax inputfield $editable = $inputfield->editable(); if($renderValueMode || !$editable) { echo $inputfield->renderValue(); } else { echo $inputfield->render(); echo "<input type='hidden' name='processInputfieldAjax[]' value='$inputfieldID' />"; // Get scripts from $this->config->scripts and output to browser } exit; //...
-
Is it possible to add actions to search box? Like when using Word, pressing Alt + Q will activate "Tell Me" feature which lets you search actions directly similar to Spotlight Instead of delving into dropdown menu, we can just type in "install" and it suggests you "Module Install" page & tab, or "field" suggests "add field" etc.
-
That's really old, like from 2006 old. If you know programming basics (conditional statements, loops, functions etc) it will get you very far before you need something more. To get you started on PHP: http://php.net/manual/en/ https://www.tutorialspoint.com/php/ https://www.tutorialspoint.com/php7/ https://github.com/EbookFoundation/free-programming-books/blob/master/free-programming-books.md#php
-
Wow I've started using it and I'm really impressed with how fast and responsive it is. Tab switching and startup is instant. On my PC, Chrome lags when scrolling on YouTube or on some sites occasionally, but on Quantum, everything feels buttery smooth. Design is quite nice and not in our face. RAM usage is way lower than Chrome, too. It'll be released on November 14, but a beta and dev edition is available if you want to test and see for yourself. https://www.mozilla.org/en-US/firefox/quantum/
-
Ups! Ich habe das nicht bemerkt. Having a way to tap into install routine would be great though. Maybe in the next topic.
-
Was this meant to read empty or unique? You want to select all records whose a certain text field is empty or has unique values? There isn't a selector option to filter pages by unique value, but you can do something like this <?php namespace ProcessWire; $empties = $pages->findMany("template=record, textField=''"); $fulls = $pages->findMany("template=record, textField!=''"); $uniques = new PageArray(); $fieldValues = []; foreach ($fulls as $record) { if (in_array($record->textField, $fieldValues)) continue; $uniques->add($record); } $uniqueOrEmpty = $empties->import($uniques);
-
Perhaps a pw-bootstrap.php that could be run after the installation? <?php return [ 'installs' => [ 'FieldtypeRepeater', 'InputfieldPageAutocomplete', 'AdminThemeUikit' => 'https://github.com/ryancramerdesign/AdminThemeUikit/archive/master.zip' ], 'fields' => [ ['body' => ['type' => 'textarea']], ['views' => ['type' => 'integer']], ['products' => ['type' => 'table']] ], 'templates' => [ ['post' => ['label' => 'Post']], ['blog' => ['label' => 'Blog']], ['listing' => ['label' => 'Product Listing'], ['product' => ['label' => 'Product', 'urlSegments' => 1]] ], 'pages' => [ '/blog/' => ['template' => 'blog'], '/blog/test-post/' => ['template' => 'post'], '/products/' => ['template' => 'listing'], '/products/test-product/' => ['template' => 'product'] ] ]; Which then could be used to perform a quick setup like this: $bootstrapPath = './pw-bootstrap.php'; if (!file_exists($bootstrapPath)) return; $setup = include($bootstrapPath); function installModule($name) {...} function createField($name, $opts) {...} function createTemplate($name, $opts) {...} function createPage($path, $opts) {...} foreach ($setup as $type => $items) { switch ($type) { case 'installs': foreach ($items as $module) installModule($module); break; case 'fields': foreach ($items as $fields => $opts) createField($field, $opts); break; case 'templates': foreach ($items as $template => $opts) createTemplate($template, $opts); break; case 'pages': foreach ($items as $page => $opts) createPage($page, $opts); } } Performing these manually takes at least 10min, but with an automated system it wouldn't take more than 10-20 seconds
-
I almost always regret it when I copy paste some code. It takes many times more to debug than just write the code again / refactor it
-
There's no include statement before $config->paths->site . 'template/include/random-trailers-5.php'
-
Even when you include a file, you still need to declare namespace at the top. Change this to <?php namespace ProcessWire; ?> <section> Also, if /features pages exists, you can just use $pages->get('/features/')->url or $pages->get(<id>)->url instead