-
Posts
16,793 -
Joined
-
Last visited
-
Days Won
1,540
Everything posted by ryan
-
Very cool Adrian! A few suggestions: Make your version number 2 rather than 002. PHP might interpret that as Octal or something. Add an ___install() method that does a class_exists('imagick') and throws a WireException if it doesn't. Make the ___install() method add the document_pdf field, or make the module configurable so people can tell it what field to use. Put it on GitHub. Add to the modules directory. Profit! (as Adam would say)
-
Create a role called "top-level-editor" (or whatever you prefer). Give that role edit permission, but not delete permission. If you want the role to be able to sort children of these top level pages, then you'll want to assign page-sort permission to the role as well. Assign that role to the template used by your top level page(s). Create another role. We'll just call it "editor". Give that role edit, delete, move and sort permission. Assign that role to the templates indicated, but not the templates where you assigned top-level-editor. Don't forget to assign both of these roles "top-level-editor" and "editor" to your user(s) that you want to have this access. I think this was the part WillyC was trying to communicate.
-
I had to go get some coffee after seeing that photo. Just got this thing yesterday called an Aeropress. The guy that invented the Aerobee (frisbee) apparently locked himself away on a multi-year caffeine binge and came up with this clever device that supposedly makes the best coffee in the world. The coffee beans were just roasted from a place a block away from here, tasty.
-
You can match in either the filename, description, or tags via any of the DB-find functions too. $pages->find("files=myfile.jpg"); $pages->find("files%=myfile"); $pages->find("files.description*=some text"); $pages->find("files.tags%=mytag"); One thing to note is that description and tags have fulltext indexes, but the actual filename doesn't. As a result, if you need to perform a partial match on filename, you can only use the "%=" operator.
-
Roy I think something may be amiss with the file you downloaded, or with whatever program is unzipping it. Also, the link you mentioned is to 2.2.9. Be sure you are grabbing 2.3.0, which is linked from the homepage. GitHub keeps changing the ZIP download URL, so I had to update it yet again as recently as yesterday (this time replacing /zipball/ with /archive/).
-
I'm wasn't seeing that behavior here the other day, as several other pages matched when I tested, but I only copied/pasted enough in here to communicate. I need to go back and test again when in a non-default language. Just to confirm, this is occurring in a non default language?
-
Ability to define convention for image and file upload names
ryan replied to adrian's topic in Wishlist & Roadmap
My opinion is that a good default behavior is to retain the original filename as much as possible. Otherwise you lose relation to the original file on your computer. Usually when a CMS auto-generates filenames, it's because they don't have another means of relating back to the source (Page/id), are using it to define a sort order, or they don't want to go to the effort of making sure the filename is secure (auto-generated names have no user input). Auto-generated names are the quick and dirty way out for a CMS. Never realized they would actually be desirable. If you have a preference for it to auto-generate names like that, it could certainly be done though. One way to accomplish it would be to make a module that hooks before Pagefile::install and rename the file, and send the new filename to the function. That function receives a single argument of just the filename to add. That filename can be local or http, so you'd only want to attempt a rename if local. public function init() { $this->addHook('Pagefile::install', $this, 'hookPagefileInstall'); } public function hookPagefileInstall(HookEvent $event) { $filename = $event->arguments(0); if(strpos($filename, '://')) return; // don't attempt to rename http-based files $page = $event->object->page; // page that will own the file $info = pathinfo($filename); // PHP's pathinfo() function $n = 0; // find the next available filename do { $n++; $newFilename = "$info[dirname]/{$page->name}-$n.$info[extension]"; // my-page-name-1.jpg } while(is_file($filename)); rename($filename, $newFilename); $event->setArgument(0, $newFilename); // update the argument to the install function } The above was written in the browser and not tested, so may need adjustments before functional. What it does is rename the file before it gets added. The do loop may not actually be necessary here, but that is just to account for the possibility that the directory (PHP's upload dir) already has a file with the target name in it. ProcessWire already takes care of adding numbers to files that are placed in it's own assets/files/ dirs. -
Makes sense to me. If you guys want to post a replacement function here, I'll plug it in (or pull request, whatever you prefer).
-
Two issues I can spot here: 1. Your inputs have no "name" attribute. I think you want them to have name="date_start" for one and and name="date_end" for the other. 2. It looks like the PHP code overwrites date_start if both are specified. I'd suggest doing this instead: $selector = ''; if($input->post->date_start) { $startdate = strtotime($input->post->date_start); if($startdate) $selector .= "date_start>=$startdate, "; } if($input->post->date_end) { $enddate = strtotime($input->post->date_end); if($enddate) $selector .= "date_end<=$enddate, "; } // then right before your $pages->find(): $selector = rtrim($selector, ", ");
-
Who is Dr. Joseph Murphy? Those books I linked to are classics, ones that I have in print and that I think are worth reading in full once a year. They might seem like they are just about money, but that's just how they attracted readership–the concepts are actually much bigger.
-
I thought that the MODX move was interesting too (as were the EE changes a few months earlier). I don't think it affects anything about ProcessWire, other than that it seems to drive more users here. We won't be following the path of MODX, in case anyone was worried. We get paid by the sites and apps that we develop with ProcessWire, and by the commercial support of modules like FormBuilder and ProCache. I don't have any inside knowledge on the changes at MODX, and may not understand the full scope of them, but here's my outsider opinion about it… I can understand why it is shocking to folks that use MODX, because it kind of destroys the perception of MODX as being a big and stable player. In my mind, they were a big and successful company, and I think that was a lot of other people's perception too. Why would they ever have to rely on a little hosting company with a toilet name and an HTML5 logo? MODX is way above this, or so I thought. The changes instead reveal reality that's probably always been there… MODX is a labor of love rather than profit, as most open source projects are (including us). But MODX has grown big enough in user base that keeping the whole ship afloat means having a team people that dedicate lots of time to it. These people have to be paid in order to take care of their own families, etc. So it looks to me like they are just making the tough decisions necessary to keep the team together and stable. It's not pretty (especially the Siphon part), but digging up the floor to fix the plumbing never is. WordPress has proven that hosting is a safe and viable business model to sustain a big open source project. Supporting other CMSs on the Siphon platform is probably just about risk reduction (put the eggs in a few different baskets… err, siphons… rather than all in one) and it would probably make a lot more than it would cost. None of us should view CMSs as religions. I'm glad that I can run Windows apps on my Mac now, when I need to; that doesn't make me prefer Windows. I'm not sure that having web hosting that can only run MODX would be worthwhile. The value proposition with WordPress hosting (which can only run WordPress) is entirely different. Most people using MODX (and ProcessWire) are professionals that have multiple tools. Most people using WordPress are consumers that know how to write, but don't know anything about web development. Given the different audience, I don't think MODX could duplicate WordPress's hosting success by only hosting one product. But I do think they can be successful by catering to the needs of the audience, which is rarely glued to a single product. If diversifying the eggs among multiple baskets helps to drive development for MODX, then that can only be a good thing. Hopefully that's their intention. If their reality really is as it sounded, then the changes were probably good, even if shocking. I think the fear that people might have is that this is somehow driven by investors trying to monetize the software for themselves. But that just doesn't seem to add up in this case. Instead it presents a lack of sustainability in their existing system that had to be fixed (which is itself shocking). I'm just surprised that: 1) They aren't as big and successful as I thought; 2) They don't have a stronger source of income; 3) Any of this was necessary; and: 4) They told us. I don't think that folks should abandon MODX because of the changes. Their team has put themselves in a vulnerable spot and we should support them. While I don't totally understand their changes, it seems like they are doing this to find sustainability more than anything else. While I support and wish the best for MODX in their changes, I also want to be clear that we will not be following that path. We're already on a beautifully sustainable path here, thanks to all of you.
- 25 replies
-
- 10
-
Sorry to hear about the job loss, but you'll appreciate it later on as you move on to bigger and better things. I think it's good that you've invested time in learning ProcessWire. You know how to use a tool that most people don't, and a tool that lets you easily turn any idea into reality. It will be a money printing machine if you want it to be. Unless you have a lot of bills to pay, don't jump back into something where you are dependent upon another employer for your livelihood. You can make a lot more money working for yourself than someone else, though it does take time to get there. Be useful. But find a way to be useful to millions of people rather than just your boss. One idea is to find a fairly specific subject you are passionate about and think about how you might build an online empire around it over time. But that's just scratching the surface. If necessity dictates going back into another job, then at least save your best energy (early in the morning or late at night) building something for your own future, rather than just your employer. The internet really is the land of opportunity where anything is possible. We have more opportunities than anyone has in history. The more you can make investments in and for yourself and the future, the better.
-
Getting fake URLs (with UrlSegments) returned in search results
ryan replied to adrian's topic in General Support
if($m->viewable()){ A viewable() check shouldn't be necessary unless your selector had an "include=all" or "check_access=0" in it (which it doesn't). -
Thanks for reporting back on this. Glad to hear you resolved it.
-
I like and support code standards, especially the PSR ones. PSR-0 and PSR-1 affect the external use of your code, and provide consistency in how people access your code from the outside. I think these are important standards and am very enthusiastic about them for the most part. PSR-2 is not in the same class. It's a good standard, but is more about internal style than external access. It's one of a few good standards to consider if you are starting something new, especially with a team. But if a project has already adopted a style standard, it would be silly to change from one good style standard to another. The point of standards is unchanging consistency. Changing style standards is counter to the purpose of style standards. I don't think the committee behind PSR-2 would suggest changing from another good style standard to PSR-2. But I do think they would suggest PSR-2 as a solid style standard for new projects, and I would agree. However, PSR-2 is not a clear choice even for new projects. It is somewhat controversial in that it's leaderless committee-design, full of compromises making concessions to differing opinions that don't usually go together. I think the committee-design is apparent in the resulting code style. I'm sure the folks behind it would agree and admit it is a lot of compromise. In this respect, I think it may be weaker than some other style standards, but that's always subjective. However, to focus on how or where it was designed is to ignore the point of the standard. So I very much respect what they were trying to do and have done. I hope that PSR-2 will survive because I think the intentions are good. Though I'm not confident it will be so common 5 years from now. But I think PSR-0 and PSR-1 are here to stay. I hope that folks can understand why it would be a counterproductive (even disrespectful to the purpose of standards) for an established project to change from one internal style standard to another.
-
Here you are making ProcessWire do the same work twice (not efficient): if(count($page->images->findTag('gallery'))>0) { $gallery = $page->images->findTag('gallery'); Instead, do this (efficient): $gallery = $page->images->findTag('gallery'); if(count($gallery)) { // ...
-
I think the problem here has to do with the validation/sanitization functions. Most likely the values are coming through as strings (since they come from a user input form) and your code is throwing them out since they don't match is_int(). In FieldtypeForm.module: Make your getBlankValue() function return a blank string (or 0 if you prefer), rather than an array. In sanitizeValue, typecast $value to an integer, like $value=(int)$value; if(!$value) return null; Then get rid of the is_int($value). Values coming through forms may be strings rather than integers, so using is_int() to throw out a value can basically break the whole thing. Change your wakeupValue() and sleepValue() functions to do nothing more than: return (int) $value; In your getInputfield() function, you don't need to set a 'name' attribute, as PW already does this for you. If it still doesn't work after the above changes, review /wire/modules/Fieldtype/FieldtypeInteger.module, as it has identical storage needs as your module.
-
A few things to check: Check if there is a /site/assets/installed.php file. If there is, delete it. That file would only be present if your installation was copied from another, rather than from a fresh GitHub/zip file. Double check that there is an /install.php file present. If you still get an error, try accessing /install.php directly from your browser.
-
I agree that we'll want a UTC-based date fieldtype at some point. Though this is the first that it's come up, so I think that most folks (including me) aren't using the Datetime field in situations where timezone matters. Most usage has to do with dates accompanying content that is specific to server time, in the same way that the built-in created/modified timestamps are. But as the use of PW increases for things involving authenticated users and storage of their data, I think there will be demand for something like this.
- 1 reply
-
- 2
-
Mats gets the credit there. The nice thing is that MarkerCluster is nice and easy to work with. Here's some more about it with examples: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/docs/examples.html
-
I'm not 100% positive about the safety/stability of this option, which is why its only in advanced mode. It may very well be perfectly safe, but since it's something I never use myself, I didn't think I'd be using/testing it enough to adequately support it. It definitely creates a more abstract picture when it comes to the scope of deleting things, and that's the only area of concern I have with it.
-
Yes, my title and body fields were multi-language. Though I only had the default (en) language populated. To duplicate the issue, would I populate the title in some other language, make that my $user language, and then perform the search? Just want to make sure I understand the all the factors necessary to reproduce.
-
Thanks for your work here Horst, it looks great! I look forward to going through in more detail so that I can understand it all and then integrate into the dev branch. It makes sense to have this built-in.
- 32 replies
-
- 4
-
- manipulation
- imagesizer
-
(and 3 more)
Tagged with:
-
I don't see reference to your date field in the code block, so I'm not totally sure I'm answering right… but you can sort by date by adding this to your selector "sort=date_start" or "sort=-date_start" for reverse. You can also stack sorts, i.e. "sort=date_start, sort=title". With regard to formatting, it doesn't matter unless you need to specify an actual date in your selector string. Should that be the case, you would just want your date to be in a format that is either a unix timestamp, or a string recognized by PHP strtotime(). Meaning, all the following would be valid and equivalent in a selector: date_start>=today date_start>=1365436783 date_start>=2013-04-08 date_start>=4/8/2013 date_start>=8.4.2013 date_start>="April 8, 2013" When a date is coming in via user input (like from a datepicker), I'll usually convert it to a unix timestamp before putting it in the selector. That's because: even though we could stuff the user-input date string into the selector, a unix timestamp (which is an integer) is much simpler and safer to validate as user input. if($input->post->date) { $date = strtotime($input->post->date); if($date) $selector = "date_start>=$date"; }
-
It would depend on what method of multi-language support you are using. If using LanguageSupportPageNames, you could do this: foreach($languages as $language) { $url = $page->localUrl($language); echo "<a href='$url'>$language->title</a>"; } or this $saved = $user->language; foreach($languages as $language) { $user->language = $language; echo "<a href='$page->url'>$language->title</a>"; } $user->language = $saved;