Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by Webrocker

  1. Hi and Happy New Year to you all I'm currently reviewing some of my first sites, esp. regarding better usability for the backend users/editors. One thing I use often is to set the infos displayed in the tree/listing view, for example have not only the title, but also the category or the published date visible. Now, if the format of the date field is not set in the template settings, this will display the unix timestamp, which is not so comfortable for the editor. But if I set the format, this will influence how the date is displayed in the front end, which may be too inflexible, for example if the field is used in different templates, maybe with a short and a complete date display. I decided to use the unformatted date and format it to my needs in the front end templates. but as said, this makes the backend display of the date unusable for the editor. Now upon revisiting this situation, I wonder if it would be better to use a (pre set) format that's suitable for my back end editors needs, and make a strtotime/strftime formatting in the frond end templates to change the date format if needed. How is your approach to this, or how is the set-date-format at field level thing intended to be used? cheers, Tom
  2. Hi, using a "Search" input and having the search over several fields like "Title", "Headline", "Body", and running the input value through $sanitizer->selectorValue() first, I noticed that a search for "Non(n)sense" led to errors. After testing around a bit, we discovered that replacing the "(" and ")" with "\(" and "\)" before running the selector yielded the expected search result. on line 738ff in core/Sanitizer.php: // disallow some characters in selector values // @todo technically we only need to disallow at begin/end of string $value = str_replace(array('*', '~', '`', '$', '^', '|', '<', '>', '=', '[', ']', '{', '}'), ' ', $value); Should the normal braces () be added there as well, or should those be escaped somewhere in this sanitizer? I am not sure if we have a homegrown problem here, because our "search" selector uses some or-groups, which are denoted by using - braces. cheers Tom
  3. thank you, @kongondo, this will be very useful!
  4. Hi BernhardB, is it possible to have this enabled for the front end as well? thx Tom
  5. Hi @driedstr welcome to the forum I'm with @horst on that - most likely there's something in your site/config that's working fine in your local env, but not on the server. I had some memory alloc errors with processwire, but usually only with extensive api things working on several thousand page objects. Maybe looking directly on the server with 'top' gives a clue what eats the memory? cheers tom
  6. hi craig, yes, the "real" one uses a limit. if set to 20, this takes around two seconds. do you happen to know of a way to "see" the mysql queries PW is sending? if I introduce a sort=shows_relation.date to the above, it again will time out… thx Tom
  7. Hi Craig, wow, this simple modification sped up the query quite a bit O_o ) $res = $pages->find('template=event_item, shows_relation.date>2015-11-28, shows_relation.date<2016-01-15'); # RAW mySQL Result-Count: 26770 Duration: 0,023936033248901 Seconds. // not used in the following: # PW Result-Count: 7342 Duration: 5,9315440654755 Seconds. THANK YOU.
  8. to illustrate the above; this is with $res = $pages->find('template=event_item,shows_relation='.$res1.',limit=50'); # RAW mySQL Result-Count: 26770 Duration: 0,030179023742676 Seconds. # PW Result-Count: 50 Duration: 48,704106092453 Seconds. Tom
  9. Hi Wanze, thx for the fast reply … the problem is, the queries are timing out even before the end result (which is paginated) will be returned -- it seems that the selectors that are querying the page-relation fields try to look up several thousand page objects in between - even if the result in the end is only a handful of matching pages… :-/ but again, maybe there is a problem in the way we are trying to get to the information, not in the way pw returns it. For the moment I was wondering wether the repeated "OR" lines in the sql statement can make a difference… thx Tom
  10. Hi, consider this setup: - "Shows" having a certain "Event"; stored in a page field "event_relation" - "Events" having multiple "Shows"; stored in a page field "show_relation" There are about 86,000 shows and 17,000 events in the database, together with the normal cms pages there are over 100,000 rows in the pages table. I now query first the shows matching a certain criteria, and then query the events having these shows, in order to use their data for display. I had the server timing out several times; even with memory settings maxed up. I created the following bit for testing, already using a raw sql query to get to the page ids of the shows, then using this in a "pw-style" selector for the events. echo '<h1>RAW mySQL</h1>'; $start = microtime(true); $sql = 'SELECT pages_id FROM field_date WHERE data>"2015-11-28" AND data<"2016-01-15"'; $query = $database->prepare($sql); $query->execute(); $res = $query->fetchAll(PDO::FETCH_COLUMN); $result = count($res); $end = microtime(true); $diff = $end - $start; $res1 = implode('|',$res); echo '<p>Result-Count: ' . $result . '</p>'; echo '<p>Duration: ' . $diff . ' Seconds.</p>'; echo '<h1>PW</h1>'; // process-wire: $start = microtime(true); $res = $pages->find('template=event_item,shows_relation='.$res1); $result = count($res); $end = microtime(true); $diff = $end - $start; echo '<p>Result-Count: ' . $result . '</p>'; echo '<p>Duration: ' . $diff . ' Seconds.</p>'; # RAW mySQL Result-Count: 26770 Duration: 0,021031141281128 Seconds. # PW Result-Count: 7229 Duration: 40,812306880951 Seconds. Look at this -- 40 seconds, on a root server in a testing environment, no "real" traffic interfering. O_o I had a look into mySQLs log files and processlist, and I noticed that the query that PW is sending contains LOTS of OR statements like this: ... OR ((field_shows_relation.data='103472') ) OR ((field_shows_relation.data='103473') ) OR ((field_shows_relation.data='103477') ) OR ((field_shows_relation.data='103478') ) OR ((field_shows_relation.data='103479') ) OR ((field_shows_relation.data='103480') ) OR ((field_shows_relation.data='103481') ) OR ((field_shows_relation.data='103482') ) OR ((field_shows_relation.data='103483') ) OR ((field_shows_relation.data='103486') ) OR ((field_shows_relation.data='103490') ) OR ((field_shows_relation.data='103491') ) OR ((field_shows_relation.data='103492') ) OR ((field_shows_relation.data='103496') ) OR ((field_shows_relation.data='103497') ) OR ((field_shows_relation.data='103515') ) OR ((field_shows_relation.data='103518') ) OR ((field_shows_relation.data='103526') ) OR ((field_shows_relation.data='103527') ) OR ((field_shows_relation.data='103528') ) OR ((field_shows_relation.data='103529') ) OR ((field_shows_relation.data='103530') ) OR ((field_shows_relation.data='103531') ) OR ((field_shows_relation.data='103532') ) OR ((field_shows_relation.data='103533') ) OR ((field_shows_relation.data='103534') ) OR ((field_shows_relation.data='103535') ) OR ((field_shows_relation.data='103536') ) OR ((field_shows_relation.data='103537') ) OR ((field_shows_relation.data='103539') ) .... in the example above like 26,770 rows of these "OR" statements. I don't know if this is the reason why those queries take a long time, and I am by no means skilled in query-crafting, but wouldn't it be easier to have an "IN( a,b,.....,n )" statement for that? The problem is, we are using quite a lot of these "page" fields to reference lots of shared data like venues and locations - and some of these use other page relations and so the resulting queries fired by the PW selectors are very very long and complex, and so the percieved performance of the page using this is rather sluggish. As long as the data queried stays under like 1000 results, everything is ok, but the it starts to increasingly getting slower. Has someone else had similar experiences? Should we stay away from the API selectors for such an amount of data or have we shot ourselfs in the foot architecture-wise by using all those page-fields? thanks, Tom
  11. I'm puzzled why the "«" seems to cut off the string, but "»" doesn't: "»blahbleh«bloh" will return "blahbleh", "«Blahbleh»bloh" will return "". Strange.
  12. hi tpr, thank you, but it seems like pageNameTranslate($val) is the same as pageName($val,Sanitizer::translate) ? public function pageName($value, $beautify = false, $maxLength = 128) { return strtolower($this->name($value, $beautify, $maxLength, '-')); } public function pageNameTranslate($value, $maxLength = 128) { return $this->pageName($value, self::translate, $maxLength); } What helps in my case is to add "« -" in the InputfieldPagename translation settings. cheers, Tom
  13. Hi pwFoo, sorry for the late reply; it seems to work as intended in our install, thank you (one minor thing, tho, the FrontendUserRegisterEmailValidation module is not updatable from the backend, it still claims to be 6 months old, even with the fresh 13.11.15 version on the server…) cheers, Tom
  14. Hi, I just stumbled across this: We have a title of an Event "»The Good Ones« – The Last show" (excluding the double quotes). From this a PW page is created via the API and the title is used for the page name, but is sanitized with "$Sanitizer->pageName(title,Sanitizer::translate);" This results in "the-good-ones" -- everything following the "«" is stripped. If the "«" is the first char in the title -- "«The good ones» – The Last Show" -- the the page name is empty. I traced the pageName -> name -> nameFilter chain in wire/core/Sanitizer.php, but I don't see an obvious point where this could be caused, only that this must be inside the "if $beautify...." clauses. My guess is, it is in the nameFilter function, but there's a lot going on with multibite and ASCII stuff, which is quite over my head. Can somebody else confirm this? (PW 2.6.21 / with Multilanguage activated) thx Tom
  15. Hi, I think there's a hickup in your database - the sqlstate error hints that there's a duplicate entry. make sure to empty the trash in pw backend and if possible look directly in the database and look out for the "language-22" entry in "name_parent_id", my guess is this is in the pages table. I'm afraid that you deleted the admin page for the language settings (id 22?), possibly this needs to be present. not sure tho, maybe someone else has more experience with that… cheers tom
  16. @Christophe Thank you, didn't know about that special char, and my google skills need some improvement, it seems @pwFoo Cool, thanks. Perhaps this could be triggered via a settings option? I guess 'our' problem is caused because we have all the 'surrounding' markup in the _main.php, other structural designs may not be bothered by this. On the other hand, in your demo mail template the complete 'surrounding' markup is contained, so no need for inheritance from the page/main template. hm. on the other hand, what if you need to access some vars or funcs from _init.php or _func.php … guess what i'm trying to say: as so often with processwire: it depends cheers Tom
  17. btw, what is the "\h+" in the preg_replace supposed to match against?
  18. Hi again, I think we found a bug regarding the emailValidation E-mail: The email contains some markup residue which is pulled from the _main.php file (for example some google analytics script code), even if sent as text email. If the vars for the render() func contain $vars['prependFile'] = null; $vars['appendFile'] = null; $vars['allowCache'] = false; this is gone. Is there a way to insert this via hook, or only in FrontendUserRegisterEmailValidation.module, line 97ff…? // Set email template variables $vars = array( 'username' => wire('session')->get('registerUsername'), 'email' => wire('session')->get('registerEmail'), 'token' => wire('session')->get('registerToken'), 'url' => wire('page')->httpUrl . '?registerToken=' . wire('session')->get('registerToken'), 'content' => $this->content, // config variable // ToDo: Tests with php 5.3 // no markup from page template: 'prependFile' => null, 'appendFile' => null // ---- // ); // Load the plain / html email templates $emailContentHtml = wire('page')->render(wire('fu')->getFile('validationEmail.php', 'templates'), $vars); // Send verification email with the generated token $mail = wireMail(); $mail->to($form->fhValue('email'))->subject($subject); if ((int)$this->emailType == 1) { $mail->bodyHTML($emailContentHtml); } else { $emailContentPlain = preg_replace('/^\h+|\h+$/m', '', strip_tags($emailContentHtml)); $mail->body($emailContentPlain); } $mail->send();
  19. ok, found it (with the support of @inspeCTor) $fu->form->addHookBefore('render',function($event){ if (!wire('session')->get('registerStep')) { $event->object->fhSubmitBtn->value = __('Send validation code',$langfile); } });
  20. Hi, I'm trying to override the "Send email validation code" value of the UserRegistration submit button, I need it to be translatable. Since I don't want to hack the module (line 157 of FrontendUserRegisterEmailValidation.module) by putting a _('Send email validation code'), I tried to set the custom value with a $fu->addHookBefore('render',function($event){ $form = wire('fu')->form; if (!wire('session')->get('registerStep')) { $form->fhSubmitBtn->value = __('My custom text',$langfile); } }); but to no avail -- it seems that the module's hook function ( hookRegisterFormBeforeRender ), which also will hook into before render, always trumps "my" value. What am I missing? thx Tom
  21. You have to enable the pagination in your backend-template_ "Enabling Pagination Make sure the "Pager" (MarkupPagerNav) module is installed in Admin > Modules. If it's not installed, click the Install link next to it. Determine what template(s) you want to use pagination with. Go to Admin > Setup > Templates > [Your Template] > URLs, and check the box for: Allow Page Numbers. Save. Pagination should now be enabled and ready to use in your templates." (http://processwire.com/api/modules/markup-pager-nav/) cheers, Tom
  22. Hi, I'm not sure what you're trying to achive; but if you want to have your first example in combination with the pagination, you could do it like this: $pageItems = 10; $columns = $page->children('limit='.$pageItems); $colcount = $columns->count(); $pagination = $columns->renderPager(); $i = 1; echo '<div class="row">'; foreach ($columns as $column) { if($i == $colcount){ echo "<div class='medium-4 columns end'> <a href='{$column->url}'><img src='{$column->webshop_child->first()->url}' alt='' /></a>"; } else { echo "<div class='medium-4 columns'> <a href='{$column->url}'><img src='{$column->webshop_child->first()->url}' alt='' /></a>"; }; if($i % 3 == 0) { echo '</div></div><div class="row">'; } else { echo '</div>'; } $i++; } echo '</div>'; // new row with on col span full width for the pager; change according to your layout echo '<div class="row">'; echo '<div class="medium-12 columns">'; echo $pagination; echo '</div></div>'; You could save some lines of code if you catch the class for the last column instead of if/else the nearly identical lines: $pageItems = 10; $columns = $page->children('limit='.$pageItems); $colcount = $columns->count(); $pagination = $columns->renderPager(); $i = 1; echo '<div class="row">'; foreach ($columns as $column) { $colClass = 'medium-4 columns'; if($i == $colcount){ $colClass .= ' end'; } echo "<div class='{$colClass}'> <a href='{$column->url}'><img src='{$column->webshop_child->first()->url}' alt='' /></a>"; if($i % 3 == 0) { echo '</div></div><div class="row">'; } else { echo '</div>'; } $i++; } echo '</div>'; echo '<div class="row">'; echo '<div class="medium-12 columns">'; echo $pagination; echo '</div></div>'; cheers, Tom
  23. Cool. You think you have some time to spare in conf breaks? would love to hear about your tales from the other side
  24. I'll be at the warm-up too. I am the one guy with no beard and no tattoos. ;-)
  • Create New...