Jump to content

Pete

Administrators
  • Posts

    4,032
  • Joined

  • Last visited

  • Days Won

    66

Everything posted by Pete

  1. Well a 500 error simply means there was something broken in your code. Returning "nothing at all" (I'll assume it returned no results is what you mean) means you were closer to getting it right but the selector probably needed tweaking. You can change the last bit of your code above to simply be: // Search pages $selects = $pages->find( "template=child-template, $selector" ) ); There's no need to import into an empty PageArray unless you were merging multiple PageArrays, so just doing the above results ina single PAgeArray anyway. Your code looks like it should be fine but will always result in a trailing comma in your selector (both the $selector.= lines end in a comma) so you should put the comma before the branche= and contract= lines and change your final selector to look like this (no comma): // Search pages $selects = $pages->find( "template=child-template $selector" ) ); Whole thing then looks like this: $selector = ''; if($input->get->branche) { // Get the criteria and sanitize them $branche = $pages->get("/branche/" . $sanitizer->pageName($input->get->branche)); if($branche->id) { $selector .= ", branche=$branche";//CHANGE YOUR SELECTOR AS SHOWN HERE $input->whitelist('branche', $branche->name); } } if($input->get->contract) { // Get the criteria and sanitize them $contract = $pages->get("/contract/" . $sanitizer->pageName($input->get->contract)); if($contract->id) { $selector .= ", contract=$contract";//CHANGE YOUR SELECTOR AS SHOWN HERE $input->whitelist('contract', $contract->name); } } // Search pages $selects = $pages->find( "template=child-template $selector" ) );
  2. I guess another way to put that is "modules in PW follow some sort of convention in the way they are presented rather than modules in other systems where you can't predict how a module author might display the data in the admin" Well in 2.4 admin themes are modules, so it wouldn't be massively difficult to override the user's choice and show a different theme (though not sure why you would). During install using 2.4 you get to choose the theme and the next step after that shows the installer using the new theme so there's probably some code there. Alternatively if you just wanted to hide some things there are numerous ways including editing the default.php template file in the admin theme and showing certain things to certain roles (though there are better ways than that depending on your needs).
  3. I like Soma's example above as it contains a few things I didn't even know were possible (and I've been here 3+ years ). The only other way that might work for you is merging two PageArrays, like this (from this topic: https://processwire.com/talk/topic/3384-search-with-merged-pagearrays-pagination-not-working/): $selects = new PageArray(); $selects->import( $pages->find( "your first selector" ) ); $selects->import( $pages->find( "your second selector" ) ); $selects now contains pages from both selectors.
  4. If they're hours as in 24 hours in a day, could you not just do something like this: for ($i=0; $i <=23; $i++) { // Regular PHP - see http://www.php.net/manual/en/control-structures.for.php echo '<a href="' . $page->url . $i . '/">' . $i . '</a>'; // which will output as <a href='/your-page/4/'>4</a> - well, it will output 0 - 23 in this way so you'll have 24 hourly links for example } Not quite sure what you mean by "link" in this case, but you could use something like the above with a selector that uses the urlsegment and searches for pages with 4 in the rangeslider field - see this example adapted from the rangeslider instructions for the selector if you wanted to match any page with a range that encompassed "4": $pages->find("range.min<=4, range.max>=4"); // So if minimum is less than or equal to 4 and maximum is greater than or equal to 4, get those pages. You'll probably want to specify a template as well but you get the idea
  5. Raymond - did you see my ProcessDashboard module?
  6. This is great as it's Something I've wanted to do on a couple of projects the last few weeks, thanks!
  7. Can I ask about the app for a sec - what's the benefit over a fully functional mobile admin theme? The API makes an app easier to accomplish than in many other systems but unless there's a clear advantage I'm not sure I see the point to be honest.
  8. What Teppo said - since the admin user is a known ID it would be trivial to log in as the admin this way and wreck your site (or actually install a module like Hanna Code, throw in some PHP and do significantly more damage to your server). It's an extremely bad idea.
  9. I think you would have to stick Pw in a subfolder then but you would get the subfolder name in your Pw page urls. Or was that what you mean in your question? How to remove the subfolder from the Pw urls?
  10. Pete

    Client of the Day

    Though I've just told my client's boo-boo, I did very recently tip an entire cup of tea all over one of these: http://www.logitech.com/en-gb/product/illuminated-keyboard-k740?crid=26 The keypresses just aren't what they used to be - smooth and quiet has turned into a bit clicky, but at least they stopped sticking after a few days! Marginally cheaper than Joss' recording desk but I was still annoyed with myself.
  11. I still use the default install setup of including head.inc and foot.inc the most to be honest (mostly through habit), but there are many ways to approach it as kongondo says.
  12. Also an ex-MODx'er myself. It's been fun converting some very different sites over the past few years as things that required a lot of custom code and queries in snippets in MODx to something that's much more manageable using the API in ProcessWire templates. Kidderminster-Husum-Twinning Before: https://web.archive.org/web/20130726180253/http://www.kidderminster-husum-twinning.co.uk/ After: http://www.kidderminster-husum-twinning.co.uk/ StrategyCore Before: https://web.archive.org/web/20120118171718/http://strategycore.co.uk/ After: http://www.strategycore.co.uk/ Etc etc
  13. Pete

    Client of the Day

    Someone I work with was busily deleting files fro the Windows folder one day to free up space because "they didn't seem to be anything he recognised as being relevant". Same chap also had his laptop on a boat on a sailing holiday and it got soaked when a big wave came over the side. I constantly threaten him with his next laptop being one of these:
  14. I'm not sure about it to be honest (which probably goes against what I've said on the subject when it's been mentioned before ). I mean, the user will have just done some manual work to get the files onto their server to begin installation anyway (even if they use the single file installation method) so it shouldn't be too daunting for them to put a different profile in the right place. What might not be a bad idea as a first step towards this is maybe mention on the first step of the installer that other profiles are available with a link to them?
  15. I'm going to highlight this again horst as it's the important bit So whether yours or Teppo's module is installed or neither, emails can still be sent using the default Wiremail class. Therefore if I'm writing a module that requires email sending functionality, it needs to be able to use the same functions whether it's ryan's base module, the SwiftMailer class or your own module or module authors won't know what to expect. I think these WireMail modules need to be coordinated somewhat so that whatever the base class supports, the other classes also support so there are no surprises.
  16. The problem with just implementing it in Swiftmailer (or in your class) is this from ryan's first post: So I can't count on the user not just using the default WireMail class and certain functionality not being available. I think that the WireMail base class needs to have these functions set up before subclasses (is that the correct term?) implement features or we'll have issues with things working consistently or we'll have to do some checks to see which Mail module is installed. My usage in this case is writing modules that use the WireMail class, so I need the functionality in the base class to be sure that the emails will definitely send
  17. Can we have options for CC and BCC please ryan (and then Teppo in SwiftMailer )? It's not mega urgent, but these do come in handy in a few situations.
  18. Pete

    Client of the Day

    I'm now on page 70-odd of stories on the Clients from Hell website... it's a bit addictive, and quite amusing
  19. Cheers - I forgot I had similar in place for page edit as well! My next message as about not having template edit access, but I figured I could save a lot of headaches by just allowing the right permissions on the template (though I did see your note on the subject here: https://processwire.com/talk/topic/371-page-specific-permissions/page-2 ).
  20. So my edit function works great, but my add function fails to override the correct permissions (I'm happy overriding permissions because the users can't see the page tree to cause mayhem and I will have other checks in the code too). I was trying to do something like this: public function executeAdd() { $this->fuel->breadcrumbs = new Breadcrumbs(); // start with a fresh breadcrumbs list $this->fuel->breadcrumbs->add(new Breadcrumb($this->config->urls->admin . 'mymodule/', "My Module")); $this->fuel->page = $this->page; $this->fuel->page->addable = true; $addForm = $this->modules->ProcessPageAdd; $addForm->parent_id = $this->page->id; return $addForm->execute(); } However $this->fuel->page->addable doesn't seem to want to work. I'm probably missing something obvious, but any suggestions?
  21. Pete

    Client of the Day

    Did you have fun explaining it to him in that last example? Please paint a picture of the look on his face (using words, not MS Paint ).
  22. Can you not just do this when they submit the text field containing the URL? $pic->add($input->post->your-text-field); Not sure it works with URLs but that's the way to test it
  23. Exactly what Soma said. What you are trying to do above when you say $page->title works sounds like you're trying to find all pages with the template "child-template" that have the current page in the "provincie" field, so you don't need to do anything more complicated than this (because $page is the current page): $selects = $pages->find("template=child-template, provincie=$page->id"); Or if you don't specify a field on the end of $page then it returns the page ID anyway: $selects = $pages->find("template=child-template, provincie=$page"); It sounds like you're trying to find other pages that relate to the page currently being viewed, so you should always try matching the current page's ID, assuming "provincie" is a Page fieldtype? For that fieldtype pages are stored using their IDs. UrlSegments is just over-complicating things at this stage
  24. Would you like to export it as a site profile for ease of installation? All you have to do is install the Profile Exporter module to create a profile from your setup and then people can install ProcessWire using this profile.
  25. EDIT: I edited my posts because millions of rows will slow down a search, but you have to ask yourself when you expect to encounter millions of rows in your database? Comments on a news site maybe, but then when are you ever going to want to search the contents of a comments field across all articles? It's all relative to what your scenario is.
×
×
  • Create New...