Jump to content

evan

Members
  • Posts

    94
  • Joined

  • Last visited

Everything posted by evan

  1. Ah yes, I just found that! Thanks. I think that'll work well enough for my situation.
  2. I'm referring to the image insert option in CK Editor or TinyMCE. Maybe this is the same question as above, but I find it a bit confusing UI-wise when resizing, as it displays the original image with the original orientation, but renders rotated after inserted. I'm wondering if it's possible to make the image display consistent -- by hooking into the WYSIWYG image insert option, pre-processing all uploaded images, or whatever. Not sure what the best approach would be to achieve this, or if it's possible at all. Thanks!
  3. Has anyone else had issues with orientation in the Select Image modal? While it renders correctly in the WYSIWYG and Image field, it doesn't seem to reflect those changes in Select Image. I assume it's because it's the orientation is changed in the resize() function. This is in PW 2.4.0, and it appears to reorient only in the WYSIWYG in 2.5. Thanks! evan
  4. Actually posting this as a reply to the Core ImageManipulation, feel free to delete this.
  5. Hello, Anyone else having issues using imageSizerOptions['autoRotation'], and the Select Image modal? While it renders correctly in the WYSIWYG and Image field, it doesn't seem to reflect those changes in the Select Image modal. Perhaps it's not checking orientation where that's being rendered? Thanks! evan
  6. I left the iteration in place for possible future use, but good to know the clean way too! And no, I'm not using ZIP extraction currently.
  7. The title function renderRepeaterLabel is hookable. Here's a generic example, which applies to all Repeater fieldtypes: class RepeaterTitle extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( // The module'ss title, typically a little more descriptive than the class name 'title' => 'Repeater Title', // version number 'version' => 0.1, // summary is brief description of what this module is 'summary' => 'An example module used for demonstration purposes.', // Optional URL to more information about the module 'href' => 'http://processwire.com', // singular=true: indicates that only one instance of the module is allowed. // This is usually what you want for modules that attach hooks. 'singular' => true, // autoload=true: indicates the module should be started with ProcessWire. // This is necessary for any modules that attach runtime hooks, otherwise those // hooks won't get attached unless some other code calls the module on it's own. // Note that autoload modules are almost always also 'singular' (seen above). 'autoload' => true ); } /** * Initialize the module * * ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called * when ProcessWire's API is ready. As a result, this is a good place to attach hooks. * */ public function init() { $this->addHookBefore('InputfieldRepeater::renderRepeaterLabel', $this, 'repeaterLabel'); } public function repeaterLabel($event) { // Replace function $event->replace = true; // Arguments: $label, $cnt, Page $page $page = $event->arguments(2); // Show repeater page body instead $event->return = $page->body; } } Not sure what the best way is to replace the title per specific instance of a Repeater field -- I'm still learning my way around hooks. But I'm sure someone else knows!
  8. Figured it out...not really complicated, I think I was just getting sleepy/myopic: // Instantiate the class and give it the name of the HTML field $u = new WireUpload('file'); if (count($u->execute())) { foreach($u->execute() as $filename) { $p->files->add($filename); echo $p->files->last()->hash; // Returns the hash } $p->save(); } else { return false; } And on the JS side, I set an attribute of UI element to the response upon successful upload.
  9. Interesting, thanks! Didn't know about the hash property, I would much rather use that. Is that documented somewhere? Currently my JS uploads each file with individual AJAX requests, and generates a file UI element and delete button. Basically I need a way to keep my UI in sync with what's actually uploaded. Ideally my AJAX endpoint could just respond with the individual file hash and I could match it with the UI element. So I guess my question is, can I access or generate the file hash on an individual per-request basis?
  10. Individually managing files stored in a Page's multi-file File fieldtype by filename wasn't as easy as I hoped it would be. I was using Dropzone.js to upload files, and wanted to allow the user to delete their uploaded files individually. Unfortunately, it appears that the filenames are sanitized in a somewhat hidden way. To match my raw filename with the one stored in PW, I had to to instantiate WireUpload to use its validateFilename method: $u = new WireUpload('empty'); $sanitizedName = $u->validateFilename($filename); $file = $myPage->files->get('name='.$sanitizedName ); $myPage->files->delete($file); $myPage->page->save(); Is there a better way to do this that I'm missing? It might make sense to have this method exposed as $sanitizer->filename, if not. As a side note, I also noticed that WireUpload has the method setLowercase(bool), but it doesn't seem to work -- I tried setting it false, but my uploads were still being renamed in lowercase. Is there some other point further down the line at which it's being modified?
  11. Yes, it happened right after trying to create a new form, as you described. I think I had MySQL 5.6.21 running, though I'm not 100% certain.
  12. OK, interesting. After snooping more, it looks like it's a MySQL 5.6 issue -- downgraded to 5.5.39 and it works now.
  13. Hello, I just started using Form Builder in PW 2.5, but for some reason am unable to create a form. It just gives me this error: Field 'data' doesn't have a default value I tried googling it, but bafflingly, the only forum post on the subject no longer exists. Thanks for your help!
  14. Hi, I just started making use of field type tags, and noticed that, when changing the field type from one to another (integer to float, for example), it loses the associated tag. Is this intended behavior, or a bug? I could see why you'd want to unset the tag when you change the field type, but it also seems logical that you'd want to keep it grouped the same. Thanks! -evan
  15. If you hook onto page->save(), it's no longer necessary to loop over pages->find(): public function sorttitles($event) { $page = $event->arguments[0]; // Only run if the page we just saved has the "item" template if ($page->template == 'item') { $new_title = (preg_match( "/^(the|a|an)\s/i", $page->title)) ? substr(strstr($page->title," "), 1) : $page->title; $page->sort_title = $new_title; $page->save('sort_title'); } } } } } -evan
  16. Hey, nice! I did notice that there was a page->save() hook after the fact, maybe I'll try that out. It was just quicker for me to do LazyCron, as I'd done it before. But it's always good to know a little more about PW! -evan
  17. The beauty of ProcessWire is that it approaches content management without any assumption about what kind of content you're storing, or what you're going to do with it. Content is data, and data is content, and are accessible equally through the API and the GUI. You don't need to build modules to take full advantage of PW, or even make templates -- you can just include PW in any PHP script and have full access to its API. So yes, it would be extremely easy to build a custom web application on PW. You can just think of it as a way to interface easily and safely with MySQL. It also happens to have a wonderful GUI backend, objects for santizing user input, and managing sessions.
  18. I ended up going with soma's suggestion, and just storing the alternate title as field sort_title in the Page. Here's the function I made, triggered by the hourly LazyCron: function createSortTitles(HookEvent $e) { $items = wire('pages')->find('template=item'); foreach ($items as $item) { if ($item->sort_title=="") { $item->setOutputFormatting(false); $new_title = (preg_match( "/^(the|a|an)\s/i", $item->title)) ? substr(strstr($item->title," "), 1) : $item->title; $item->sort_title = $new_title; $item->save(); } } } For some reason I couldn't get the selector sort_title='' to work correctly -- it would only return a portion of the Pages. Hence the conditional instead. -evan
  19. That'll work, but as soma said, I'll have to store that value in the Page in order for it to be alphabetized as I want it to. Thanks! -evan
  20. Yeah, I was thinking that. I guess that'll have to do. -evan
  21. Just to clarify, I'm not looking to exclude Pages that begin with the/a/an, but rather alphabetize them by the second word if they do start with any of those. For example, given these Page titles: Aguirre, the Wrath Of God The Wild Blue Yonder Cave of Forgotten Dreams Stroszek Lessons of Darkness A Heart Of Glass It should produce: Aguirre, the Wrath Of God Cave of Forgotten Dreams A Heart Of Glass Lessons of Darkness Stroszek The Wild Blue Yonder What would be amazing if there was an optional field in find() that would let you call up a PHP function, in which you could manipulate the results. Unless, of course, you can do something like that already. -evan
  22. Hi, Is there an easy way to add rules to the "sort" selector, or otherwise manipulate search results directly with PHP? I'm trying to sort results by Page title, but I want to ignore any initial "the", "an", or "a." I know I can export the results into an array, manipulate them, and then display them, but that would disrupt pagination, and seems clunky. Surely there's an elegant solution? Thanks! -evan
  23. Anyone else have their submit button end up in weird spot? If I float the element one way or another, it's fine, but since it's within an iframe I can't just tack the CSS on. Many of my fields are 25% or 50% width, which might have something to do with it. Using the latest OS X Chrome, seems to do it in OS X Firefox 19.0.2 as well. I also had to add a Z-index to the modal dialog, as it ended up under some of my own DIVs. Maybe that should be added to the release? This'll be incredibly useful, thanks!
  24. Was this issue ever resolved? The code below will fail when given the string "well, I": $query = $sanitizer->selectorValue($input->get->q); $this_results = $pages->find("template=item, body|title|artists.title%=$query, sort=-posted, limit=10"); The error output: Error Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in /home/public_html/wire/core/Selectors.php line 165) #0 /home/public_html/wire/core/Selectors.php(190): Selectors->create('I', '', '') #1 /home/public_html/wire/core/Selectors.php(63): Selectors->extractString('template=item, ...') #2 /home/public_html/wire/core/Pages.php(132): Selectors->__construct('template=item, ...') #3 /home/public_html/wire/core/Wire.php(269): Pages->___find('template=item, ...') #4 /home/public_html/wire/core/Wire.php(229): Wire->runHooks(Array, Array) #5 /home/public_html/site/templates/section.php(92): Wire->__call('find', Array) #6 /home/public_html/site/templates/section.php(92): Pages->find('find', Array) #7 /home/public_html/site/templates/home.php(78): include('/home/msvalerie...') I'm using PW 2.2.2. Nevermind, disregard -- editing the wrong template. How embarassing...!
  25. Hi, I'd like to create a permission that allows users of a certain role to create users of another role -- in this case, the business owners ('editor' role) to create users with a 'vendor' role. What's the best way to achieve this, without making them a superuser? Too complicated, easy? Thanks! -evan
×
×
  • Create New...