Jump to content

adrian

PW-Moderators
  • Posts

    11,263
  • Joined

  • Last visited

  • Days Won

    374

Everything posted by adrian

  1. This should do it: ^(?:0?[0-9]|1[0-2]):[0-5][0-9] [ap]m$
  2. This module allows you to automatically rename file (including image) uploads according to a configurable format This module lets you define as many rules as you need to determine how uploaded files will be named and you can have different rules for different pages, templates, fields, and file extensions, or one rule for all uploads. Renaming works for files uploaded via the admin interface and also via the API, including images added from remote URLs. Github: https://github.com/adrianbj/CustomUploadNames Modules Directory: http://modules.processwire.com/modules/process-custom-upload-names/ Renaming Rules The module config allows you to set an unlimited number of Rename Rules. You can define rules to specific fields, templates, pages, and file extensions. If a rule option is left blank, the rule with be applied to all fields/templates/pages/extensions. Leave Filename Format blank to prevent renaming for a specific field/template/page combo, overriding a more general rule. Rules are processed in order, so put more specific rules before more general ones. You can drag to change the order of rules as needed. The following variables can be used in the filename format: $page, $template, $field, and $file. For some of these (eg. $field->description), if they haven't been filled out and saved prior to uploading the image, renaming won't occur on upload, but will happen on page save (could be an issue if image has already been inserted into RTE/HTML field before page save). Some examples: $page->title mysite-{$template->name}-images $field->label $file->description {$page->name}-{$file->filesize}-kb prefix-[Y-m-d_H-i-s]-suffix (anything inside square brackets is is considered to be a PHP date format for the current date/time) randstring[n] (where n is the number of characters you want in the string) ### (custom number mask, eg. 001 if more than one image with same name on a page. This is an enhanced version of the automatic addition of numbers if required) If 'Rename on Save' is checked files will be renamed again each time a page is saved (admin or front-end via API). WARNING: this setting will break any direct links to the old filename, which is particularly relevant for images inserted into RTE/HTML fields. The Filename Format can be defined using plain text and PW $page variable, for example: mysite-{$page->path} You can preserve the uploaded filename for certain rules. This will allow you to set a general renaming rule for your entire site, but then add a rule for a specific page/template/field that does not rename the uploaded file. Just simply build the rule, but leave the Filename Format field empty. You can specify an optional character limit (to nearest whole word) for the length of the filename - useful if you are using $page->path, $path->name etc and have very long page names - eg. news articles, publication titles etc. NOTE - if you are using ProcessWire's webp features, be sure to use the useSrcExt because if you have jpg and png files on the same page and your rename rules result in the same name, you need to maintain the src extension so they are kept as separate files. $config->webpOptions = array( 'useSrcExt' => false, // Use source file extension in webp filename? (file.jpg.webp rather than file.webp) ); Acknowledgments The module config settings make use of code from Pete's EmailToPage module and the renaming function is based on this code from Ryan: http://processwire.com/talk/topic/3299-ability-to-define-convention-for-image-and-file-upload-names/?p=32623 (also see this post for his thoughts on file renaming and why it is the lazy way out - worth a read before deciding to use this module). NOTE: This should not be needed on most sites, but I work with lots of sites that host PDFs and photos/vectors that are available for download and I have always renamed the files on upload because clients will often upload files with horrible meaningless filenames like: Final ReportV6 web version for John Feb 23.PDF
  3. Thanks Ryan, Not sure why I actually never tried that. I have used InputfieldFile::fileAdded in my SVG rasterizer module, so it should have been on my radar. Anyway, for this module I have gone with InputfieldFile::processInputAddFile and it seems to be working great. New version is on Github and here is the official module support post: http://processwire.com/talk/topic/4865-custom-upload-names/ Thanks again for seeing me through this one
  4. Sorry for yet another post, but I just fixed a bug that prevented certain fields being exported and assigned to templates in some situations. Not the most elegant solution (repetitive declaration in the JSON file), but it should work for the moment until I have time to rework slightly. Grab the latest version from Github for testing
  5. Sorry - maybe my wording wasn't very clear - I am not having any problems - the "also" was referencing Martijn's comment.
  6. Hi nate and welcome to PW. I don't have Form Builder so I might not be of much help, but you should message Ryan to gain access to the form builder forum board. Normally in PW ->get returns only one thing. ->find will return an array and you can append ->last() after the selector to get the most recently saved, depending on how the sort order is set up. Unfortunately I am not sure how this works with form builder, but I am sure someone else will chime in with an answer shortly
  7. I know it doesn't help, but I am also having no problems with 2.35 (actually very latest dev today) and Safari 6.1 Not sure why or how exactly, but does setting: $config->sessionFingerprint = false; help at all? Are there any other settings in the config.php that are different between the site with the new admin theme and the other site you tested?
  8. Brent - sorry, I didn't read that you were only doing an InputField at the moment. From my understanding of things, a new FieldType is likely your only option. Actually, I wonder if you can have a separate field that stores the selector. Maybe that hidden field you are using is an actual PW field, or you take the content of your existing hidden field and copy it to an actual PW field (visibility set to hidden) on page save. Then on form render it is grabbed and populates the selector text field. Something like that anyway. Not sure how well this would work - seems like it should be possible, but maybe someone else will chime in with a better idea, or flame this one
  9. Hi sshaw, Thanks for your enthusiasm on this. I am still trying to figure out what I think is the best approach here. Here are the functionalities on my list that I would like to see: Code snippet repository that anyone can contribute to Snippets can be "installed/updated" on your site with one click An admin interface that handles running these snippets in different ways, so no need to copy/paste code anywhere. On-demand code execution - for admin type tasks, such as Ryan's clean-files.php script mentioned above Triggered by a specific PW hook Injected into specific template files Embedded into an RTE the way the Hanna Code works As I mentioned above, I think this could really remove the need for module creation in many cases. I wonder if this needs to be a new module, or if extending Hanna Code would work best. PS Just read your last post properly - sounds like we are on the same wavelength here I am definitely happy to take the lead on this, although I'd really like to get some input from the PW gurus on this - in particular Ryan, what do you think about the idea of using Hanna Code as a base for this. I don't want to bloat it with things some users won't want, but I also don't want to have a completely separate module to store snippets that can't be embedded like Hanna does. Maybe the new module could just hook into the Hanna snippets DB table. Any thoughts?
  10. Sounds interesting. You should be able to save the selector by defining a new database field for your fieldtype (in addition to the standard "data" field). This approach is used in a few fieldtype modules, like: http://modules.processwire.com/modules/fieldtype-phone/ http://modules.processwire.com/modules/fieldtype-dimension/ http://modules.processwire.com/modules/fieldtype-map-marker/ Have a look at the getDatabaseSchema and updateDatabaseSchema functions in those modules, along with their dabatase tables and you should get the idea. Hope that helps. Also, this is just a quasi-related module that I'd reference here for the sake of it: http://modules.processwire.com/modules/fieldtype-pages-selector-query/
  11. Hey Ryan - thanks for getting back to me - I think the module will be really cool once I get this figured out! I just tested on a brand new PW dev installation and I still can't Pagefile::install to work. This is my hook (line 74 of my module) which doesn't work: $this->addHookBefore('Pagefile::install', $this, 'customRenameUploads'); As soon as I make setFilename hookable and use the following hook instead, it works perfectly: $this->addHookBefore('Pagefile::setFilename', $this, 'customRenameUploads'); Maybe I am missing something obvious This comment - "I mention this because it's not uncommon when doing data conversion jobs to put the file right in the destination directory before adding it to ProcessWire's data." has me thinking. I am not really sure what you mean by data conversion jobs, but I am just using PW upload dialog to get the images into the system and I am calling "addHookBefore" so I would think it should happen before the file is copied into the assets destination folder. I have attached a version of the module with the install version of the hook, which is the only difference to the version on github, execpt for a error_log call to see if the function is actually being called at all from the hook. Thanks for looking into it. ProcessCustomUploadNames.module ProcessCustomUploadNames.js.txt
  12. Try this: <?php echo $page->find("name=projects")->url ?> or you can use the path of the page, eg. if it is at the root of you site you can do: <?php echo $page->find("/projects/")->url ?> Also, be sure to install the selector test module - will help you figure out the right selector more easily: http://modules.processwire.com/modules/process-selector-test/ EDIT: Be sure to take nik's advice below about get vs find!
  13. I know it might seem confusing and unintuitive at first, but this is the PW way and I am certain you'll be convinced of the value of the approach in time. Here is some more reading on page fields: http://wiki.processwire.com/index.php/Page_Field Have a read of this thread from here on: http://processwire.com/talk/topic/201-fieldtype-select-aka-drop-down/?p=13637 We have all struggled with what seems overly complicated, but it really does work and it works well! Page fields reference child pages, but they are used as a way to allow the user to select from these items (pages) using select, multiselect, radio etc. Try not to think of pages as just being pages - they are used for everything in PW. Maybe someone else will chime in and be better able to explain how it all works, but I would say just dive in and try it - it will soon make sense once you have tried it.
  14. Take a look at this video for an explanation of how page fields work: http://processwire.com/videos/page-fieldtype/ They can be a little tedious to set up, but they are so very powerful compared to the way most CMSs handle storing content for select/radio etc fields that they are more than worth the effort. That module I pointed you to can make the entire process much quicker though - give it a try
  15. In the admin or a front-end form? In the admin you need to use the page fieldtype and then on the details tab choose single and on the input tab choose Radios in the input field type section. The page field select creator module can make this setup much easier: http://modules.processwire.com/modules/process-page-field-select-creator/ If you are after the radio buttons in a front end form instead, let us know and we'll show you through that.
  16. I would say that lots of us are running the dev version for production websites. Key thing is to check that all the functionality you need is working fine, especially any multi-language features as there have been some recent changes there. If it all works as expected, go for it
  17. Well you can modify the _init.php and _out.php files to have a conditional check. Something like on the first line of each: if(!$useWrappers) return; Then in your template file do: $useWrappers = false; Or something along those lines - whatever fits best with your workflow.
  18. I think I see your point now - maybe if you can explain exactly what you need the hook to do it might be easier to figure out the best approach.
  19. You can add hooks in the template files themselves. Here is a great post about hooks by teppo: http://www.flamingruby.com/blog/using-hooks-to-alter-default-behavior-of-processwire/
  20. Here's a cool approach from WillyC: http://processwire.com/talk/topic/1799-routes-and-rewriting-urls/?p=16708 Or you could add a line to your htaccess file (as devcow shows), or if this is a change from what the parent page used to be called this module would do the trick, but you need to have it installed before the change in the name of the page, http://modules.processwire.com/modules/page-path-history/ I guess you could change the name back, install the module, and then change the name again. It's an awesome module to have installed right from the start of development! EDIT: If you go with the htaccess route, you might find something like this useful so that all posts are taken care of: RewriteRule ^news/(.*)$ /blog/$1 [L,NC,R=301]
  21. Peter, I am not sure if http://www.synbioproject.org/sbmap/marker/3210/ is an actual PW page or not, but there is certainly no reason that you couldn't use a PW page to generate the code on that page. There are so many ways you could go about this - really up to you and how you have the content structured. You could set up a parent marker page and marker.php template and allow URL segments and use the ID in the segment as the variable to grab the content from other parts of your page tree. Would that approach work well for you, or do you already have the content that you want in the InfoWindow already set up in child pages? It is possible that Ryan is using URL segments in a sbmap.php template file with the first segment to determine markers and the second to get the ID of item and use those to generate a selector to get the content from somewhere else in the page tree.
  22. Are right - sorry I didn't read your initial post properly. I am still not quite sure where you are exactly having the trouble. Is it figuring out how to generate a URL like: http://www.synbioproject.org/sbmap/marker/3210/ in PW, or how to populate it's output with the correct content, or how to set the marker.rcID to the right value? Tell us more an we'll get you sorted
  23. Hi Peter, Something like this would work: foreach($page->children as $location){ echo "\n\t\tRCDMap.addMarker('{$location->title}', {$location->geo_address->lat}, {$location->geo_address->lng});"; } I haven't filled in all the elements for the marker, but hopefully that should give you the idea. Note that the geo_address comes from using the PW map marker fieldtype module.
  24. It is easy to get content from other pages in PW, but the actual method will depend on your needs. This is one example that allows you to echo out the body fields from all the child pages that match a given selector. foreach($page->children(selector_to_get_specific_children) as $content_for_page){ echo "<p>$content_for_page->body</p>"; } You could also loop through any other pages you want be using a selector like this: foreach($pages->find(selector_to_get_pages) as .... Does that make sense?
  25. Great looking site! I especially love the responsive design changes. The thumbnail hovering doesn't seem to have any issues for me - OSX Chrome 30.0.1599.101 The only thing I find a little confusing is the "In English". It makes me thing the site is always actually in english. I think if it were just worded as "English" it would be more logical. I also wonder if perhaps the selected language should be the one highlighted in orange, although not totally sure on this as the logic of the alternate language looking like a button (in orange) also makes sense
×
×
  • Create New...