Leaderboard
Popular Content
Showing content with the highest reputation on 09/30/2016 in all areas
-
Last week we called it a soft launch, but this week we'll say ProcessWire 3 is now released and considered our new master, version 3.0.35. This post is a changelog of sorts, where we will cover all that's new in ProcessWire 3! https://processwire.com/blog/posts/pw3-changelog/11 points
-
Here's an updated version of the script from @horst and @jacmaes This version; Is PW3 compatible (but not 2.7/2.8) Fixes a bug that prevented the $debugIteration flag from working as described Tweaks the output formatting somewhat Adds some stats on pages/images/variations visited (and variations copied successfully) <?php // for PW3+ // (UPDATES by @jacmaes bugfix for $new filename from below post!) // (UPDATES by @netcarver debugIteration bugfix, PW3 compatibility & formatting tweaks) $debugIteration = true; // true to iterate only over the first page with a desired field, false to iterate over all pages $doFilecopy = false; // true to really copy variation files, false for debug purposes $oldFieldtype = 'CropImage'; // CropImage $newFieldtype = 'CroppableImage3'; $timelimit = 120; // per single page // bootstrap PW include(dirname(__FILE__) . '/index.php'); // collect fields and cropsetting names $collection = array(); echo "<ul>"; foreach($fields as $f) { if($f->type != 'Fieldtype' . $oldFieldtype) continue; $collection[$f->name] = array(); echo "<li>{$f->type} : {$f->name}</li>"; $thumbSettings = preg_match_all('#(.*?),.*?\n#msi' , trim($f->thumbSetting) . "\n", $matches, PREG_PATTERN_ORDER); if(!$thumbSettings) continue; $collection[$f->name] = $matches[1]; echo "<ul>"; foreach($collection[$f->name] as $suffix) { echo "<li>{$suffix}</li>"; } echo "</ul>"; } echo "</ul>"; echo "<hr />"; $pages_visited = 0; $images_visited = 0; $variations_visited = 0; $variations_copied = 0; // now iterate over all pages and rename or copy the crop variations echo "<ul>"; foreach($pages->find("include=all") as $p) { set_time_limit($timelimit); // reset the timelimit for this page foreach($collection as $fName => $suffixes) { if(!$p->$fName instanceof \ProcessWire\Pageimages) { continue; } $images = $p->$fName; if(0 == $images->count()) { continue; } echo "<li>Page \"<strong>{$p->title}</strong>\" <em>directory \"site/assets/files/{$p->id}/\"</em><ol>"; foreach($images as $image) { echo "Image \"<strong>{$image->name}</strong>\"<ul>"; $images_visited++; foreach($suffixes as $suffix) { $variations_visited++; $errors = array(); $dispold = "{$suffix}_" . $image->name; $dispnew = str_replace(".", ".-{$suffix}.", $image->name); $dir = dirname($image->filename).'/'; $old = $dir . $dispold; $new = $dir . $dispnew; $old_present = file_exists($old); $new_present = file_exists($new); if (!$old_present) $dispold = "<strike style='background-color:#F33'>$dispold</strike>"; if ( $new_present) $dispnew = "<u style='background-color:#3F3'>$dispnew</u>"; echo "<li><em>Variation: $suffix</em> — $dispold ⇒ $dispnew"; if($doFilecopy && $old_present && !$new_present) { $res = @copy($old, $new); if ($res) { $variations_copied++; $res = "<span style='background-color:#3F3'>Success</span>"; } else { $res = "<span style='background-color:#F33'>FAILED</span>"; } echo " <strong>Filecopy: $res</strong>"; } echo "</li>"; } echo "</ul>"; } echo "</ol></li>"; if($debugIteration) break; } $pages->uncache($p); // just in case we need the memory $pages_visited++; if($debugIteration) break; } echo "</ul><p>Visited $pages_visited pages.</p>"; echo "<p>Visited $images_visited images.</p>"; echo "<p>Visited $variations_visited variations.</p>"; echo "<p>Copied $variations_copied variations.</p>"; exit(); Looks like this now... Thanks Horst for the detailed instructions and script - and to jacmaes for the testing and update!5 points
-
You can serve any content from a PW install by creating placeholders on the target page, then use javascript to populate those placeholders. Here's one way, though there are probably many - i did this once and it worked pretty well: The JS would load it's html from the remote server. In the template that will display the content, you would put something like this at the top: $request_headers = apache_request_headers(); $http_origin = $request_headers['Origin']; $allowed_http_origins = array( "www.example.com" ); if (in_array($http_origin, $allowed_http_origins)){ header("Access-Control-Allow-Origin: " . $http_origin); } if(!$input->pid) exit("no page id specified"); if($input->pid) { // Sanitize the request $pageRequest = $sanitizer->int($input->pid); // Look for the page $banner = $pages->get($pageRequest); if(!$banner->id) exit("banner not found"); // echo your banner here exit(); } on the target site custom.js: var baseUrl = "http://www.example.com/services/banners/"; // the location of your custom js file: var script = $("script[src*='scripts/custom.js']"); var pageID = $(script).data('page-id'); if( typeof pageID != 'undefined' ) { $( "div#p"+pageID ).html('<p>Loading...</p>'); $.get( baseUrl + "?pid=" + pageID, function( data ) { $( "div#p"+pageID ).html( data ); }); } and on the page that will display the banner: <script data-page-id="1020" src="scripts/custom.js" type="text/javascript"></script> <div id="p1034"></div>5 points
-
Sometimes it's better to use the ID of the page for those critical pages, or employ some way to prevent changing the name of the page: page-rename permission: https://processwire.com/blog/posts/language-access-control-and-more-special-permissions/#how-to-use-the-page-rename-permission "prevent manual changes" option in the Page Rename Options module: http://modules.processwire.com/modules/page-rename-options/5 points
-
Here's a nice article with some examples if you need to allow dates before 1900 http://www.x-note.co.uk/javascript-regex-validate-years-in-range/ Also don't forget about some of the great regex testing tools: https://leaverou.github.io/regexplained/ https://regex101.com/ http://www.phpliveregex.com/4 points
-
@szabesz - Thanks for the pointer to Tracy for this. Unfortunately, of everything in that list, mod_security is the one thing that can't be reliably confirmed as not installed, because PHP can't determine this for PHP-FPM - it only works if php is installed as an apache module. A positive "1" should confirm that mod_security is installed, but a false result unfortunately can't confirm that it isn't. I might add an additional check to show if the negative is confirmed - that I think we can do.3 points
-
The technique i described above would not be blocked unless the adblockers decided specifically to block your server. Otherwise this would operate just like any other content on the page that is generated or manipulated by JS.3 points
-
I also have a copy of the script that optionally handles deletion of the source variations too. I'll post that when its had some more testing.3 points
-
I prefer "locked down" names to IDs, because as a developer I might choose to delete the page in question for whatever reason (e.g. for testing purposes, etc...) so identifying by names makes it easy to substitute the page just in case... EDIT: One more thing against IDs: it is hard to look for its appearances in the codebase, whereas looking for somewhat unique names (I prefer being verbose in this case too) is easy with a decent code editor, even in multiple files.3 points
-
@SamC Hi, You might find the solution in this thread: Especially @gebeer's solution might be the one you are looking for, if I'm not mistaken.3 points
-
3 points
-
Attention: please don't install this module at the time being! It is not compatible with current PW versions, and it will be some time until I can work in all the changes. Due to a discussion here in the forums, I was inspired to finally have a take on datetime fields and see if I couldn't get them to be searched a little more conveniently. Here's a small module - still in alpha state, but I'd be happy to get some feedback - that allows searching for individual components of a date like year, month, day, hour or even day_of_week or day_of_year, and also returning them. Github repo: DatetimeAdvanced Current version: 0.0.5 Tested in: ProcessWire 2.8 + 3.0 Possible subfields: day month year hour minute second day_of_week day_of_year week_of_year Examples: // Database search: $pagelist = $pages->find("mydatefield.year=2016"); // Filtering PageArray in memory: $maypages = $pagelist->filter("mydatefield.month=5"); // Back to our starting point: $start = date('z'); $end = $start + 7; $sevendays = $pages->find("mydatefield.day_of_year>=$start, mydatefield.day_of_year<$end"); // Nice side effect: subfields are now directly accessible $blogentry = $pages->get('blog-entry-1'); echo $blogentry->title . "(" . $blogentry->publishdate->year . ")"; // New in 0.0.4: shorthand methods echo $blogentry->publishdate->strftime("%Y-%m-%d %H:%M:%S") . PHP_EOL; echo $blogentry->publishdate->date("Y-m-d H:i:s") . PHP_EOL; ToDos for the future: See if there's a possibility to specify ranges more conveniently Check if this can perhaps wiggle its way into the PW core Changes: example for direct subfield access and shorthand methods to strftime() and date() added.2 points
-
Redgate is giving out non commercial licenses for its MySQL Compare and MySQL Data Compare tool. I've used their SQL Server Compare tools and the ToolBelt extensively many years ago, and it saved my back side time and time again. I only happen to come across it because I was looking out for a MySQL Compare tool to work out the difference between my Test & Live Servers. The unfortunate caveat is that it only runs on Windows ...... perhaps it will still be of use to someone. I will try running it on Parallels and see if it can access a MySQL Instance running on the OS X Parent .... http://www.red-gate.com/products/mysql/mysql-comparison-bundle/2 points
-
2 points
-
I thought about it as well. If you created a foot template and a foot.php file is included in a _main.php it does't mean that fields from this template will be accessible. You should add visit_counter to page-currently-being-rendered template. Btw.: I use something like this for the same purpose: $page->save('visitCounter', array('quiet' => true, 'uncacheAll' => false, 'resetTrackChanges' => false)); Otherwise on all pages the modified user will be quest.2 points
-
The field is added to the template called _foot, which is included to the page's template. You have to add the field to the page's template itself (to check, try "echo $page->template->name;" - this reveals the "real" page template.2 points
-
Someone correct me if I am wrong, but if I am reading the error correctly, it appears like the field is not attached to the current template (or not created at all). You would need to create the visit_counter field and add to your template.2 points
-
I think i'd probably go with this in the regex (if it's not for historical data) (1|2)\d{3}-(1|2)\d{3} For something like a blog there's hardly need for years before 1000 and beyond 29992 points
-
You can use @adrian's Tracy Debugger module to inspect it: It is in the ProcessWire Info panel. If "Versions List" is enabled in the module's settings, then you get a "Versions List" listing in the panel, where "mod_security: 1" should show up if it is enabled or "mod_security: " if ti is not:2 points
-
Depending on how mod_security2 was built, it might not be possible to disable it in .htaccess.2 points
-
Try to disable cache for the template(s): setup > templates > cache (at least for a temporary workaround if it's a live site) Perhaps checking if pw namespaces are at the top of your files might be another fix (that was introduced with pw 3). https://processwire.com/blog/posts/processwire-3.0-alpha-2-and-2.6.22-rc1/#compiled-template-files2 points
-
I've read about this, but I would only want to use a module once I know how to do this manually. It would save time of course, but now I've learnt about '$a->has('selector')'. Spot on! Thanks to you and @gebeer. Complete function works now as follows (with parent page class added): /** * Render navigation from array of pages * * @param PageArray $items * @param $menuClassName * @return string * */ function renderMenu($items, $menuClassName) { // if we were given a single Page rather than a group of them, we'll pretend they // gave us a group of them (a group/array of 1) if($items instanceof Page) { $items = array($items); } $str = ''; foreach ($items as $item) { // checkbox on page template, fieldname 'showInMenu' if ($item->showInMenu == true) { $menuText = $item->get('menuLinkTitle|title'); if ($item->id == wire('page')->id) { $str .= "<li class=\"current\">"; } elseif (wire('page')->parents->has($item) && !($item->id == 1)) { $str .= "<li class=\"current-parent\">"; } else { $str .= '<li>'; } $str .= "<a href=\"$item->url\">$menuText</a></li>"; } } // if output was generated above, wrap it in a <ul> if ($str) { $str = "<ul class=\"$menuClassName\">$str</ul>"; } return $str; }2 points
-
2 points
-
For what it's worth, I'm successfully running the base payment class and the Stripe class on a 3.0.33 installation. Not tried the Paypal module.2 points
-
Hi @cb2004 That's a fine start However, it will also match "-", "--", "---", "-2000", "-0", "-1000-1", "1---", "31415926" etc. If you are expecting a 4 digit start and end year separated with a single dash then you will need to use a more restrictive/specific regular expression. Assuming the start year is in the 1900 to 2099 range, and the end year in the 1900 to 2999 range, you'd need something more like this; Also, if you are going to be splitting this string up into the start and end year, you might want to use a urlSegment for the start and a separate one for the end year. If that is the case, you'd use ^(19|20)[0-9]{2}$ for the start urlSegment and ^(19|2[0-9])[0-9]{2}$ for the end urlSegment. Hope that helps!2 points
-
Not a proper answer to your issue, but have you had a look at MarkupSimpleNavigation? It will take care of your current/parent classes, plus a lot more (if you want it).2 points
-
I'm only new to this too, but at a total guess: 1) Does this happen when you turn caching off and load the site? 2) Is 'stripTags()' a built in function (part of $sanitizer) and you're redefining it in your functions file? 3) Is the functions file only included once, and not somewhere else as well in another template? If '_init.php' (or whatever you've called it) is appended to your site, the functions within your '_functions.inc' file will already be available to all your other templates. // _init.php // Include shared functions include_once("./_func.php"); 4) What happens if you remove 'stripTags()' from your '_functions.inc' and then try and call this function in another template i.e. in home.php? Does the function still work? I might be well off track but I'm sure the more experienced members will have a better idea. However, these are the avenues I'd try if you haven't already.2 points
-
Something like this ?: $id = $page->id; $pid = $page->parent->id; $locationData = $page->get("LocationData"); $relatedPages = $pages->find("parent=$pid, id!=$id, LocationData=$locationData");2 points
-
Hi guys, Just launched my latest project, The Tourists' Affairs: http://www.thetouristsaffairs.com/en/ This one was a pleasure to build. It's based on a tours catalogue, features a tour finder, and for the first time I based a gallery on Instagram embeds. You can see those working on each tour. I'm using my basic ingredient set here: Languages, AIOM+, MarkupSEO, and not much more. Not big or complicated, but neat.1 point
-
True happiness!! And today Vue 2.0 was released too, Destiny are you trying to tell me something?! Thanks everyone for the amazing work, I keep enjoying developing with PW like in no other system.1 point
-
Hi @adrian, I've an issue to report: Error: ProcesswireInfoPanel exception 'ErrorException' with message 'Undefined index: HTTP_MOD_REWRITE' in .../site/assets/cache/FileCompiler/site/modules/TracyDebugger/ProcesswireInfoPanel.inc:467 Stack trace: #0 .../site/assets/cache/FileCompiler/site/modules/TracyDebugger/ProcesswireInfoPanel.inc(467): Tracy\Bar->Tracy\{closure}(8, 'Undefined index...', '...', 467, Array) #1 .../site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-master/src/Tracy/Bar.php(127): ProcesswireInfoPanel->getPanel() #2 .../site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-master/src/Tracy/Bar.php(81): Tracy\Bar->renderPanels() #3 .../site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-master/src/Tracy/Debugger.php(266): Tracy\Bar->render() #4 [internal function]: Tracy\Debugger::shutdownHandler() #5 {main} I get this when my MAMP Pro's PHP mode is set to "CGI Mode" and the "Versions List" is turned on. I have not found too much on this so called "CGI mode", only this: http://documentation.mamp.info/en/MAMP-PRO-Mac/Servers-and-Services/Apache/ As far as I can see, this mode means the cgi_module is used, so I get the error, but when MAMP Pro's "module mode" is used instead, all is fine. According to PHP Info REDIRECT_HTTP_MOD_REWRITE is on, so it seems to be a strange issue to me.1 point
-
I was stunned because you had the answer in your question (literally) so I was expecting further trickeries1 point
-
There we go...just another instance of me forgetting the simplest of items and trying to make things too complicated. I appreciate it tpr.1 point
-
Just a wee rant. Literally, it's simpler and easier to build a website in PW than it is to manage content on friggin' Sitecore. I mean WOW! How much effort did they put into making it such a complete pain to use? Anyone ever had the bad luck of touching it?1 point
-
Welcome to the enterprise world. We have been in competition a few times. From other companies I hear it's a pain in the ass to maintain and to update. Developers spending 60 hours just to upgrade seems like no exception. The suites sell it good. These are the guys who can convince a client User Experience is a checkbox in a page.1 point
-
Superb work and so great many improvements. While I read all the blog posts I can't even remember them all, like the multi language improvements. Thanks Ryan (and the rest of the team) for the great work.1 point
-
Added ProCache today which has helped alot on my server stats, as the CPU has gone from around 50-60% right down to 20%. however my RAM usage is still up the 80% which isnt great. Analytics are still at around 300-1500 hits a day. Will check out that site @Sérgio for sure.1 point
-
thanks for pointing me to the Tracy Debugger module, wasn't aware of it, looks like an awesome tool even if I can't use 90% of its features because they're above my knowledge level. The Tracy Debugger shows that it can't detect mod_security as being installed ("mod_security: "). Even though it's not a hard confirmation, it's consistent with what I found snooping around via SSH into the server. Thanks for all the help so far! Any ideas where to go from here?1 point
-
I know you're going to wait awhile, but I'm only just back from work and have been thinking about this. Considering adding a namespace fixed your issue, perhaps it's also something to do with the compiler settings in: Admin > Setup > Templates > Edit Template: "template-name")... in the 'Files' tab. I had a different problem with this myself and had to choose 'Auto (compile when file has no namespace)'. Worth a look anyway.1 point
-
1 point
-
1 point
-
Great! You might want to update the post of the (this way almost) complete example as well.1 point
-
Just to confirm did you uncomment this rule? RewriteCond %{REQUEST_URI} "^/~?[-_./a-zA-Z0-9æåäßöüđжхцчшщюяàáâèéëêěìíïîõòóôøùúûůñçčćďĺľńňŕřšťýžабвгдеёзийклмнопрстуфыэęąśłżź]*$" Also, you don't need to restart Apache when changing htaccess files; you only need to restart if you have changed a configuration file, such as httpd.conf or a virtual host file.1 point
-
The processwire admin is using jquery all over the place, so why not use it if it's already there.1 point
-
Hello all, Just wanted you all to know that I found an excellent webhosting company for Benelux (where I live) and Europe. They are advertising Processwire on their frontpage, which is cool, is it not? What can Processwire want more than free publicity on hosting companies websites ;-) The link is: https://www.hosted-power.com/en/processwire Greetings, Karl.1 point
-
@Robin S It has nothing to do with the default behaviour of the template cache -- it is clearing the cache when it should do. At least I've not noticed any issues when logged-in, saving pages or using GET/POST whitelist. Adding/removing/changing fields - I don't know, but adding fields is at least usually accompanied by modifying pages (to add the new data), which would clear the cache. However, making changes to the template files does not clear the cache. Which is one of my issues. My other issue is laziness If I'm logged-in (which would prevent caching), I'm not getting the normal visitor ('guest') experience/view. I just wanted one simple place to disable the cache temporarly for multiple templates, without having to log-in, add a no-cache GET variable (and then have to add it to every URL in dev) or disable it on every template that uses it. it would also be useful on staging sites, where you may enable caching to show clients how fast it can be (and for testing), but might want to disable it when making changes. Or even on the live site itself -- globally disable the cache (and then dump it via the module's settings page), make the updates/upgrades while the cache is disabled (preventing visitors from triggering caching), then once the updates are made/tested, enable the cache again. This is where Soma's solution works a charm - it creates that simple/quick config setting and and only involves a few lines of code in the ready.php file.1 point
-
the master branch / version from pw module directory wasn't PW 3.x ready. Previously you had to use branch develop. But I just released a new version 1.0.0 which supports ProcessWire 3.x (only). Just update the module to the latest version and everything should work as expected.1 point
-
Check the owner and permissions on site/assets/* And if you want to learn more server stuff, there are a book and a video tutorial series on https://serversforhackers.com/1 point
-
There's a partly free series on vue 1.0 on laracasts.com, this should get you started quite well. Just be aware that the soon to be released 2.0 version does change some parts on the inter-component communication.1 point
-
I think the issue is that the image is by default an inline element. Inline elements do not respond the same as block elements. Verticaly you can't set paddings to 0 You could float the image to make it a inline-block automagicly or you could make it a block element. img { display:block; margin: 0; } // center image with class .center img.center { display:block; margin: 0 auto; } img.left { float: left; } img.right { float: right; }1 point