Jump to content

Jo J

Members
  • Posts

    32
  • Joined

Everything posted by Jo J

  1. I vaguely recall this happening to me too. But that was a while back for me to know how it got fixed. Have you tried checking your httpHosts in config is complete? $config->httpHosts = array('localhost','yourdomain.com') or ensure you have the correct index.php & .htaccess that goes with ProcessWire 3.0.229?
  2. I use unix sockets in my dev environment too and am surprised to find just one of you here. I opened an issue to see if it gets in.
  3. I used to do this. Sometime before version 3.0.184. I symlinked just the wire folder inside multiple installations...until I started getting duplicate module errors. I don't remember if it was due to class loading issues or minor differences in file path/directory structure between installations but there was definitely conflicting issues. It could have been cache related too. It didn't work for me.
  4. JSYK, this issue has been fixed by Ryan. His preferred fix also addresses when the #login_start gets stale via cache which is important. Issue #1839 corrects ProcessLogin refresh issue when client and server have different times for UTC/GMT. The fix has been pushed to the current dev branch as of today for continued testing.
  5. I also experienced this issue. Following on netcarver's advice above, it turns out that my device clock is ahead by over 5 minutes. I adjusted my device time & it worked but thought a broader solution might be better. This fixed my issue. var startTime = parseInt($('#login_start').val()); // GMT/UTC // var maxSeconds = 300; // max age for login form before refreshing it (300=5min) var clientStartTime = Math.floor(new Date().getTime() / 1000); var clockDifference = clientStartTime - startTime; var maxSeconds = 300 + clockDifference; But I prefer it be done in the core, so I opened an issue in github.
  6. I ought to have known better. It's not a title issue, rather it's the name--that I should be validating for existence. (And the sanitizer->selectorValue doesn't help either. So, here's what worked: --same-- $title = $row['title']; $name = wire('sanitizer')->name($title,true,128,'-'); $p = wire('pages')->get("name={$name}"); // check if name already exists if(0 < $p->id) { continue; } --same-- Is there a better answer?
  7. I thought I solved it with addslashes($title). But it didn't work either.
  8. I seem to remember this happen to me too. I came across @horst's comment to avoid it: with old wire version, make a db dump, but for all caches use drop table, create table, without inserts. Or, if you are able, remove the inserts in the live db. remove all files within the cache disc subdirectories switch wire folder, load the admin for 2 or 3 times
  9. Using the ff snippet I derived from one kind member here (sorry, I can't remember & I also cleared my browser cache), I cannot figure out how to avoid double quote enclosures on titles with commas that are being added in the admin: while($row = $files->getCSV('importwines.csv',['separator' => '|'])) { $title = wire('sanitizer')->selectorValue($row['title']); $title = wire("sanitizer")->text($title, array("maxLength"=>128)); // fetch and sanitize the title $p = wire('pages')->get("title={$title}"); // check if it already exists if(0 < $p->id) continue; // move on to the next record if it exists $p = new Page(); $p->template = "wine-item"; $p->parent = "wine-list"; $p->title = $title; // use the sanitized title $p->vintage = wire("sanitizer")->int($row['vintage']); $p->price = wire("sanitizer")->float($row['price']); $p->category = wire("sanitizer")->int($row['category']); $p->location = wire("sanitizer")->text($row['location'], array("maxLength"=>128)); $p->of(false); $p->save(); } These are the escape characters i've tried: "vintage"|"title"|"price"|"location"|"category" 2020|"Cross Barn Chardonnay\\, Sonoma Coast"|105.00|"United States"|1324 2020|Truchard Chardonnay, Carneros|115.00|"United States"|1324 2018|"""Grgich Chardonnay, Napa Valley"""|170.00|"United States"|1324 Undesired results as page titles in the admin includes the double quotes: "Cross Barn Chardonnay , Sonoma Coast" "Truchard Chardonnay, Carneros" "Grgich Chardonnay, Napa Valley" These 3 are also being excluded by a broad $page->find($selector) selector filter unless I manually delete the double quotes in the admin. I think the $sanitizer->selectorValue() above also calls the new selectorValueV1() & selectorValueV2() because I am using PW3.0.210. Is there another sanitizer I should be using for the title?
  10. I have no access to the module to test it myself but.. have you tried enclosing it with html tags? html:<h1>Thank you!<br>We will contact you soon.</h1>
  11. I also see your point in wanting to put it all in the same flow. It might take more time, but I would explore the module in depth coz after quick inspection the necessary methods for registration are hookable.
  12. ...you'd have to add $loginRegister = modules()->get('LoginRegister'); $content = $loginRegister->execute(); echo $content;
  13. Yes you can. I have something similar for a blogging site. Copy/edit/improve here what makes sense to your case... wire()->addHookBefore('LoginRegister::renderList', function($event) { $links = array(); $defaults = $event->arguments(0); if(user()->isLoggedin()) { if (user()->hasRole('member')) { $links['member-list'] = "<a href='" . $this->wire('pages')->get('/directory/')->url . "'>" . $this->_('Member Directory') . "</a>"; } if (user()->hasRole('author')) { $links['blog-admin'] = "<a href='" . $this->wire('pages')->get('/utilities/blog-admin/')->url . "'>" . $this->_('Blog Admin') . "</a>"; } if (user()->hasRole('admin')) { $links['back-admin'] = "<a href='" . $this->wire('pages')->get('template=admin')->url . "'>" . $this->_('Page Admin') . "</a>"; } } else { if($event->object->allowFeature('register')) { $defaults['register'] = "<p>Don't have an account yet? Members can <a href='./?register=1' class='inline'>" . $this->_("register for an account") . "</a></p>"; } } $links = array_merge($links, $defaults); $event->arguments('items', $links); });
  14. Was curious too. I searched and, yes, it was brought up before. Here. TLDR. As mentioned there, it becomes more important when multiple programmers are (or will be--next guy after you) involved. Also mentioned, was the additional benefit of self-documentation when you follow a naming convention. To answer your question, being all implementors of the PW architecture (and PHP), it probably makes sense for us to be consistent with it. (Compared to other frameworks PW made it easy for us.) Still, I did another round of refactoring recently and felt happier after. None of my direct templates have echos. Reduced them to about 10. Since they mostly describe a type of page (model), it's a 1 word all-lowercase filename. I have a couple of controller classes that I camelCased with an .inc extension so the admin wont see it...and added an underscore so its listed on top. I guess we all have different reasons.
  15. I'm not really sure if this will lead you to something or nothing, but have you tried using a compatible jquery version in the FE? The PW BE uses jquery 1.11.1 with a migrate version 1.2.1 but in my testing jquery ver 2.2.4 worked too. It works for me using something like the following: echo "<div edit='",$input->get->id,".images' >","<a>dbl-click to edit</a></div>"; $scripts = "<script type='text/javascript'>" . "$(document).on('pw-modal-closed', '.pw-edit-modal', function() {" . "var saveButton = document.getElementById('button_save');" . "saveButton.click();" . "});" . "</script>"; $jquery_version = "2.2.4"; Then in my main template I add that jquery variable because for regular FE pages, I use another jquery version. <script>window.jQuery || document.write('<script src="<?php echo $config->urls->skin, "js/jquery-{$jquery_version}.min.js"; ?>"><\/script>')</script>
  16. I just checked my values in a Ubuntu 18 distro and sure enough I get 0, 1000, 1440 for those 3 settings. Thank you much for this. I will be testing and applying your findings for sure.
  17. For a front-end search form? One strategy I often use is concatenating the selector one input field at a time. Just make sure your add your validation. Something like this: $selector = ''; if($place = sanitizer()->selectorValue($input->post->place)) { $input->whitelist('place', $place); $selector .= ", place%=$place"; } if($input->post->doctor) { $input->whitelist('doctor', $input->post->doctor); if($input->post->doctor == '1') { $selector .= ", name=jim"; } elseif($input->post->doctor == '2') { $selector .= ", name=jon"; } elseif($input->post->doctor == '3') { $selector .= ", name=jake"; } } $limit = 12; $template = doctor; $parent = doctors; $selector .= ", sort=sort, limit=$limit"; $selector = "template=$template, parent=$parent" . $selector; $results = pages()->find->($selector);
  18. To whoever might be searching this topic, I just recently found out about $config->appendTemplateFile and started using it in a delayed template method. In my xml type templates (e.g. rss.php), "exit" seems to have the same effect (bypassing the _main.php template). if(input()->urlSegment1 != 'rss') throw new Wire404Exception(); $rss = wire('modules')->get('MarkupRSS'); $rss->title = 'RSS Feed'; $rss->description = ''; $rss->render($items); exit; But for AJAX, i might be inclined to use the suggested solutions above.
  19. I use an IDE and found it stressful to have to work-around deploying config.php This is how I found your thread. Thank you! I integrated your solution into my own workflow and came up with this to share back here: /site/config.php (like @bernhard except last line) // include config file from outside of the repo $client = 'config-' . end(explode('/',__FILE__, -2)); include("../$client.php"); The PHP end() function and the minus 2 in the explode(), always gets the URI domain base. (As long as PW keeps it there.) Since my usual deployment flow is from ABC.dev -> test.mybox.com/ABC -> ABC.com ...in my root folder, safely out of reach (like @bernhard's concept), I then create 3 files each containing config deployment differences. ../config-ABC.dev.php and ../config-ABC.php and ../config-ABC.com.php For those also using PHPStorm, since these files are located out of project, I would add them in Favorites. (And add it's root folders in Deployment Mappings). I can then easily make use of IDE features like "Compare Two Files", "Sync with Deployed to", etc. Removing doubts about what config property I may have missed across the board. No more stress.
  20. Good to know. Thanks. I didn't think to look in the database, and yes, I do see the value in it now but without the labels as you explained. My module implements a WireData. I just use it to store parameters and install some custom classes required for a nightly cron job. I can access the values by $module->get('fieldA'), but I was hoping to get the label too to include in the cron job. I'll probably change the input type to something else that saves both the label and the value. Thanks much all!
  21. Thanks for the quick response. I tried to var_dump the getModuleInfo() but it just gives the module's overview info. I was trying to get deeper, at the Inputfields.
  22. I am trying to get the "text Content" (not the value) portion of an InputfieldSelectMultiple property I created for an installed module. The selected options are saved in PW somewhere. How do I get at it? viz: <select name="fieldA"> <option selected value=0>Content 1</option> <option value=1>Content 2</option> <option selected value=2>Content 3</option> </select> I know its an array and that i'd have to access the options in a loop. But I can't seem to make the right call to any of the methods that return an array. So, here's an example of many that i tried and failed: $module = wire('modules')->get('ImportMyModule'); $field = $module->get('fieldA'); $options = $field->getOptions(); foreach($options as $key => $val) { echo "key: ", $key, " val: ", $val; } I can't figure out to get at just the "text Content" for now , then the selected one's after. (in the above sample "Content 1" and "Content 3") It'll save me a bunch of if's. Thanks forum!
×
×
  • Create New...