Leaderboard
Popular Content
Showing content with the highest reputation on 10/16/2013 in all areas
-
7 points
-
This is one thing I love about PW. Many heads thinking and suggesting, one head deciding and acting quickly3 points
-
Hmm.. if I may try to correct a possible misunderstanding on Steve's part: Felix was saying the word "frontend" a lot, but it was in the context of "frontend development" - NOT about the Processwire frontend vs. backend! So he was talking about best frontend development practices for strictly the PW admin interface. (Sorry, if this is superfluous at this point, just not sure if we are all on the same page)2 points
-
Thanks Diogo! That did the trick. I've posted the latest update to the admin theme on dev and this includes the bundled Arimo fonts. I'm curious if this makes it look better for you guys on Windows? This update also includes several other tweaks and minor fixes.2 points
-
I don't think there is technically any need to have global variables, and you are better off avoiding them. But on the rare occasions where it seemed worthwhile, I'd usually use the $GLOBALS PHP superglobal anytime I referred to it, just to be really clear about what it was. i.e. $GLOBALS['cd'] = 'this is a test'; function roo() { print $GLOBALS['cd']; } That makes use of any global variables stick out like a sore thumb, reducing the potential confusion that comes from using global variables. Btw, the reason why just defining $cd outside the function doesn't make it a global is because ProcessWire templates are actually running from the namespace of a function in the TemplateFile class, not from the global namespace.2 points
-
coming back to this: I have made good progress! I do not use the htaccess file in site/assets/files/ anymore but have edited the htaccess file in pw root folder. Somewhere at top of the mod_rewrite directives I have added my lines that should redirect requests to original images to a proxy-script and let others pass through: htaccess with Pim1 and PW < 2.5.11 .htaccess with PW 2.5.11+ / PW 3+ # ----------------------------------------------------------------------------------------------- # CUSTOMSETTING : redirect original images to proxy-script - /pwimg.php?fn=... # ----------------------------------------------------------------------------------------------- RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} (^|/)site/assets/files/(.*?)/ RewriteCond %{REQUEST_FILENAME} \.(jpg|jpeg|gif|png)$ [NC] RewriteCond %{REQUEST_FILENAME} !-piacrop RewriteCond %{REQUEST_FILENAME} !-piacontain RewriteCond %{REQUEST_FILENAME} !-pim2-full RewriteCond %{REQUEST_FILENAME} !-blogthumb RewriteCond %{REQUEST_FILENAME} !.*/.*?\.([0-9]+)x([0-9]+)\.(jpg|png|jpeg|gif)$ [NC] RewriteRule ^(.*)$ pwimg.php?fn=$1 [L] Now from all existing images the originals get redirected to the proxy-script and the others will delivered directly by apache. Requests to none existing imagefiles get answered by a 404. So as everything seems to work fine, the RewriteConditions could be optimized a bit. ---- pwimg.php ---- <?php // check filename $imgFilename = isset($_GET['fn']) ? preg_replace('/[^a-zA-Z0-9_\-\/\.@]/', '', $_GET['fn']) : false; $imgFilename = is_file(dirname(__FILE__) . "/$imgFilename") && is_readable(dirname(__FILE__) . "/$imgFilename") ? dirname(__FILE__) . "/$imgFilename" : false; if (false == $imgFilename) { header('HTTP/1.1 404 Not Found'); exit(2); } // check imagetype $imgType = getImageType($imgFilename); if (false == $imgType) { header('HTTP/1.1 403 Forbidden'); header('Content-type: image/jpeg'); exit(1); } // bootstrap PW require_once(dirname(__FILE__) . '/index.php'); // check user-account if (! wire('user')->hasRole('superuser|editor')) { header('HTTP/1.1 403 Forbidden'); header('Content-type: ' . $imgType); exit(1); } // collect infos $maxAge = (60 * 60 * 2); // 2 hours $imgTimestamp = filemtime($imgFilename); $imgExpiration = intval(time() + $maxAge); // create headers $imgHeaders = array(); $imgHeaders[] = 'Content-type: ' . $imgType; $imgHeaders[] = 'Content-Length: ' . filesize($imgFilename); $imgHeaders[] = 'Date: ' . gmdate('D, d M Y H:i:s',time()) . ' GMT'; $imgHeaders[] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s',$imgTimestamp) . ' GMT'; $imgHeaders[] = 'Expires: ' . gmdate('D, d M Y H:i:s', $imgExpiration) . ' GMT'; $imgHeaders[] = 'pragma: cache'; $imgHeaders[] = "Cache-Control: no-transform, private, s-maxage={$maxAge}, max-age={$maxAge}"; // send headers foreach($imgHeaders as $imgHeader) header($imgHeader); // send file $errorCode = @readfile($imgFilename) === FALSE ? 1 : 0; // and exit exit($errorCode); // --- functions --- function getImageType($fn, $returnAsInteger = false) { $types1 = array(1 => 'gif', 2 => 'jpg', 3 => 'png'); $types2 = array('gif' => 1, 'jpg' => 2, 'jpeg' => 2, 'png' => 3); if (function_exists('exif_imagetype') && isset($types1[@exif_imagetype($fn)])) { $success = $types1[exif_imagetype($fn)]; } if (!isset($success) && function_exists('getimagesize')) { $info = @getimagesize($fn); if (isset($info[2]) && isset($types1[$info[2]])) { $success = $types1[$info[2]]; } } if (!isset($success)) { $extension = strtolower(pathinfo($fn, PATHINFO_EXTENSION)); if (isset($types2[$extension])) { $success = $types1[$types2[$extension]]; } } if (!isset($success)) return false; return true === $returnAsInteger ? $types2[$success] : $success; }2 points
-
Hey Soma, Is this the same as my issue at: http://processwire.com/talk/topic/383-module-import-pages-from-csv-file/?p=43443 I submitted a fix and pull request for that here: https://github.com/adrianbj/ImportPagesCSV/commit/ad4d9e71f844fe2e4c9162152177e119a403ef38 Although it sounds like you have something else going on with the $pageName as well.2 points
-
As some of you might have noticed recently there has been a large "Frontend Performance Talks Offensive" (not only) by Google Engineers. Here are some high quality (regarding content) Videos which i enjoyed very much and thought you also might be interested in. A Rendering Performance Guide for Developers by Paul Lewis: Performance Tooling by Paul Irish Your browser is talking behind your back by Jake Archibald Gone In 60fps – Making A Site Jank-Free by Addy Osmani http://addyosmani.com/blog/making-a-site-jank-free/ Any suggestions for more interesting performance related stuff are welcome!1 point
-
Here is our website using ProcessWire, still work in progress: http://www.mokkivertailu.fi/ The site is a search engine for rental cottages in Finland. Cottage owners can register and add their information while users can search and browse the database.1 point
-
Thanks, I have fixed that in the latest commit to dev. Not a bug per se, as the template context settings don't currently accompany the clone. But maybe they should. Thanks, this one is also fixed in today's commits (though not sure that one is yet up on GitHub, but it will be shortly). Most likely because PW doesn't validate the selections when PHP code is used to find selectable pages. It does validate them when using a regular selector string, and this validation was implemented recently on the dev branch. The "has_parent" is a database-specific selector option, while our validation is done in memory (not by the database) so this is most likely why it's failing there. I think the solution is for me to add "has_parent" as one supported by our in-memory selectors. This should be as simple as just adding has_parent as a property recognized by the Page class (which would return the result of $page->parents). If you have a moment, can you try out the attached /wire/core/Page.php replacement to see if that fixes it? Page.php1 point
-
Thanks guys, I have updated the module to 1.0.4 with these fixes in place.1 point
-
Antti, I've just done some basics, but it seems to be working great now! Mac: - Safari - Chrome - FF Windows: - IE9 - Chrome I hope the sorting issue isn't too difficult to conquer — that's that last piece I would need to make this production ready. Thanks for all your hard work.1 point
-
I plan to collapse them to a "=" icon (pretend it has 3 horizontal bars rather than 2). But I'm also not sure how important it really is, as the navigation remains fully functional either way. I think it'll be fine to let the content tabs (WireTabs) wrap this way at least. I thought they looked pretty good the way they were, but if you guys think they look better on top, I'll switch it. It should be translatable from /site/templates-admin/default.php, at least it does appear in our translation list in that file. I'll test it out to be sure though. Thanks, I'll try this one out. I was able to test on Windows Chrome this week, and can now see the font-rendering issue. Though from my perspective, all fonts looked pretty poor, including Arial. Maybe I'm just used to the antialiasing in OS X, but wondering if Chrome/Windows just has issues here in general. Not sure how far we should go with it if even the native fonts look bad. Fontsquirrel says that the font's license doesn't allow them to create a webfont version of it, so it has to be done manually. If they can't distribute the webfont version, i'm assuming we can't either. When we put something in ProcessWire, we're distributing it. However, I'd love to be wrong about this, as I'm really enjoying the look of Arimo (on the mac at least).1 point
-
> "& developer winns the lottery and quit working at all" ...the way to go, lol! No, but I only use http://ready.mobi/ as a tool to check my output while I´m developing the site. I do handle mobile detection myself and I´m trying to output code that only has to be adapted slightly to be mobile-ready.1 point
-
Concerning "fancyness" and the Design part: Maybe it's easier to understand where I am heading if I share some more general perspective of engagement with you: I adore the system and want to give something back I'd like to make processwire more known as we would all profit from this in several ways I like the way the processwire community acts and communicates: You're all kind and lovely people around here in the forums Having said that here is "my plan" to discuss and think about I'm a CTO and developer at a Communication Agency and (as i already stated) and have a strong design & UI background as I completed vocational training as a media designer. I'm also very interested in marketing. To be kind: What I'm trying to do here could be summed up as "Content Marketing". To Explain this further: Me and all my co-workers were in search of a "perfect" CMS that fits our needs because we were tired of all those typo3s, drupals and wordpresses out there. We discovered processwire and all loved it. I even managed to convince my boss that we should start using processwire as our first choice CMS because it seems promising in the long term. He agreed because he trusts me with this kind of decisions. That was mostly because I told him that I know there are plenty of other developers feeling the same. That's a good starting point: When a lot of people are searching something there is a business case for it. But there was one thing we didn't like and in my opinion is a reason processwire doesn't get the credits it deserves: The design of it's backend which until now (sorry: no offense ryan) looked kind of "oldish" (i love where the new dev-branch theme goes though). If you're looking at choosing processwire from a bussiness perspective it is nothing (at least our) customers already know, so there are some things to consider apart from how efficient and fun it is to build websites with: How do i convince my customers this is the CMS he needs? Will my customers have "fun" using it and be satisfied (as in "WOW, this is SO SIMPLE and BEAUTIFUL" i'll recommend it to all of my partners and drop my MS-Word for it!!11)? Will there be more attention (and thus more potential jobs) in the future? If not: How can we manage to draw more attention to it (again: for us and the community because we do believe it should have)? Most people like "nice looking and simple" things (take the iPhone for example). Processwire is (imo) just simple yet. That's good from a developer point of view but won't sell you anything. So let's work on that. If we made it more "nice looking" we can start the "marketing machine" saying: Customers love it's look AND developers it's simplicity. It's so super-duper awesome that a really big bunch of hip "early adopters" (that's us!) is using and has written some articles in about it (which is something we're about to do, too). The people you should try to reach here aren't just developers but designers and marketing guys who are really good at sharing and promoting things once you've conviced them that this is an awesome system to use. Once PW is more known: How can we position ourselfs as experts when someone is looking up people who implement things with PW for him? Engange Be visible Help making things better Promote where you can Last but not least: World domination! ;D Ghosts marketing did a pretty decent job on that (except for the world domination): No one knew how the system would work but it looked simple and beautiful so it got a big buzz, is widely recognized and people are starting to build stuff with it. I know Ghost reaches out for a different kind of users (more End-users and Bloggers) and I didn't dig too deep into Ghost but as far as I can tell it's pretty "basic" compared to what processwire can do.1 point
-
Ok: Let's just leave out the fancy design for now. If we do that there is exactly one tool apart from bower which I've mentioned: require.js. If you don't like using this: I'm OK with that from a "don't use too many fancy libraries" point of view (but IMO there are - as i mentioned - several good reasons to think about it). Other than that I only talked about making things more modular and fast which isn't dependant on any library or framework. When you remove the "prose part" i was basically saying: Modularity Use OOCSS and make Javascript less dependant on Markup and other Javascript Performance Keep an eye on performance issues and make things as fast as possible Accessibility Add some markup that helps disabled people to use processwire Testing Good software (which processwire is) should be tested I'm with you here. Let's take OOCSS as an Example: For a long time I didn't like the concept of OOCSS and kept using descandant selectors for "all the things". While this is a conservative and valid way to write CSS there are certain pitfalls and problems which make it hard to maintain and extend. When it comes to complex frontends that are beeing maintained and extended by multiple developers it's good to have some structure and guidelines to assure everyone is running in the same direction. I recommend reading these articles to dive more into this concepts. Implementing - for example - BEM syntax and methodology would be pretty simple: It's only thinking about structure in another way and adding / removing some classes. As diogo mentioned SASS is already used in the new admin theme and i'm pretty happy with that as it adds another layer of easier theming and DRY. If I were about to introduce a lot of "state of the art bells and whistles" i would have mentioned doing the backend with angular, ember, polymer [more namedropping and fancy frontend frameworks here] or even building a processwire api framework which acts as a facade and abstratcs dom manipulation and common tasks out so you could even drop jquery and use zepto, prototype or yui instead. But I didn't do that for a reason. I'm fine with keeping it simple (stupid) and not overenigneering things (I've done quite a lot frontends for magento which imo is an overengineered nightmare and a perfect example how to complicate things while maximizing modularity to a level no one will ever need). Sorry: I can't follow your argumentation at this point. I'm still not getting what the fact that processwire doesn't bake in anything at the frontend has to do with the style the backend is implemented. The frontend part is "your project": This is the what you are going to produce the way YOU like and processwire is a very efficient tool which helps you to achieve this without getting in your way. So if we make processwire even more efficient and customizable (if you're interested in customizing things) what makes that a bad thing? Why would one need two interfaces? I think it's OK for both editors and developers to have a decent, up to date, simple, good looking, efficient tool to work with. For me there is no need to seperate things here.1 point
-
@Horst and Adrian: So I found out what it was with the </img> tags: They are not added by either CKEditor or TinyMCE. I was mistaken about that. What happened is that I have been using the "Inspect Element" feature in Firefox to view the output and that´s where it shows the </img> tag. Whereas when I use "Inspect Element with Firebug" or view the source (also from Firefox) the tag isn´t there! So this is a bug in Firefox, unless there is some reason I don´t understand. As far as the missing image dimensions go I wonder if it´s not a CKEditor thing in general, not just in the Processwire module? Maybe if I have the time I will test this. So I did a brief test: Downloaded the latest version of CKEditor (amazing amount of features and options!). When I use the standard samples they provide with the installation and look at the posted data from there I don´t see any image dimensions provided with the img tags! When I use their sample that produces XHTML compliant output it gives me style="float:right; height:109px; width:150px" in the img tag. Maybe if I configure the CKE module to output this that will fulfill my need here (outputting mobile-optimized code). No, apparently not: to assure best mobile-readiness I check my output with http://ready.mobi/ ==> and it wants the width and height attributes, not just the style. Then there is also the possibility to configure CKEditor so it outputs valid HTML 4.01 code. However then the pages will likely fail as valid XHTML Mobile Profile 1.2 doctype. I only want width and height in the image tags, not sure if there is an easy way to get CKEditor to do that...1 point
-
1 point
-
$lalias = "the-name-of-the-page-in-english"; $english = wire("languages")->get("english"); $lalias_name = wire("sanitizer")->pageName($lalias); $page->set("status$english",1); $page->set("name$english",$lalias_name); $page->save();1 point
-
A post from Ryan that I think is relevant here: http://processwire.com/talk/topic/4442-pw-performance-with-hundreds-of-fields/?p=43643 I have a similar dilemma coming up and I think I will end up going with a custom fieldtype because it will allow the flexibility of a custom database table structure while still being able to use the PW API effectively. Keep in mind that I have been developing with PW for 6 months and this is the first time I have wanted to go this route - generally PW's fields and pages do a great job. Every now and then I have had to use an SQL query and there are a few examples of how to do that here in the forum. http://processwire.com/talk/topic/1684-reading-and-displaying-data-from-a-custom-table/ http://processwire.com/talk/topic/669-using-a-secondary-database/1 point
-
The database is structured to be easily queried by the API and not to be queried directly. So, even if you can do it, I'm pretty convinced that you can do 99% (not only simpler cases) of what you will ever need by using the API.1 point
-
I can hear from your post that you're an experienced developer. Give your self some time, play around with the API. You'll see that PW handles one to may, many to many relations very well. After a while you'll see that PW is a framework with a admin build on top. If you wish to use SQL directly you're free to use it. Best to use $database (PDO) variable instead of $db (mysqli). ps, I'm very bad with SQL, so ProcessWire is heaven for me.1 point
-
Well. Even if no one seems to be interested i'll keep updating this if i stumble upon interesting links. Maybe this will help someone in the future Here we go. How to prioritize visible content: http://www.feedthebot.com/pagespeed/prioritize-visible-content.html1 point
-
Try making $cd explicitly global. <? global $cd; $cd = "this is a test"; roo(); function roo() { global $cd; print "[".$cd."]"; }1 point
-
It's hard to say without more information. $txt isn't a standard processwire variable, do you know where $txt gets defined? Figuring out what $txt is might help you find your answer.1 point
-
Hi there The search API is the API. It's all the same thing, so only one thing to learn. URL Segments are just a way of passing some additional things to the page so you can fine tune what you're displaying. If you had a page called "Articles" with a template "articles-home", what you might do is turn on URL segments and then do something like this, where urlSegment1 is what thing you want to filter by in terms of a and urlSegment2 is what you're matching against <?php if ($input->urlSegment1 == "author") { // Assumes there is a specific field in your article template called "author" and you would match by their name from a URL like www.yoursite.com/articles/author/ted-danson/ $articles = $pages->find("template=article, author.name=$input->urlSegment2"); // As you can see we matched urlSegment1 against the fictitious URL above and the above $articles variable will hold all the IDs for articles by the matched author, urlSegment2 /articles/ is a real page, /author/ is urlSegment1 and /ted-danson/ is urlSegment2 } elseif ($input->urlSegment1 == "category") { // Now imagine our URL is www.yoursite.com/articles/category/autobiographies $articles = $pages->find("template=article, category.name=$input->urlSegment2"); } elseif ($urlSegment1) { // If someone is still passing an URL segment and it's not one we recognise and have dealt with above, it would be best to throw an error. People could be typing in all sorts of rubbish otherwise like www.yoursite.com/articles/bunnies/ninja/ throw new Wire404Exception(); } else { // So in this very last one we've not got any URL segments at all, so we probably just want to list the last ten articles with no search parameters applied $articles = $pages->find("template=article, sort=-created"); // This lists all articles in reverse date order // You can also add ", limit=10" stragith after the word "created" in the selector above, or any of the ones above to just return a certain number of results and then look into pagination elsewhere on the site and forums to implement that rather than display potentially thousands of results on a page } // And now you have your $articles you can do something like this (I've assumed you've added a field to the article template called "date": foreach ($articles as $article) { echo "<h2>$article->title</h2> <p>Written: $article->date</p> <p>$article->summary;</p> <p><a href='$article->url'>Read More</a></p>"; } Now the only reason I could see for you matching articles on a specific date was if you were maybe reading articles on a busy site and at the end of a specific article you wanted to see a list of other articles on that date. Even so I can't think why you might want to do that, but here's some code that might help - remember you've now just read an article and at the bottom of the page we want to list other articles on that date: <?php // We're getting articles on the same DAY (the exact time as the current article would be a little pointless as you're down to matching the second in that case) // We'll assume that the date the article is saved in ProcessWire is the date you want to use to find other articles posted on the same day, however it could easily be your own date field - for the purpose of the example below this just means I'm matching against the "created" field in the database $startOfDay = date('j F Y', $page->created); // Since this will be a horrible timestamp to the SECOND that the article was published, we're turning it into something that reads like this: "12 September 2012" $startOfDay = strtotime($startOfDay); // Then we're turning that from a human readable string back to a timestamp, except now it is 0:00am on that day - the start of the day! $endOfDay = date('j F Y', $page->created) . " +1 day"; // Now we're doing the same again, but you can tag " +1 day" on the end of the string... $endOfDay = strtotime($endOfDay); ... and strtotime() is clever enough to add a full day onto the date $articles = $pages->find("template=article, created>$startOfDay, created<$endOfDay"); // Easy huh? Not if you don't know some of the above date functions obviously, but it's well worth looking on PHP.net as everything before the line directly above involves just some pure PHP to manipulate the date and is well worth spending a little time learning. Let us know if you need any more examples. The search functionality just uses the same functionality above from what I remember except it sends the search query to a specific search page and then matches the string the person entered against various fields like "body" and "summary". It's all the same sort of code behind the scenes. This is also the reason you won't see a generic example - they just don't make sense as everything uses selectors to find results (plus real-world examples are easier to understand for the most part): http://processwire.com/api/selectors/1 point
-
Updating the module to 1.0.3 it doesn't recognize paste in CSV data I get "Missing required CSV file/data", the file upload works. Could it be that the folder for that page is /-1006/ and it doesn't allow to use file_put_contents() as it's protected by htaccess? It tries to put in "/home/.../site/assets/files/1006/data.csv" Also the duplicate option doesn't rename names to "name-n", it just throws error and names them "-n" SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'ilnau-5870' for key 'name_parent_id' Quick look at #404 $page->name = $this->getUniquePageName($pageName); $pageName isn't set, it should be $page->name1 point
-
Spex is official now, I've added this to the modules directory =)1 point
-
Ryan is open to add hooks when requested and it makes sense or there's a need for it. Language modules are relatively new and not many things has been done with it so it's just a matter of asking. I also am working with languages and recently thought the same while looking at the LanguageSupport modules. You could for now just make them hookable by putting ___ prefix.1 point
-
I think the problems inherent with a table booking system are as follows (and this is with no real research by the way): Do restaurants have a good grasp of how long a table will be occupied for? If so, give them an option (maybe default to 2 hours per table) Different table sizes will affect the booking. You need to enter your party size ideally to see what is available. That or the restaurant may be able to push tables together in many cases - how do you deal with that? If you're using a web booking system for a restaurant and it needs to be up to date, the system needs updating whenever walk-in customers come into the restaurant. Either that or you can only book online X hour in advance (4 hours default maybe?). Basically, what I'm getting at is that there are far more variables in play than other booking systems. Booking a holiday cottage is easy - it's got a fixed number of beds - no problem. Booking a hotel room is slightly trickier - you have more options, not just with how many beds per room, but type of room. The more I think about it, the less likely every eventuality will be covered just by the module I'm creating. I think it far more likely that each scenario needs to be tailored and that they might be best as site profiles since there will be a lot of templates with them. As such, the module I'm working on may help as a starting point for accommodation/asset-based booking, but won't be much help for table bookings and other time-of-day based scenarios. At least, not in version 1.1 point