-
Posts
11,264 -
Joined
-
Last visited
-
Days Won
374
Everything posted by adrian
-
You will want something like this: public function ___execute() { $this->exportExcel(); } public function exportExcel($event) { header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=name.xls"); header("Pragma: no-cache"); header("Expires: 0"); $this->outputExcel(); exit; } public function outputExcel($data) { // your php://output" code } I used something like this is in: http://modules.processwire.com/modules/table-csv-import-export/ In that module you can test the behavior of downloading directly from a PW menu item by going to Pages > Admin > Setup > Table CSV Export and removing the hidden flag, then go to Setup > Table CSV Export and it will start a download directly from the process attached to that page. The module is not designed to be run directly from that helper page, but it will show you that it can work that way! Hope that helps to get you started.
-
https://github.com/ryancramerdesign/ProcessWire/issues/808 Feel free to add a comment about your experience if you want
-
kongondo was saying that the page he linked to has all PW versions all the way down to 2.2.4 - it includes 2.4, 2.3 etc. Weirdly it doesn't have 2.5 though - which you really should be using
-
Checking if a page has a FieldtypeMulti field
adrian replied to gRegor's topic in Module/Plugin Development
I am not going to be much help, other than to say that your code works fine with empty Page fields, File fields, etc - ie other field types that extend FieldtypeMulti. Can you can confirm the same at your end? If so, then it suggests it must be something specific to your FieldtypeWebmentions. Can't see why it would make any difference at all, but have you tried iterating through the page's template? foreach($page->template->fields as $field){ -
Looks like you are typing the address into the www field without the http:// so you can either make sure you do that, or you can do this in your template: <?php echo "<a href='http://{$image->www}'>Click Here for the WEBSITE</a>";?> I would recommend the former approach though because you never know if it will be a http or https site if you do it from your template. Nevermind - not thinking this morning - listen to kongondo below
-
$page->children("sort.... from smallest to greatest number
adrian replied to Matte85's topic in General Support
I don't think you'll be able to do that in a PW selector, but you can sort it after you have the page array. I asked this question a long time ago - that thread should help you: https://processwire.com/talk/topic/3392-emulate-natsort/ I am not sure if natsort works with comma decimals, but maybe there is an alternative php function you can use if needed? I am sure one of the european PW devs will have some input if this is an issue. PS Welcome to the forums! -
DownloadGuard - Module for restricted access on downloads
adrian replied to backes's topic in Modules/Plugins
Ok, I see - I manually deleted those and reinstalled and it works now. I still don't really like the downloads.ext filename, but maybe that's a personal thing. Also, the dg_download template still has URL Segments enabled, but they aren't needed. Doesn't really matter since that template throws a 404 anyway, but would be cleaner to not enable it. Thanks again for putting this together! PS Not everyone has their templates folder writeable by PHP, so you might want to add a note and also handle any permission errors if those template files can't be added/removed. -
DownloadGuard - Module for restricted access on downloads
adrian replied to backes's topic in Modules/Plugins
OK, the apache check is working - I am getting the correct line in the htaccess file, but there is still a problem with the download URL. You have the URL segments settings correct, but the dg_download.php file is still the one with: $hash = $input->urlSegment1; echo $modules->get('DownloadGuard')->validateDownload($hash); That now needs to be in the dg_downloads.php file and changed to grab the second URL segment, since the first one would now be "hash". Also, doing that will result in all the downloaded files being named "downloads.ext" rather than the name of their child page. -
DownloadGuard - Module for restricted access on downloads
adrian replied to backes's topic in Modules/Plugins
More comments for you! When uninstalling, I am not sure about deleting the Downloads page tree and the required templates - this could result in a LOT of data loss with a simple click of a button. kongondo has struggled with this and his Blog module and went with a separate, optional, cleanup script before uninstall. I think you need to do something along these lines, or at least, don't remove these things. Maybe you should limit the uninstall to deleting all the .htaccess files and the module files, but nothing else? Also, looks like there is an error with the install routine and making use of the new PW "Which URL segments do you want to allow?" option. Looks like you are trying to set it with this line: $t->urlSegments = array('regex:^hash/[0-9a-zA-Z]+$'); but you have that on the dg_downloads template, rather than the dg_download one, which is where it is needed. Hope that helps! EDIT: Now I see what is going on with that non-working "hash" url - that would have worked, but you didn't have urlsegments enabled for the dg_downloads template, even though you had tried to set the regex rule there. Anyway, not sure which way you want to go, but at the moment, it is half and half and therefore not working -
DownloadGuard - Module for restricted access on downloads
adrian replied to backes's topic in Modules/Plugins
Hi Martin, Thanks very much for this - looks very useful! Just having a look through it now. The first thing I noticed is the htaccess rules. You will need to add support for apache 2.4+ which means that: order allow,deny deny from all no longer works. Instead you need: Require all denied but of course you need to support older versions, so you will need to detect the apache version: http://php.net/manual/en/function.apache-get-version.php As for testing it, I am currently getting a 404 for this: http://pwtest.dev/downloads/hash/aa3033f10280fc120dbec5f3877dbcfa54ccd4d1ba5e7 I checked this link: http://pwtest.dev/downloads/test/aa3033f10280fc120dbec5f3877dbcfa54ccd4d1ba5e7 where "test" is the name of the child page under Downloads that I created. This wants to work, but first I needed to change this line: $max->save(); to: $max->save("dg_downloads"); because I was getting a "Call $page->setOutputFormatting(false) before getting/setting values that will be modified and saved" error, although not actually sure since you were already doing this. Anyway, saving just the field works fine! -
This is something that I am sure horst will follow up on, but as far as I know, the only thing you need to do (or can do), is to make sure the filename matches the conventions for variations: https://github.com/ryancramerdesign/ProcessWire/blob/7b9730d43e6eda8bd27841a4811a1b9737bfe903/wire/core/Pageimage.php#L484 If you need a different filename format that isn't automatically detected by the core isVariation() method that I pointed to above, you can hook it and modify like I have done here: https://github.com/adrianbj/ImageRasterizer/blob/master/ImageRasterizer.module#L243 Hope that helps until our image expert sees this!
-
Great to hear. I have committed another update that removes those checks - they really aren't very useful anyways as they can be manipulated in the browser and aren't always provided (hence the errors you were getting). Can you please confirm that all the other multiple Table field and issues with only one row importing are also now solved? Thanks for your help in getting this all fixed.
-
I am thinking it must be my mimetype checks. Can you please try replacing: if(($csv_file_extension == 'csv' || $csv_file_extension == 'txt' || $csv_file_extension == 'tsv') && ($csv_type == 'text/plain' || $csv_type == 'text/tab-separated-values' || $csv_type == 'text/csv')){ $this->session->{$fieldName . '_csv_data'} = file_get_contents($_FILES[$csv_filename]["tmp_name"]); } with: if($csv_file_extension == 'csv' || $csv_file_extension == 'txt' || $csv_file_extension == 'tsv'){ $this->session->{$fieldName . '_csv_data'} = file_get_contents($_FILES[$csv_filename]["tmp_name"]); } and see if that allows the csv upload to work.
-
Great work - just playing with it now and it's really slick - thanks for the contribution! One thing I noticed - not a big deal, but when you search by text, with "From all categories" selected, it duplicates the matching icons. Also, out of interest, did you see this: http://processwire.com/blog/posts/processwire-core-updates-2.5.15/#new-icon-selection-module-in-the-core It's an Inputfield, but not a Fieldtype, so it can't be used in templates as is, but I wonder how these two modules could be consolidated, or maybe they should remain completely separate - just thinking out loud - I have no idea whether Ryan is planning a matching fieldtype for his module.
-
Fieldtype: Select (AKA Drop Down) Multi Language
adrian replied to KaMeKuN's topic in General Support
@KaMeKuN - today's dev commits from Ryan provide a new fieldtype that supports select options with multilanguage support without relying on pages - perhaps you would prefer this approach. Have a read about it here: https://processwire.com/api/modules/select-options-fieldtype/#multi-language-translating-options -
There is this new fieldtype: http://modules.processwire.com/modules/fieldtype-image-extra/ But be sure to look at my comment about some things that need fixing: https://processwire.com/talk/topic/7910-module-fieldtype-image-extra-multi-language/?p=85654 So long as you don't have debug mode on, that warning won't show and therefore won't break things. Otherwise, you can use a PageTable field (core module, but needs to be installed) with a template that contains an images field along with a URL field, and any other metadata fields that you might want. Let us know if you need more info about this field type (https://www.google.com/?q=site%3Aprocesswire.com%20%22pagetable%22) You can also just use child pages - one for each image - since you seem to be relatively new to PW I'll assure you that this is not actually a bad idea, even though it may seem like it at first glance
-
I added a poll for you to this thread. Let's see how everyone responds
-
The simplicity and scalability of PW for front end dev?
adrian replied to kathep's topic in General Support
Oops - very sorry about that - I should have looked back at your site to check before making that faux pas -
The simplicity and scalability of PW for front end dev?
adrian replied to kathep's topic in General Support
Love your research Kathy - we might need to chat at some point I'll have to give you some background to that statement in a PM at some point when I find some time. -
Love the enhancements, but I am getting something weird - if I only enter 2 characters and then hit enter, it creates a new tag for to match those 2 characters, and then randomly adds a second tag to the list. Then hit enter and I get this:
-
Thanks @RJay - I think I have managed to fix all those issues - I hadn't tested with multiple Table fields on the one page. Please check the latest version and let me know how it goes for you. PS There was nothing wrong with your CSV file.
-
Hi RJay - wow, that doesn't sound good Yes, please PM me the file. Also, does the same CSV file work on a template with only one Table field?
-
No offense kongondo, but I would actually really like to see the inline way of adding new tags/pages - Since they are already typing, I think that is what many users would expect to be able to do, rather than needing an additional field. Nico's https://github.com/NicoKnoll/TextboxList works like this, but of course it would be great to have this in this module so everything is connected to the page field.
-
There is also this - paint hasn't even dried on it yet https://processwire.com/talk/topic/8955-inputfieldchosenselect/ You can type or select and it has autocomplete. Surprised you didn't mention it @LostKobrakai
-
I really like: http://modules.processwire.com/modules/inputfield-select-multiple-transfer/ It is kinda like an ASM, but with a built in live filter bar - works pretty nicely, although the search bar could do with some css tweaks to make it a little larger.