-
Posts
17,095 -
Joined
-
Days Won
1,641
Everything posted by ryan
-
Alex, TinyMCE seems to be inconsistent about when it applies the <p> tag inside tables. I think its behavior may vary from browser to browser, though have not confirmed that. I'm using Firefox 4 and Chrome 12. On the sites that I use it on, it's only on rare occasions that a <p> tag shows up inside table cells. Because it's so rare, I just remove them manually when it happens in the HTML code view of TinyMCE. If you are finding it's doing it all the time, first check that you don't have any TextFormatters turned on in your field. When using TinyMCE, you generally don't want any other text formatting to take place since TinyMCE is writing out HTML. If you can't solve this with TinyMCE settings, you may want to do something more brute force. Edit this file: /wire/modules/Inputfield/InputfieldTinyMCE/InputfieldTinyMCE.module Then locate this function: <?php public function setAttribute($key, $value) { if($key != 'value') return parent::setAttribute($key, $value); /* // remove empty tags $value = preg_replace('{<([a-z0-9]+)>\s*( |<br />)*\s*</\\1>}i', '', $value); // replace fake bulleted lists $value = preg_replace('{<br />\s*[-*]\s*}m', '<br />', $value); // fix breaks to be paragraphs $value = str_replace(array('<br /> <br />', '<br /><br />'), '</p><p>', $value); // fix paragraphs that start with a break $value = str_replace('<p><br />', '<p>', $value) ; // remove arbitrary and incorrect bulleted lists $value = preg_replace('{\s*•\s*}', ' ', $value); // fix those darn tags $value = str_replace(' ', ' ', $value); */ return parent::setAttribute($key, $value); } That function is what sets the value in ProcessWire, so you can modify the output from TinyMCE before it gets saved if you want to. Note all the commented stuff in orange. Those are all various solutions I've had to use to solve a specific problem on a specific site at one time or another. They are commented out because they really only apply in specific cases. But it sounds like you have a specific case like this. So what I would do is add something like this before or after that commented stuff already in the function: $value = str_replace("<td><p>", "<td>", $value); $value = str_replace("</p></td>", "</td>", $value); That would make it remove <p> tags that open and close with the <td> tags. This may not be an ideal solution, but it would get the job done. If you want to account for possible whitespace between the opening or closing table cell and paragraph tags, here is another solution to try (though writing in browser, not tested): if(preg_match('/<td>\s*<p>/', $value)) { $value = preg_replace('{(<td>\s*<p>|</p>\s*<(/)td>)}', '<$2td>', $value); }
-
404 Page Not Found Error When Saving Edits to an Existing Page
ryan replied to srbobc's topic in General Support
This is one I've not heard of before, but I'm guessing some error is occurring that's getting thrown by PageEdit and then misinterpreted by PageRender. Which version of ProcessWire? 2.0 or 2.1? The following applies regardless of version, but this might help me to determine the source of the problem. Can you edit /site/config.php and find the line with $config->debug = false, and set it to true. Try to perform the page save again and see if you get any other error messages. If there's anything revealing post here. Otherwise, edit one of your site's existing template files and add this temporarily at the top: <?php echo "<pre>"; $p = $pages->get(5772); if($p->id) { echo "\n{$p->path}\n{$p->status}\n{$p->template}"; $p->setOutputFormatting(false); $p->status = Page::statusOn; $p->title = $p->title . " (test)"; $p->save(); echo "\nSaved page\n"; } else { echo "\nUnable to load page\n"; } return; Now view the page using the template where you pasted that. What does it say? If it appears to have saved the page successfully, try and edit again in the admin and see if you still run into the 404 error? Thanks, Ryan -
There are positives with every CMS project and things to learn. There is no one-true way to approach things. Instead it's just a matter of different CMSs meeting different people's needs and preferences. My relatively brief experience with Symphony left me feeling that it was very much in opposition to how I work. But I have no doubt there are also good points and ideas to learn from, as there are with many products. I try to spend a good deal of time experimenting with other CMSs and will be sure to give Symphony more time based on your suggestion. In terms of organizing content for an editor with some form of limited access (as opposed to a superuser), I would suggest experimenting with ProcessWire 2.1 rather than 2.0. I think that 2.1 represents a stronger system for working with access to specific types of content. You define the access with the template rather than the page in PW 2.1. My opinion is that the tree view is the right approach whether you have access to all the branches in the tree or not. It is consistent and representative of the site's front-end structure. On large sites, confusion arises when you start pulling things out of the context of the site's structure (at least, that's my experience). You actually have quite a lot of flexibility in defining how this tree works in 2.1, including the ability to specify what fields appear in it on a template-by-template basis. But the desire to display pages in an alternate way in the admin has come up before, so you'll also be glad to know the new page search module can be used as a page listing filter (enabling nearly any kind of page listing display), and we'll be taking this utility a lot further as we move forward in PW development. But the tree structure will always be PW's native view into your site... we'll just provide more options for those that want it. The debug tool sounds interesting. I wouldn't want to take the approach of intercepting GET vars or making PW produce output directly in that manner, because PW promises not to take that control from your template. But you can achieve a similar type of result pretty easily just by adding a little code to your template's file. For example: <?php if($input->get->debug && !$user->isGuest()) { echo $page->renderFields(); // uses the MarkupPageFields core module // or iterate through the page's fields on your own to produce JSON, XML, etc. return; } // otherwise render regular page output
-
Okay that's good to know, thanks for the clarification. We've already got the note about the RewriteBase commented in the htaccess file so I won't worry about that one. But knowing that it's required at 1&1 (a fairly major hosting service) I might need to call more attention to this in the install directions.
-
Very cool, it looks like the 2 languages work beautifully in this example. This is the first time I've seen such a solution in place, nice work. I also like that the language-switching links stay on the current page, so that hopefully Google will index the whole thing in both languages (using the url segments). My only concern would be about whether this might confuse Google (or other search engines)–I suppose that would only confuse Google if GoogleBot maintained session cookies… and I don't know if it does. But if it does, you might be better off requiring a form POST before setting the session cookie to change the language, setting the cookie with Javascript, or forcing the language URL segment to always be on the URL for one of the languages. The last solution mentioned there would be the best but also be a little harder to implement. If you are interested, I can describe how to do it. But if potential confusion to the search engines is not a concern, then you don't need to worry about any of these as the site appears to function beautifully for the user.
-
Where to set image resizing quality and how to re-resize images
ryan replied to Adam Kiss's topic in General Support
This is an excellent idea. This is what PW uses for cleanup when you delete a page. For a site-wide cache clear of images, this may work very well. But on a really large site, it may be slow (or run out of memory) since it'll involve loading all the pages on the site. So for the image cache clear that I'm writing, it's going to most likely just stick with hunting in the file system and confirming that it's a variation based on the existence of the full size image. -
Great–glad that worked with minor changes. Thanks for the follow-up. I'm thinking we should adjust the date-based selector strings to automatically run strtotime on any strings passed to it that aren't all digits. That way we wouldn't have to use strtotime to build the selector in instances like this.
-
Thanks for the kind feedback. I know what you mean about the terminology for templates. A template might be described as a page type (or content type) in other CMS projects. Despite the literal definition, the word 'template' can evoke a file rather than a type. I think this is because of the way the term is used in other CMSs. But in PW, the file is just a component of the template. It's an important connection, but one that I get tripped up on wording sometimes too. Maybe the best way to describe it as the "template's file", clarifying that the file is owned by the template. I would refer to it as an "output file" or a "view", except that they are not always accurate… Your template's file might just as easily be a controller that's calling upon other views. I guess it just depends how you are using PW, and there are plusses and minuses to not being too specific with the terminology. Perhaps we will come up with some better terminology at some point, so lets keep thinking.
-
Thanks for posting this. 1&1 is a large hosting provider, and if they require modifications to the default htaccess in order for the site to work, this is really good to know about. I'm sure this will be helpful to others. I'm just wondering if there is anything I can do to avoid having it not work in the first place at 1&1... it's not safe for me to assume a www redirect in the default .htaccess file, or to apply a rule like that based on the status of HTTPS. They must have an unusual configuration at 1&1. I will do more research into this.
-
ProcessWire on Windows7/2008 Server with IIS WebServer
ryan replied to nikola's topic in General Support
Thanks for posting! I'm sure this will definitely help out many people looking to install on IIS. I need to link to this post in a couple other spots too. -
Thanks for the followup and glad to hear it's working well.
-
Thanks for posting. I'm guessing this part is necessary because 1&1 is defaulting to PHP4? (and this forces it to use PHP5?) AddType x-mapp-php5 .php .html .htm AddHandler x-mapp-php5 .php .html .htm There are some security considerations with making HTML documents run through PHP, so unless you need that, you may want to remove the .html and .htm extensions from being parsed by PHP. Why are these lines necessary for 1&1? RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] Is looks like this redirects a non-www hostname to a www hostname (we're doing the opposite with processwire.com). Thanks, Ryan
-
I don't see your template here, but it came through in the email I got. I've never used output buffering in my own templates so don't know if there is some unusual side effect resulting from that. PW is already output buffering everything in your template, and you are output buffering on top of that. Should that matter? I have no idea. But so far that's the only thing unusual I can spot about your template. Does the problem occur only on pages using that template, or on others too?
-
Thanks for your feedback. This is an interesting topic, and I'm not sure that I totally understand what you are saying, and may need more context. But looking at the diagram you linked to, it reminds me of why ProcessWire was built in the first place. I'm equating their 'sections' with templates in ProcessWire. But their definition of templates are also something separate beyond that, and 'entries' are a separate entity from 'pages' (if I'm understanding it correctly). While the terminology is varied, this is what I was describing as one of my fundamental problems with EE and Drupal. I'm not suggesting it should be a problem for you or anyone else, but for the sites I develop and the way I develop them, I don't like extra layers of complexity that fall outside the context of the front-end. Not specific to Symphony, but consider: channels, nodes, taxonomies, categories, sections, entries, resources, and on and on. Taken in the context of the front-end and boiled down to their core, they are all pages or behave like pages. Looking at the big picture, IMO these are all unnecessary complexity and that's why ProcessWire is designed exclusively around pages. Earlier versions of PW and Dictator have been split out into more layers (not unlike that diagram, and even using some of the terms mentioned above). Over time I've found more benefit to reduction and simplification. Far more benefit than to the occasional and potential flexibility of keeping them separate. if you get deep into the API, you'll even see one hold-out: Fieldgroups (aka sections in Symphony) are separate from Templates in the API, but not from the admin. And that will probably change eventually too as we work to simplify more and more. The goal with PW is not to solve all needs, but to solve most in the simplest way possible. I like to wander into concept and theory, so please forgive me for straying off topic a bit. It sounds like you are talking specifically about building forms... though I still haven't figured out how to connect that with the diagram. But we don't have a form builder (other than the one used by the admin). The form builder is scheduled for version 2.3 of ProcessWire. So this type of feature is on the roadmap, but multi-language functions are coming first. The form builder is not next on the priority list only because it's not something that necessarily provides more flexibility, just saves time (i.e. you can implement forms of equal flexibility and power without a form builder). The challenge will be to do all this while continuing to make the system simpler, and we'll get there.
-
It should be fine to remove all of those. I would suggest disallowing indexes just for security (keeps prying out of directories without index files). But if indexes are already denied, then all good. The ErrorDocument stuff is just an optimization to keep the favicon.ico and robots.txt requests from getting sent to PW. It is fine to remove those. The FilesMatch is a secondary measure and it should be okay to remove. Several of the RewriteRules are doing roughly the same thing. The php_flags are just optimization and are fine to remove. Likewise DirectoryIndex is fine to remove.
-
Adam, can you try clearing your cache: Admin > Modules > Page Render > Clear Cache To me it looks like a permissions issue. So if you get errors when clearing the cache, or if it doesn't work, you might want to try and remove all the dirs below cache/Page/ manually. i.e. rm -rf /site/assets/cache/Page/* I think Almonk also wrote some shell scripts that do this. Let me know if the error persists after clearing the cache.
-
Okay good news, this is now available in the latest commit of 2.1: https://github.com/ryancramerdesign/P21/commit/da6418cedeede89b7039341536641e5080fea144 To use it, you have to add a ".count" to the end of your field name. Using your example from above: $children = $page->children('images.count>2'); The reason you have to use ".count" is because without it the operator is comparing the image's filename. While I could redirect the ">", "<" and related comparison operators to the count, I wanted to find a consistent way to do this throughout the system, and adding ".count" to the field name seemed the most logical way to do it. You can use this with any multi-value field: files, images, page references, comments, etc. You can also use it with a page's children, i.e. $children = $page->children('images.count>2, children.count>0'); Note that all pages have a 'children' property, so it can feasibly match any page. But maybe not all pages in your system use a template with the "images" field. PW doesn't attempt to match pages that don't even have the field, so if you did this: $children = $page->children('images.count=0'); ...that will only match pages that have an images field with zero images. It won't match pages that don't have an images field. This is for consistency with other selectors. Please let me know how this works for you and/or if you run into any errors with it. Thanks, Ryan
-
Hi Stephen, Welcome to the forums and good question. Here's one way you could approach it, assuming all those posts were under the same page (like /blog/). I'm somewhat limited on time right now, so this is written in the browser and not tested, but I can follow up with more detail later if you'd like. <?php $blog = $pages->get("/blog/"); $startYear = date("Y"); // this year $endYear = 2009; // or whenever you want it to end $now = time(); for($year = $startYear; $year >= $endYear; $year--) { for($month = 12; $month > 0; $month--) { $startTime = strtotime("$year-$month-01"); // 2011-12-01 example if($startTime > $now) continue; // don't bother with future dates if($month == 12) $endTime = strtotime(($year+1) . "-01-01"); else $endTime = strtotime("$year-" . ($month+1) . "-01"); $entries = $blog->children("created>=$starttime, created<$endTime"); // or substitute your own date field $date = date("m-Y"); echo "<li><a href='./$date'>$date - " . count($entries) . "</a></li>"; // output the month and count } } Then you'd use the same template to list the entries when a $input->urlSegment1 has a date specified in it. Basically you'd cycle through the $entries found above and link to them. This is rough and just approximate. I'll be glad to follow up with more detail... but wife is telling me to get off the computer.
-
I've got an update for you in 2.1 which makes this available. I'm going to run it through a little more testing tomorrow, and if all checks out I'll commit this to the 2.1 source.
-
Well PW 2.1 is very close to becoming the current stable version. I have a few details to take care of, but think it's just about there (perhaps by the end of the month). I'll keep the 2.0 branch going for bug fixes but probably won't be adding new features to it... this is already the case.
-
Thanks for the feedback, glad that you are finding a lot of sites to be a good fit to develop in PW. I've not yet had the opportunity to try out Symphony, but had heard good things about it (and like what they've done with their site). Still glad to hear that PW makes it easier to manage page content. I remember several years ago there was a fairly impressive new blog platform that came out called Symphony (not sure where that went)... and then there is the Symfony framework (different spelling). A little confusing, but it is a good name. Even though I've not used Symphony, I have used quite a lot of other CMSs. EE was one of the more frustrating to me because there was so much to like about it (people, CodeIgniter, design, company), that you are willing to go further, invest time into it and look past some of it's strange ways. So the "deal killer" moments came later and were a little more frustrating. I think those "deal killer" moments are different for every person, so it's not to say anything bad about EE other than relative to what I was looking for (and I'll still use it when the project requires it). But now you have to invest money in it before you can even try it. I suspect this is why they don't have a free demo version of EE2 anymore (they did for awhile). With the current CMS landscape, one probably isn't going to be willing to invest the time to figure their way around the odd complexity of EE unless they've already bought it (IMO). And once you've invested that time to really learn it, at least it doesn't let you down–it gets the job done. But it hurts that portion of the audience that seems convinced they are locked-in and incapable of learning anything else.
-
Where to set image resizing quality and how to re-resize images
ryan replied to Adam Kiss's topic in General Support
Well it's actually easy to identify the resized versions because they always follow a common format of filename.123x456.jpg (or substitute another width/height and image extension). Whereas the originals have the same filename, but without the .123x456.jpg part. So the cache clear will be pretty straightforward to write... it'll just look for any images that have that last part and a corresponding filename without it. Then it'll remove all the versions with the .123x456.jpg in the filename. But tracking them down requires a regular expression, so it's not something you can do so easily from your OS (unless you are good with unix file commands... I wouldn't know where to start). So assuming that the full size versions you already have in there are good, then you should be able to resize them to a different dimension. That leaves you with just the extra/unnecessary files you want to delete. Do I have it right? -
Where to set image resizing quality and how to re-resize images
ryan replied to Adam Kiss's topic in General Support
Adam, ProcessWire doesn't actually resize your original image, so they should still be in tact. All you have to do is change the resize dimensions and it should be creating the new sizes from the original. But if you want to go in and delete all the extra files for sizes you aren't using anymore, give me a couple days. I'm working on an addition to the FieldtypeImage module for that (an image cache clearing module). -
Negative lookup for ID in selector not working?
ryan replied to Adam Kiss's topic in API & Templates
I don't think as much about the mathematical stuff (as much as the SQL stuff), so I'm glad you guys are looking at it in this perspective too. Ultimately we're translating to SQL logic and the 'making sense' part is preferable to mathematical rules since selectors are a form of data queries rather than mathematical statements. But ProcessWire selectors are something new and aren't based on any existing standard, so we're kind of defining the standard here, and that's what I really like about these discussions. The more thinking that goes into the details like this the stronger it will be. -
I was just reading this post on how to make breadcrumbs in ExpressionEngine (http://bit.ly/hello_crumbly) and how you basically have to resort to a plugin to do it for you. It reminded me of some of the problems I had with EE when I was trying to use it and develop in it awhile back. One being that URLs aren't a primary/unique key to a page, natively in the system. Imagine ProcessWire with only it's root level pages and url segments, and that gives you an approximation of what you have to deal with in EE. I'm not saying it's wrong, but it's a different approach, and one that I found frustrating to work with. The post also made me realize I didn't have anything on the site demonstrating how you might make a breadcrumb trail (other than in the default site profile). It's really a simple thing (at least, relative to EE), so figured I'd post here. : <?php foreach($page->parents() as $parent) { echo "<a href='{$parent->url}'>{$parent->title}</a> "; } You may want to output those as list items or add some >> signs between items, but as far as code goes, the above is all there is to it. What it's doing is just cycling through the current page's parents till it reaches the homepage. Lets say that you also wanted to include the current page in your breadcrumb trail (which is probably redundant, but some sites do it). What you'd do is just append it to the list of parents that gets cycled through: <?php foreach($page->parents()->append($page) as $parent) { echo "<a href='{$parent->url}'>{$parent->title}</a> "; } The reason this is so simple is because every page is anchored to a specific URL and those URLs are representative of the site's actual structure. Pages in PW are actually uniform resource locators (URLs) whether on the front end or the back end. Because of that, there's no guesswork or interpretation to be done. In EE and Drupal (as examples) that data does not natively live at a specific URL. Instead that data is off in a separate container and the ultimate URL (or URLs plural) where it lives–and will be presented by default–are not as cut and dry. Yes, you can install plugins or go through strange taxonomic/channelistic/cryptic trials to approximate the behavior in other systems. And yes you can use url segments and pull/render any other pages you want in ProcessWire according to your own needs. But I'm talking about the fundamental and core system differences. This difference goes far beyond simplicity of generating breadcrumbs–it is a factor that translates to simplicity throughout the API.
- 35 replies
-
- 12
-