Jump to content

Jan Romero

Members
  • Content Count

    274
  • Joined

  • Last visited

  • Days Won

    3

Jan Romero last won the day on May 28

Jan Romero had the most liked content!

Community Reputation

427 Excellent

About Jan Romero

  • Rank
    Sr. Member

Profile Information

  • Gender
    Not Telling
  • Location
    Germany

Recent Profile Visitors

6,267 profile views
  1. Mh, it works for me. I believe 'autoload' => true must be set for it to call ready(). Have you tried reinstalling the module?
  2. I mean, you could do something like this: //in site/ready.php $this->addHook("Page::renderBlock", function($event) { $page = $event->object; if ($page->template->altFilename) $blockPath = $page->template->altFilename; else $blockPath = $page->template->name; $blockPath = "blocks/{$blockPath}.{$this->wire('config')->templateExtension}"; $event->return = $page->render($blockPath, $event->arguments(0)); }); Now you can call $page->renderBlock() or $page->renderBlock(['this' => 'that']) and the block’s template path will be determined automatically according to the template settings. Or this, maybe: $this->addHook("Page::renderBlock", function($event) { $page = $event->object; $templatePath = $this->wire('config')->paths->templates; $templatePath = substr_replace($page->template->filename, 'blocks/', strlen($templatePath), 0); $event->return = $page->render($templatePath, $event->arguments(0)); });
  3. Step 1: Change your form element’s action attribute to <?php echo $page->url; ?> Step 2: There is no step 2. edit: sorry, I didn’t read the whole thread either. This same answer had actually been posted by Soma two posts ago.
  4. I think this is a bug in ProcessWire. When you use the ~= operator, ProcessWire translates it into MySQL’s select /*[…]*/ match(field_title.data) against('+New York' in boolean mode) as _score_field_title_data1 /*[…]*/ order by _score_field_title_data1 desc The score it uses to sort is generated by the database according to the number of times the string appears in the text (probably more complicated than that, but whatever). The problem is that several results will have the same score, so the order among them is not deterministic. The database just does whatever it wants at that point, so the order may change inbetween queries, even if the queries are the same, but especially if they differ, even just in LIMIT and OFFSET. If you add "sort" to your selector string, ProcessWire will still use the score to sort, but only after your specified fields. What ProcessWire should do is ALWAYS sort by page id at the end, to keep the order deterministic. It might also be nice to make the relevance scores accessible in selector strings, so you could do something like "title|trader~='New York', sort=-title_relevance, sort=-trader_relevance, sort=-modified, sort=-id" Now you could have results in order of textual relevance, and if the relevance is equal, get the most current ones first, or whatever you desire. Obviously the id is a pretty stupid way to sort, but since it’s strictly unique, it’s a stable way to break ties, so I’d always put it last.
  5. Yes, that would be very un-databasey. You basically have three entities you care about: Chairs, Brands and Adapters. At first glance (I may be wrong about this) it looks like each Chair has exactly one Brand and exactly one Adapter. For each Brand there are multiple Chairs and multiple Adapters, and for each Adapter there are multiple Brands and multiple Chairs. Make three templates, Chair, Brand and Adapter. The Chair template has one page field for a Brand page and one page field for an Adapter page. Now you can structure your page tree any way you like. If you want your URLs to look like http://example.com/e-drive/netti-i/, put Chairs under their Adapters as children. Now you can drop the Adapter page field and just use the Chair’s parent instead. If you want your URLs to look like http://example.com/alu-rhab/netti-i/, put Chairs under their respective Brands as children. Now you don’t need the Brand page field. Assuming the latter, finding all Alu-Rhab Chairs is easy: $pages->find("template=chair, parent.name=alu-rhab"). Finding all E-Drive Chairs: $pages->find("template=chair, adapter.name=e-drive"). Finding all E-Drive Brands: $pages->find("template=brand, children.adapter.name=e-drive"). Not sure about finding all Alu-Rhab Adapters, but if it comes to it, you can just get the page ids with SQL and do $pages->findIDs() on them. Or loop over all Adapters and check if there is at least one Alu-Rhab Chair for each one.
  6. I’m guessing header and footer come from prepend and append files. You’ll have to figure out a way to disable those in Ajax requests. For example, if you use $config->prependTemplateFile, just condition that with $config->ajax. //in site/config.php if (!$config->ajax) { $config->prependTemplateFile = 'head.inc'; $config->appendTemplateFile = 'foot.inc'; } You may need to set request.setRequestHeader('X-Requested-With', 'XMLHttpRequest') on your Ajax request for ProcessWire to automatically detect it as Ajax.
  7. Tbh for one-off imports I usually transform the csv (or whatever it is) into PHP or SQL using regex replace in Notepad++ and then just run that. 1500 rows should be nothing, unless they’re absurdly long. edit: nvm, I missed the 1.000.000 figure, but still, writing to the database directly should be an efficient option. In MySQL might want to use LOAD DATA INFILE, but you’ll have to adjust the input data first.
  8. Are you using multiple languages by any chance? There was a thread with a similar problem. Unfortunately not much came of it. I never looked into the underlying cause after I got it working again…
  9. This is because non-superusers aren’t allowed to add children under /processwire/setup/languages. First, because /processwire/setup/languages is of template admin, you would need to open the template settings for admin and check the box “add children” in the access tab. Then you also need to give them permission to create pages of template language, so in the language template, enable access control and check “edit pages” and “create pages”. This isn’t a very nice solution, because you have to change access for all admin pages. I suppose it would be neat if a “lang-add” permission came with the language support module. Alternatively, you can probably write a hook to add a button somewhere that creates a language and bypasses those permission checks.
  10. The ^= operator should do it: $matches = $pages->find("limit=0, title ^= '$letter'");
  11. I’d use FieldtypeTable: https://processwire.com/store/pro-fields/table/ It’s not free, though.
  12. I’ve never used that module, but as far as I understand you’re supposed to just check the required box in the field settings. If you reuse the fields in other templates where they are not required, you can check the box in the template context field settings. Looking at this line it might only work for text fields? Not sure what that’s about, but you can always hook LoginRegister::buildRegisterForm and modify the result yourself.
  13. Hi I’m posting drunk again, and I just want to say, this module is awesome! Thanks a bunch, teppo, you’re the man. I feel much better with this after giving a friend edit permissions on my site 😄 But also, one thing, does anyone else feel that the diff should always be old to new? Right now when you open the history and click the most recent compare button, it’s the other way around. Wikipedia gives you one radio button for each version to compare and simply doesn’t let you select old to new. It’s kind of awkward and over-engineered, but I think the spirit of not going backwards in time is intuitive.
  14. sort=-date will sort by date from latest to oldest 🙂
×
×
  • Create New...