-
Posts
10,902 -
Joined
-
Last visited
-
Days Won
349
Everything posted by adrian
-
Untested, but I think this should do the trick: $page->images->sort("title"); Then you can foreach through them. Although you might have some issues with the numbers in the filenames, in which case you might need to make use of PHP's natsort: $images = $page->images->getArray(); natsort($images); $reversed_images = array_reverse($images); $sortedImages = new WireArray(); $sortedImages->import($reversed_images); $page->images = $sortedImages;
-
Statistics and GUI admin module question
adrian replied to eincande's topic in Module/Plugin Development
Firstly, check out this: http://processwire.com/talk/topic/4147-excel-like-crud-in-pw-using-handsontable/ As for selectors and pages/fields vs a dedicated table and direct SQL. I have taken both approaches with PW and will continue to use both, depending on the complexity of the data. You can do an awful lot with selectors, but I do think that sometimes it makes more sense and is in fact necessary to use a dedicated table/sql. Of course you can always load all the data into an array and use php to do your calculations - it really depends on the volume of data you are dealing with and also how often this data is updated. One approach I have taken is to have a script that runs after data is changed. This script calculates all the stats etc and populates PW pages/fields with the data that is to be displayed to the end user. One tool that might save you some time is diogo's custom admin pages module: http://mods.pw/4Y Hope that helps as a starting point. I am sure others will chime in with more ideas. -
Hi ssmith and welcome to the forums. How are you creating the dropdown menu? Are you using Soma's navigation module? Are all the children still published and not hidden? Did you by chance change their template to one that is excluded in the selector that grabs the items for the menu. Lots of possible reasons. If none of the above helps, could you post the selector you are using and also the outputted list that is being used to create the menu as well as the any relevant css classes that might be hiding the children.
-
No worries teppo - things are always changing - even Flowplayer tries to use mp4 with native html5 players now. Unfortunately server-side conversion is a little tricky. ffmpeg can do it fine with exec calls, but that rules out servers with exec disabled, safe mode on etc. Antti - not sure about using a cloud service - they are both paid services - maybe if there was a free one available? Maybe I shouldn't worry about the format conversion at this stage - just make sure people know to only upload mp4s and maybe just make note that people can download http://www.mirovideoconverter.com/ which is free fore both Mac and Windows versions. I have found it fantastic - clients find it very easy to use - it really is a two click process. Maybe offer the option to also upload a webm version as well (also easy to create with Miro) if they want to make their videos play without a flash container in all browsers.
-
Gespinha, Not sure that I understand exactly what your setup is, but you may need to change the rewrite base in the .htaccess file: RewriteBase /cms
-
Hi benjaminE, Not sure what the problem was for you, although I have had some module issues in the past, so maybe something has been improved in a recent dev version of PW. Just in case you don't know about it, check out Soma's modules manager: http://modules.processwire.com/modules/modules-manager/ Will save the hassle of copying module files for anything that is in the modules directory.
-
eincande, If you're not enjoying git on the command line, check this out: http://windows.github.com/ Even though I use the command line on my linux servers, I have been using the Mac version of this desktop client and it's pretty nice
-
Hey Wanze, Looks like it is here: https://github.com/ryancramerdesign/ProcessWire/blob/a8024bb49785370aa2e3867bd683094663cfeabf/wire/core/PagefilesManager.php#L135 with $this->path() coming from: https://github.com/ryancramerdesign/ProcessWire/blob/a8024bb49785370aa2e3867bd683094663cfeabf/wire/core/PagefilesManager.php#L166 The createPath function is calling this: https://github.com/ryancramerdesign/ProcessWire/blob/a8024bb49785370aa2e3867bd683094663cfeabf/wire/core/Functions.php#L184 I guess it might need the mkdir recursive switch set to true in the wireMkdir function. Is that what you are looking for, or am I missing your point? I think maybe I am
-
Hey teppo, Thanks very much for your input. I hadn't seen that OO port of ffmpeg-php. I'll take a look for sure, although if we end up having this module do format conversions, neither of these options will suffice as they can't convert, so I'll need to revert to exec calls to ffmpeg itself. Not sure if I am fully understanding your point about specific formats - mediaelementjs (http://mediaelementjs.com/) allows mp4 files to be played on all browsers (desktop and mobile). It uses the browser's HTML5 player if possible and flash for those that don't support it. If you provide it with both mp4 and webm versions, then all browsers can use their native HTML5 players. So if I was going to have the module offer conversion, I was thinking it would only be for converting from whatever gets uploaded into mp4 and maybe also webm. It's my understanding that FLV is no longer a format worth considering. I actually wish webm was better supported, but unfortunately I think at the moment and for the foreseeable future we won't see Apple support it in Safari. The chart of the mediaelementjs site says that Android won't play webm, but it does. Don't look at that code too closely right now - that initial commit really was put together very quickly and I ended up hacking the thumbnail creation - I couldn't figure out how to create a new Pageimage to use that for the resize, because it needs an image field on the page to work, but I didn't want to make that a requirement, so I just went with standard GD code to resize if the "Display thumbnails in page editor?" is checked. There is probably un-needed code in there still from the FieldtypeFile I started with. Hopefully I can find some time in the next few days to tackle some of the simpler enhancements/cleanup. Definitely appreciate any help you want to give.
-
Hi everyone, This new video fieldtype extends FieldtypeFile. Video is available via: $page->video_field->url Module automatically creates a poster image of the video on upload and makes this available via: $page->video_field->poster Shows the duration of the video on the title bar, next to the filesize Stores VTT files for subtitles accessed via: $page->video_field->subtitles Formats a transcript from the subtitles, accessed via: $page->video_field->transcript Users can easily upload videos and enter VTT files. The following code is used in the template file. <video src='{$page->video_field->eq(1)->url}' poster='{$page->video_field->eq(1)->poster}' width='720' height='408' ><track kind='subtitles' src='{$page->video_field->eq(1)->subtitles}' srclang='en' /></video> Additional Settings You can additionally set a few different options in the field's Input tab: Number of poster images to generate - if you change from the default of 1, the editing user will be able to select which image they want to use for the poster image Copy poster image to dedicated image field - not necessary but gives you more options of interacting with the poster image(s) Field that you want poster images copied into - only relevant if the option above is checked Try it out (NB: the code is rough - it works, but needs cleaning up. Github: https://github.com/adrianbj/FieldtypeVideo NB: Requirements The module requires ffmpeg and ffmpeg-php, although I can make the latter optional fairly easily. I don't have any requirement checking implemented yet, so if you don't have these, you'll get php errors. Possible future enhancements Ability to specify what frame is used for the poster - either by number, and/or by offering several options to choose from Done! Push poster image to a dedicated image field Done, although could be improved Field for pasting in or uploading closed captions Done, but need to look into multi-language options etc Support for uploading multiple formats of the same video (mp4, webm, etc) and/or automated video format conversion My biggest concern, is how useful this will be to people - how many hosts actually have ffmpeg setup? Do any have ffmpeg-php? Anyone have any ideas for features they'd like to see?
- 81 replies
-
- 17
-
Hey Marty - sorry for taking so long to get back to you - busy day So you could do this with Ajax calls to a PHP script like the following. It would be called whenever someone clicks on a property. This would be a toggle approach, which may or may not be appropriate depending on how the site is set up. In this case, the cookie would store an array of the property IDs. $pid = $page->id; if (!in_array($pid, $favs)) { //add to the array if not already in it $favs[] = $pid; } else { $key = array_search($pid, $favs); unset ($favs[$key]); //remove from array if already in it } $data = base64_encode(serialize($favs)); setcookie('property_favs', $data, time() + 86400 * 100, '/'); Then to read the cookie back in, something like this: $favs = unserialize(base64_decode($_COOKIE['property_favs'])); That will give you an array of page ids that you can use to populate the user's favourites. If you want to go with a combination of javascript and PHP, you can do that also. Firstly, I recommend taking a look at this jquery helper: https://github.com/carhartl/jquery-cookie You can add the property/page id to the cookie using that and then retrieve on page load using PHP. Instead of storing an encoded array, you can also store a separated list of IDs. This example is using raw javascript: if(readCookie('property_favs')){ document.cookie = 'property_favs=' + readCookie('property_favs') + escape('|' + pid) + '; path=/'; } else{ document.cookie = 'property_favs=' + escape('|' + pid) + '; path=/'; } So if the cookie exists, then read it and add on a new pid after a pipe character and escape it so it can be stored in the cookie. If the cookie doesn't exist, create it with the current pid. The jquery cookie plugin will make this cleaner. Remember to use your developer console as it will show you the current cookie contents. In Chrome it is one of the options under Resources. In Firefox I seem to remember installing a plugin for Firebug to analyze cookies. It's really pretty easy once you play around with it. Let us know if you have any specific questions.
-
There is a bug in Page.php Easy fix though: http://processwire.com/talk/topic/4141-foundation-template-problem-in-top-nav-bar/
-
Hey Marty, If they're not logged in, then I think the only reliable option will be cookies. You just need to store the ID of the PW page that stores the property's details. You could store these in one cookie as a comma separated list. I have done this with an an image library application so that guest users can create a lightbox of images. You could get a little fancier and allow them to create more than one group of properties too. Let me know if that helps, or if you'd like I can grab some non-PW bits of code as examples of how to store and retrieve the IDs. I am sure you know this, but remember that you can use both PHP and JS to manipulate cookies, so you can save changes to their list of properties without needing a page refresh. Just make sure the expiry of the cookie is set to a year or something like that. Hope that provides a starting point.
-
Aren't cookies the best option for this? I know you guys know this already, but surely IP address is more problematic in that it can prevent other people on the same network from voting. And even people using the same ISP may not be able to vote if they end up with an IP that is already recorded. What about a combination of cookie and number of hits from the same IP address in a certain timeframe to prevent people from clearing their cookies and voting multiple times in a short time period. I would think this would also help to limit bot rating?
-
Hi Emmanuel and welcome to PW. PW does not control the frontend code at all, you have complete flexibility to write the output exactly as you need, including the adding of form labels. As an example, there are different ways to do this, but if you are using PW's built-in method for generating forms, you can do something like: $f->name = "myField"; $form->label = __("Field Title"); Obviously you need to build the other elements of the form, but you get the idea. You can of course use normal HTML: <label for="myField">Field Title</label> The advantage to the first approach is that the label can be made translatable using PW's language support. You can use Bootstrap, or any other framework you wish. Ryan has recently developed a Zurb Foundation profile for PW, but it is not too difficult to use any of the other frameworks. http://modules.processwire.com/modules/foundation-site-profile/ http://processwire.com/talk/topic/2411-bootwire-basic-twitter-bootstrap-profile/ http://processwire.com/talk/topic/3832-release-unsemantic-site-profile/ PW supports multilanguage: http://processwire.com/api/multi-language-support/ You can always access the database directly. It is a standard MySQL database so you can view it easily with something like PHPMyAdmin. You can also of course query it directly using SQL statements, but in most cases using PW's API and selectors is much easier. Hope that helps get you on your way to CMS nirvana
-
This looks fantastic Jonathan. I know that Ryan was planning on releasing something along these lines, based on the recommend button in the modules directory: http://processwire.com/talk/topic/4206-thinking-about-a-likerecommend-button-module/?p=41222 I am curious to see what overlap there is between these two modules - hopefully they will both have their strengths and will be useful for different scenarios. Thanks for this!
-
If I understand you correctly, this sounds like a job for Hanna Code: http://mods.pw/4b
-
Can't empty trash or delete indivdual trashed pages
adrian replied to Rob's topic in General Support
Thanks for the fix Ryan - that error was popping up while developing a module! -
But of a rush, so not sure if this is actually related to your problem, but take a look here: http://processwire.com/talk/topic/957-how-to-find-elements-with-empty-field/ Does your selector work without the additional attempt to get a null/empty value?
-
Take a look at this post: http://processwire.com/talk/topic/4339-directory-creation-install-errors-when-restarting-install/ You might find that your site is actually installed properly Try ignoring those errors, enter your admin account info and proceed and let us know how you go.
-
Well chances are that you don't have an images field in that template - that is why it can't find the first() image from it. That code won't be a complete drop-in example for you. I don't imagine you need the entire <div class="portfolio-image-holder"> xxxx </div> section. Start by removing that and see what you get.
-
How rude of me - I point to your post as a reason for this thread and then forget to mention your module
-
I thought I'd start this thread so we could all share our favorite debugging techniques. The idea for this came from this post by Soma: http://processwire.com/talk/topic/4416-delete-user-when-page-is-deleted/?p=43320 and some of the followups with other suggestions. Here's one that I find really useful. It allows you to output content to the browser's console from PHP. It sends content from PHP through javasacript's console.log(); Not as powerful as FirePHP etc, but simple and easy to use. Put this function somewhere that it will be available to all your template files. function debug ($data) { echo "<script>\r\n//<![CDATA[\r\nif(!console){var console={log:function(){}}}"; $output = explode("\n", print_r($data, true)); foreach ($output as $line) { if (trim($line)) { $line = addslashes($line); echo "console.log(\"{$line}\");"; } } echo "\r\n//]]>\r\n</script>"; } Then you can simply put these anywhere in your templates: debug('test'); debug($variable); debug($array); This keeps your page content clear of debug messages and is easier then looking in log files, like if you were to use error_log() What are your favorite techniques?
- 17 replies
-
- 12
-
It doesn't really help you, but this is the culprit line: https://github.com/ryancramerdesign/ProcessWire/blob/a8024bb49785370aa2e3867bd683094663cfeabf/wire/core/Pagefiles.php#L264 Ryan may consider adding @ to the list of allowed characters. I don't think there are any reasons why it needs to be removed. I think historically it wasn't allowed in filenames, but now should be fine. Some more reading: http://en.wikipedia.org/wiki/Filename#Comparison%5Fof%5Ffile%5Fname%5Flimitations http://superuser.com/questions/358855/what-characters-are-safe-in-cross-platform-file-names-for-linux-windows-and-os
-
Firstly, you need to make the name of the checkbox field an array by appending [] echo "<input type='checkbox' name='type[]' value='{$t->id}'>{$t->title}<br>"; Then take a look at Ryan's example: http://processwire.com/talk/topic/3061-how-to-save-field-page-type-checkbox/?p=30229