-
Posts
17,231 -
Joined
-
Days Won
1,697
Everything posted by ryan
-
To interact with the images field. Create a new field (under Setup > Fields) and call it whatever you want, like "images" for example. Set the field type as "image". Add this field to a template (under Setup > Templates). Then edit a page using that template and upload some images. In your template code: ProcessWire will create your images at any size on the fly and then keep a cache of them. For instance, lets say we want to cycle through all the images, create a large image at 500 pixel width with proportional height, and a thumbnail at 100x100, and then have the thumbnail link to the large: <?php foreach($page->images as $image) { $large = $image->width(500); $thumb = $image->size(100, 100); echo "<a href='{$large->url}'><img src='{$thumb->url}' alt='{$thumb->description}' /></a>"; }
-
Sorry for the delayed reply. I've been on vacation for the holidays for a few days, and just getting caught up. That's correct. The one in ProcessWire uses jQuery UI's autocompletion widget, combined with a new web services module on the admin that handles the ajax-driven searches. What it has are not unlike checkboxes, in that clicking the item causes it to reverse background/foreground color to indicate it's selected. And clicking it again, switches it back to normal, to indicate it's unselected. This way it just stands out a little more in a large list than the regular checkbox does, but the idea is the same. Because the selectable items list stays open, there is an optional "close" button when you are done selecting items. It still adds the selected items to the list at the top (like you saw in the video), so that the selected items are summarized and can be sorted. These items are added to that list as you select them, so there is no separate validation from the form submission at present. Removing the selected item is done from the selected list (via the trash icon), or just by clicking the selected item in the selection list. But I'm confused about what you mentioned with changing page properties (like template) from this field type. At least in the case of the sites I'm using it on, I think there may be confusion if the user is potentially changing properties of pages when selecting items for a field. But I may be misunderstanding. Can you clarify? Thanks, Ryan
-
By the way, I'm also developing a auto-completion form control for page selection. It's functional at present, but still tweaking the details. It provides the same unlimited sample size benefit, and obviously with far fewer clicks. But auto-completion is not a true multi-selection tool since you have to know something about what you'll be adding ahead of time (i.e. you need to start typing something before seeing the selectable options). Still, auto-completion is ideal in some cases, so this is on the very near-term roadmap.
-
I appreciate your feedback. You are right that there are a lot of clicks. Though the selection sample size was over 3,000 items in more than dozen different possible groups in the hierarchy. I could be wrong (and probably am), but I'm not aware of any other multi-selection tool that works with an unlimited sample size. In this case, the number of clicks can be reduced, but they are there for usability in feedback. Specifically, the clicks relate to: Navigating through hierarchy and pagination, and not showing more than a defined number of selectable elements at a time. This ensures usable scalability regardless of selectable sample size. Providing instant feedback to show where the selected item goes. This part is optional, but can be a worthwhile tradeoff. One way to reduce the clicks is to not have the list collapse on each item select. I have this working already, but sitting on it for a bit. I didn't include it initially because I wanted my clients to have the instant feedback of seeing the item added to their list (i.e. click, and see where it goes). It's slower, but more clear. I also anticipated this type of selection as being one that the selectable sample size be unlimited, but the number of items actually selected being fairly small. So while you and I may prefer to open the list once and click many items, then close the list when we are done, I was worried that would be too ambiguous for others. Also, having the list collapse on each selection means it stays consistent with the way a regular select (and asmSelect) work. But now that I know there is someone else that wants the quicker-style of selection, I will push this forward.
-
This is true–unfortunately webkit-based browsers, like Safari and Chrome, don't support the browser-based resize method that is used by TinyMCE to resize elements in the editor (likewise with Opera, I think). Whereas both Mozilla-based browsers and IE8 do support it… though I would never suggest you use IE8. Personally, I use Firefox and Chrome equally. The solution in webkit-based browsers is to perform your resize in the image editor instead. That uses jQuery UI to handle the drag-resize, which should work just about anywhere. It will perform the same newly resampled, proportional resize that you get in the TinyMCE editor (they both direct to the same PHP script via ajax). If you want to resize an image already in the document, just click it, then click the image icon, and then it'll pop up the editor where you can do a drag-resize. Then click the "insert image" button, and it should place the resized image in your document.
-
Line 81 and 82 check the server software. It sounds like Dreamhost must not have that info populated, but I'm assuming they are using Apache, so it should still be fine to continue with the installation (and it sounds like you did). I have updated the install.php file to double check that the server_software variable exists before trying to read a value from it, and that should suppress the error you saw. Sorry about the attachment size limit. I just got this forum setup and didn't see that setting–I will try to track it down and fix. Thanks, Ryan
-
Hi Marcin, The method you posted is one I hadn't thought of before, but it would certainly work just as well as any other. Another variation on it would be: if($page->child()->id) { // has children } else { // does not have children } Here's the way that I usually do it. This is also what ProcessWire does before it executes the child() or children() methods, to decide whether a query should be executed: if($page->numChildren) { // has children } else { // doesn't have children }
-
MarkupCache is a simple module that enables you to cache any individual parts in a template. I'm working on a site now that has 500+ cities in a select pulldown generated from ProcessWire pages. Loading 500+ pages and creating the select options on every pageview isn't terribly efficient, but I didn't want to cache the whole template because it needed to support dynamic parameters in the URL. The solution was to cache just the code that generated the select options. Here's an example: $cache = $modules->get("MarkupCache"); if(!$data = $cache->get("something")) { // ... generate your markup in $data ... $cache->save($data); } echo $data; I left the markup generation code (the part that gets cached) out of the example above to keep it simple. Below is the same example as above, but filled out with code that finds the pages and generates the markup (the part that gets cached): $cache = $modules->get("MarkupCache"); if(!$data = $cache->get("city_options")) { foreach($pages->find("template=city, sort=name") as $city) { $data .= "<option value='{$city->id}'>{$city->title}</option>"; } $cache->save($data); } echo $data; That was an example of a place where this module might be useful, but of course this module can used to cache any snippets of code. By default, it caches the markup for an hour. If you wanted to cache it for a longer or shorter amount of time, you would just specify the number of seconds as a second parameter in the get() call. For example, this would keep a 60-second cache of the data: $cache->get("city_options", 60) I hope to have it posted to GitHub soon and it will be included in the ProcessWire distribution. If anyone wants it now, just let me know and I'll post it here or email it to you.
-
This topic has been superseded by the roadmap page. Please see that page for the latest items on the list. - Pete These are a few of the items on the short-term to-do list: Page preview before publish (i.e. page drafts) Autocomplete Inputfield for use with Page Fieldtypes Continue posting new documentation to processwire.com JSON page-selection web services for use by admin modules Customizable page "channel" view, in addition to the sitemap view currently in ProcessWire (Admin > Pages). This will enable browsing, viewing, editing of pages outside their parent/child structure. For instance, this view can match specific properties like having the same template, modified within the last day, or anything that you can match with a selector. Various improvements to the FieldtypeComments module(s), including documentation! Simplification of the roles/permissions system. Specifically making roles assigned to templates rather than pages as the default option, and giving permissions a more clear presentation and selected defaults. Google Maps Fieldtype module Conversion of some core code into plugin modules Some other items on the longer-term to-do list include: Tagscript parser that enables you to access most Page/Pages-related API capabilities via a tagscript syntax. Some ExpressionEngine users convinced me this is worthwhile, despite my preference for a pure-PHP based API. This will be developed as a module for those that want it, and it's already in the early stages. It is being patterned off of both ProcessWire 1.x and ExpressionEngine 2.x syntax. Plugin modules will also be able to define new tags. Built-in user form processing with admin tools to list/search/read/update/delete submissions, as well as the ability to import submissions directly to new or existing pages (with direct field mapping). Localization support for non-English languages. Strong versioning system for pages. This would also include multi-level undo and a page version comparison tool. Workflow functions whereby Templates can have custom statuses assigned which affect the state of the pages using them. Access to the custom statuses would be definable by Role (or User) so that any number of workflow possibilities could be supported. These lists are not complete, and I'll be adding to them regularly. What else do you think should be here?
-
Here's a function that would return all the children in a month. Replace the last param ($field) with the name of the date field you want it to look at, otherwise it defaults to the 'modified' field, which probably isn't what you want (but was what I used to test the function). <?php /** * Return all of the page's children where $field falls in $month and $year. * * @param Page $page The page that has the children we are finding. * @param int $month Month you want to match. * @param int $year Year you want to match. * @param string Name of the date field to check. * @return PageArray All the matching children. * */ function childrenInMonth($page, $month, $year, $field = 'modified') { $startTime = strtotime("$month/1/$year"); $endTime = strtotime("next month", $startTime); return $page->children("$field>=$startTime, $field<$endTime, sort=$field"); } Below is an example of how you might use this function in your template. This code shows examples for both URL segments and GET vars. If you wanted to use URL segments, you would need to go in to the Admin CP, click on Setup > Templates > Your Template > Advanced > URL Segments > Set it to an asterisk "*". That tells it to allow any URL segments to pages using that template. And here is code that first checks for a URL segment, then GET vars, and defaults to current month/year if none is provided. <?php if($input->urlSegment1 && preg_match('/^(\d{4})-(\d{1,2})$/', $input->urlSegment1, $matches)) { // A URL segment matched in the format of year-month, i.e. /news/2010-12 $month = $matches[2]; $year = $matches[1]; } else if($input->get->month && $input->get->year) { // GET vars were provided with the year and month $month = (int) $input->get->month; $year = (int) $input->get->year; } else { // No year/month provided, so display items from current month $month = date('m'); $year = date('Y'); } // display a headline with selected month/year echo "<h2>" . date('F Y', strtotime("$year-$month")) . "</h2>"; // find the matching pages $children = childrenInMonth($page, $month, $year); // output a list of the matching pages echo "<ul>"; foreach($children as $child) { echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; } echo "</ul>";
-
To get things started in this forum, I'm going to post some of the Q&A from emails that people have sent me. That's a good question. For most cases, I would not try to create a different page structure for years/months because that's more work and it invites the possibility that the links will change over time as you move pages to archive them. After using different strategies over a few years, I think it's better to have a single container page under which all news items will be placed, permanently. Then set that container page's default sort to be by date, so that newer items always appear first. From there, the news page should focus on the newest items, and provide links to past news whether by pagination, month/year links, etc. In this respect, you can treat a page in PW2 in the same manner that you would treat a channel in EE2. There is no problem with scalability… PW2 will run just as well with 10k+ subpages as it would with 10. When following that suggestion, these are the only scalability considerations: 1. You may occasionally have to consider the namespace with the URL "name" (aka "tag" in PW1) field. For example, if you have two news stories with substantially similar headlines, you may have very similar URL name fields. But ProcessWire will enforce that namespace, so it's not going to let you create two pages with the same name under the same parent. What that means is it'll make you modify the page's URL name to be unique, if for some reason it's not. I'm talking strictly about URL names, not headlines or anything like that. 2. When dealing with news stories (or any place that may have a large scale of pages), you want to pay attention to how many pages you load in your template API code. If you are dealing with 10k news stories, and load them all, that will slow things down for sure. So the following applies: Avoid API calls like this: 1. $page->children 2. count($page->children) Instead, use API calls like this: 1. $page->children("limit=10"); 2. $page->numChildren $page->numChildren is something that ProcessWire generates for every page automatically, so there is no overhead in calling that, like there is in count($page->children). But if working at a smaller scale, it doesn't really matter what method you use. The most important thing to remember is just to use "limit" in your selector when potentially dealing with a lot of pages. That applies anywhere, especially when making things like search engines. So when you want to support unlimited scalability, these are the functions where you want to place limits: $page->children(...) $page->siblings(...) $page->find(...) $pages->find(...) The other reason someone might like archiving to year/month is because it makes it easier to link to since you could just link to /news/2010/04/ for instance. But it would be a fairly simple matter in PW2 to make your template look for "month" and "year" get vars, or a URL segment, and produce results based on those… See the other topic in this forum for one way that you might do that.
-
Have a question? Click the "new topic" link to the above right of this message.
- 1 reply
-
- 2
-
-
To stay up to date with the project I recommend doing the following: 1. Subscribe to the e-mail list by entering your email in the sidebar box at http://processwire.com 2. Follow me on Twitter at http://twitter.com/rc_d - This is where I post general updates about ProcessWire. 3. Follow ProcessWire on Twitter at http://twitter.com/processwire - This is where all commits to the ProcessWire source code are "tweeted" from GitHub.
-
A couple people have mentioned that they installed ProcessWire, logged into the admin, logged out, and couldn't find where to login again. The default login URL to ProcessWire is: yoursite.com/processwire/ You can also change the login URL by editing the admin page (Pages > Admin) click on the "settings" tab and change the URL name to something else. Just don't forget what you name it otherwise neither you nor I will be able to figure out what the admin login URL is.