Jump to content

Can

Members
  • Posts

    350
  • Joined

  • Last visited

Everything posted by Can

  1. hey guys I'm sorry for being away for such a long time and am unfortunate to say that I'm not able to maintain any of my modules at the moment as I'm not doing any php / pw at the moment myself and don't have a working php/mysql environment locally right now to do anything "quickly" but I would be open and happy if someone else wants to take over any of my processwire modules, by any way, for example by transferring the repo to a new home to have it redirect old links, or you could just upload yourself and i'll include a message in my repo readme and here in the thread @strandoo maybe you are interested in taking over? than you could easily include your suggestions which sound good or just publish yourself and I'll link yours (just a thought, no pressure of cause!) greets
  2. haven't tested it but you should be able to replace this $value->getLanguageValue($user->language) with this $value
  3. @Slav only this gist https://gist.github.com/CanRau/662a559a07d6d7c492159d1cd497944f
  4. @ngrmm just bumped the version to 0.3.2 including a little fix so it show up again, please let me know if it works @CalleRosa40 Just checked on pw 2.8.62 and 3.0.62, cookies are created as expected..have you checked console in dev tools? it should show something..and it could be interesting to check network tab in dev tools, too, to see if it actually sends the ajax request
  5. Could you solve it? Have you tried disabling ajax? I'm really short on time at the moment :/
  6. great info thanks @kixe and @Robin S logging out could be an option..could be a little confusing though..maybe combined with some notification..thought an extra input would be more understandable
  7. Hey guys, I'm building a module to keep a user logged in until manual logout. I know about Login Persist, but this one stopped working for me a while ago and it might not even be compatible with pw3 (haven't tested this) as it's not being updated for 3 years Anyways, the module works, and now I want to secure user edit screens namely ProcessPageEdit (any user template, as there might be multiple) and ProcessProfile by requiring the current password.. I know how to add the additional input (added by hooking into ProcessProfile::execute and ProcessPageEdit::buildForm or Page::render) but I don't know how to intercept the saving and canceling the save if password doesn't match I thought about emptying $input->post (don't even know if this works?) if not valid but would be nice not to loose the changed data but instead just notify user about a wrong password.. would love to get some thoughts and input on this
  8. interesting approach thanks for sharing think the first subselector could be a nice addition to simplify things ;-)
  9. would love that too, could use it on a table field to know while searching if the first/last entry matches
  10. $user = $users->get("email=".$input->post->email('email')); this will email sanitize the email input field value combining WireInput and WireSanitizer ;-)
  11. great idea..thinking about playing with jasonette too but lend my phone to a friend for some days^^ tried you rss reader..home screen is loading but none of the feeds is...loading icon circles infinite?
  12. you don't need another template..you can use urlSegments for this and then if /amp/ is appended to the url you output amp content..without the url segment you can then output normal html which is recommended (to have both)
  13. haven't checked this threat actually, but as far as i understand i'm doing the same?! ;-)
  14. if anyone wants to allow e-mail and name in admin login with PW 3.x (and i guess 2.8) the module from @mindplay.dk wasn't working for me, i guess because ProcessLogin::execute is not pageName sanitizing the name.. this one works for me (PW 3.0.51) and allows either name or e-mail (you could change the name label to reflect this too of course) // change login name input label to e-mail-address $wire->addHookAfter('ProcessLogin::buildLoginForm', function(HookEvent $event) { // on liner as we don't change anything else $event->return->get('login_name')->set('label', $event->_('E-Mail-Address')); }); // hook into session::login to get user by mail $wire->addHookBefore('Session::login', function(HookEvent $event) { // need to get email from $input as processLogin::execute is pageName sanitizing $email = $event->input->post->email('login_name'); // stop here if login_name not a valid email if (!$email) return; // new selector arrays don't seem to work on $user so using $pages here $user = $event->pages->get([['email', $email]]); // if valid user set login name argument if ($user->id) $event->setArgument('name', $user->name); }); i've got those in a _hooks.php included in my site/init.php but you could of course outsource it into a separate module etc..
  15. as far as I know (never used it so far) it works on newly created files only (so after enabling pagefileSecure) and changes file urls, think by adding a hyphen or something which I guess .htaccess blocks already..have a look at wire/config.php excerpt: /** * Secure page files? * * When, true, prevents http access to file assets of access protected pages. * * Set to true if you want files on non-public or unpublished pages to be * protected from direct URL access. * * When used, such files will be delivered at a URL that is protected from public access. * * @var bool * */ $config->pagefileSecure = false; /** * Prefix for secure page files * * One or more characters prefixed to the pathname of secured file dirs. * * If use of this feature originated with a pre-2.3 install, this may need to be * specified as "." rather than "-". * */ $config->pagefileSecurePathPrefix = '-'; to get it working you need to block access by guest role for those templates, have a read at https://processwire.com/talk/topic/5292-proctecting-files-from-non-logged-in-users/ might be of interest: https://processwire.com/talk/topic/15622-pagefilesecure-and-pageispublic-hook-not-working/
  16. hey guys..just stumbled upon this and i think it might be interesting, at least worth a read ;-) https://medium.freecodecamp.com/how-to-build-cross-platform-mobile-apps-using-nothing-more-than-a-json-markup-f493abec1873#.az40aujdt
  17. ookay..just entered title in name format for children and modify it from the setupNew hook thanks to you @Robin S
  18. Hola amigos, I'm trying hard to auto generate page names for certain templates no matter if they're created using admin ui or api tried various hooks I hacked myself and copied stuff from and kixes module module I tried the following in site/init.php $wire->addHookBefore('Pages::setupNew', function(HookEvent $event) { $page = $event->arguments[0]; // if($page->is('comment')) { $page->name = 'the-page-name-you-want'; // } }); $wire->addHookBefore('Pages::setupPageName', function(HookEvent $event) { $page = $event->arguments[0]; // tried with and without template check if ($page->is('comment')) { $event->replace = true; $name = 'autoname'; $event->return = $name; } }); the second hook, if i get it right, might only fire via api if no name is provided (right?) for the setupNew hook Ryan mentions "if the page doesn't have a name yet" but it seemed to work for netcarver.. what am I missing here? And in this case I want to bypass the name form completely (I already stripped the title field on this template).. UPDATE: so ___setupNew seems to work but wont bypass the page name form..so I have to provide a name, hit save and then on the page edit screen it changed to the one form the hook...how can I go straight to page edit screen after clicking on new page like when a name format is entered for children ProcessPageAdd::processQuickAdd?
  19. old topic i know but the title fits exactly so... i would love to request "repeater inside itself" again and would suggest to limit it to one level... i'm actually building something using repeater matrix but guess that doesn't matter too much for this (might be wrong) so you could have one matrix type which has one field (itself, field is called "content") when you then use this field in page editor and create a new matrix item of type content...you won't be able to add another content item inside of it but only all other types that would be awesome for building flexible columns without cluttering each item with a whole load of fields.. EDIT: okay my fault...i knew there is is depth already and i played a little with it..and i'm sure i'll get it working using depth EDIT2: think i got it now
  20. you either leave the namespace or need to prepend all php function like RecursiveDirectoryIterator with an \ backslash like \RecursiveDirectoryIterator so it knows this function is not in the ProcessWire but in the root namespace..
  21. you could also copy the module into you site/modules/ directory, edit to your needs and then in processwire module settings of this inputfield select the one from your site/modules, just refresh module cash and it'll note about two possible files for this module anyway ;-) more about this in the blog https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-copies-of-the-same-module
  22. thanks for mentioning @LostKobrakai good to know right markupcache was the thing I was thinking about @adrianmak glad you solved it yourself, actually I forgot that I got my ready.php kind of split, first code blocks are intended to run on back and front end, like save hooks and stuff, then i got this code if ((strpos($page->url, wire('config')->urls->admin) !== false) || ($page->id && $page->is('parent|has_parent=2'))) return; i think i found this or something similar somewhere in the forums, am not entirely sure if the second part is really needed as the first part checking if url contains admin path (usually processwire) you could extend it by placing / before and after and I don't know if there are any possibilities of admin pages not containing admin url.. anyway, everything after this line will only run on front end..
  23. glad you solved it $cached is not being saved to cache, my code example might not be the most logical but it's short ;-) WireCache->save("cacheName", "data") so we directly save $event->return to cache and not $cached shortest way to achieve what you what would be if (!$cached) { $event->return .= "<!--cached page-->"; $cache->save($cacheName, $event->return); } or even if (!$cached) { $cache->save($cacheName, "$event->return<!--cached page-->"); } edit usually flat files are faster, this one is just using the easiest way as everything is already there with WireCache but as I said you can replace it quite easily with some flat file logic, but you would need to alter cache name too.. easier and more efficient would then be to use ProCache as it uses flat files and bypasses any php mysql serving just static files
  24. you define the cache name above/outside of the functions, like in my example right? It should actually work.. uh I'm quite sure you need to wrap $config->prefix in curly braces like so "{$config->prefix}__$page->id-$page->template-{$user->language->name}"; without them php thinks the two underscores are part of the variable but there is no variable called $config->prefix__
  25. as mentioned above, wirecache uses database tables so you have to go to adminer or phpmyadmin (or similar) and check out the caches table of your page to see cached content, and you could change the page content before caching by e.g. adding a "cached" class to body or html tag sidenote: there is template cache and I think some predecessor to wirecache which use file based cache using the hooks you could implement your own caching logic/system, for example writing the page markup to a file using file_put_contents() and the before hook could check for the existence of the file and then file_get_contents() output it..
×
×
  • Create New...