Leaderboard
Popular Content
Showing content with the highest reputation on 07/10/2015 in all areas
-
AvbFastCache Module Github repoModule Authorİskender TOTOĞLUBig Thanks to phpFastCache authorsphpfastcacheUsage Almost Like original phpfastcache library : I made some modification on original phpfastcache library for use it with ProcessWire. On my side i tested files and sqlite its look working well. You can set default settings from module setting panel or you can use it like original library with custom settings for each call, from module setting panel you can set storage type, cache path, security key, fallback and also you can delete cached data from module settings panel. Modified set function, working like core $cache->get function this function will check a cached data exist ? if not save cache data and return cached data back. Here is some example usages : // Load Module $AvbFastCache = $modules->AvbFastCache; // Set cache settings from module $_c = phpFastCache($AvbFastCache->storage, $AvbFastCache->getConfig(), $AvbFastCache->expire); $output = $_c->set("cacheKeyword", function($page)) { $output = '<h1>{$page->title}</h1>'; $output .= "<div class='body'>{$page->body}</div>"; return $output; }); //=> OR // Do MemCache $_c2 = phpFastCache("memcached"); // Write to Cache Save API Calls and Return Cache Data echo $_c2->set("identity_keyword", function()) { $results = cURL->get("http://www.youtube.com/api/json/url/keyword/page"); $output = ""; foreach($results as $video) { $output .= $vieo->title; // Output Your Contents HERE } return $output; }, 3600*24); // This will check id=1 or parent_id=1 and will return last modified page UNIX_TIMESTAMP as result echo $AvbFastCache->getLastModified(1); // This will check id=1 or parent_id=1 and template=basic-page and will return last modified page UNIX_TIMESTAMP as result echo $AvbFastCache->getLastModified(1, 'basic-page'); // What can you do with last modified dates ? Let me show you an example // Think you are in news page, $page->id is news page id we are using $user->language->id because if we have multi language website // Here getLastModified() function will get last modified date for us, if news page or children pages have any update new cache data will be created automatically // Like this you can set expire time 0 unlimited from module panel ! // Think we are in "new-list" template and listing children pages $keyword = "newsPage" . $page->id . $user->language->id . $AvbFastCache->getLastModified($page->id, 'news-single'); // Load library with your settings $_c3 = phpFastCache($AvbFastCache->storage, $AvbFastCache->getConfig(), $AvbFastCache->expire); // Write to Cache and Display Result echo $_c3->set($keyword, function($page)) { $output = ""; foreach($page->children as $p) $output .= "<h2>{$p->title}</h2>"; return $output; }); You can check phpfastcache usage from phpfastcache wiki or phpfastcache offical website Note : I didn't tested this module with older ProcessWire versions, tested with 2.6.1 or newer versions. Module not have core dependency, it could work also older versions but need to check for be sure !3 points
-
I'm no expert, but adding to Pierre-Luc suggestions, I would do this (considering a budget as low as US$30/month): A Digital Ocean 2GB RAM VPS for the the PW installation (with a 2 or 4GB swap file); A 1GB VPS for the mysql db Procache to create static version of the website Nginx or other instead of Apache, for a small ram footprint Free plan on Cloudflare to have a CDN for static assets blitz.io to load tests (easier to use than jmeter IMHO) You can always increase the VPS's specs easily on DO, but you will need to shutdown them before that, so it's better to do it before production.2 points
-
Hi Ralph // remove these lines: $view = $form->find("id=ProcessPageEditView")->first(); $form->remove($view); $form->append($wrapper)->append($view); // Replace it with: $form->prepend($wrapper); Then the it should work again. (Note that the family Tab is now the last tab, after view, sorry about that)2 points
-
Hi again, in this case we would need a user-based counter. I just realized that I therefore only need to create a page reference field named "likes" that refers to the user pages (multi-select, not editable via the editor). Great!2 points
-
I moved to Berlin in April and left behind the graphic design studio I co-founded in Basel to get myself more into digital product design. Last week one of my old clients from Basel approached me because they are currently thinking about implementing an own web shop on their website (run on PW). Now I’m looking out for a Berlin-based PW dev with experience in implementing web shops (external platforms or/and PadLoper) in a PW environment who would be interested in collaborating with me on this. I’d mainly work on the design and provide support with the project/code structure on implementation. If this sounds interesting to you, get in touch! If you are very interested and not based in Berlin, don’t hesitate to reply anyway. Thanks in advance!2 points
-
Hey, I think it's time to remove "templates-admin". In my opinion the shared functionalities which are still used by Reno and Default Admin Theme should be put in a separate plugin ("AdminTheme") or a core class ("AdminTheme.php") and the old "templates-admin" should be removed. To prevent that No admin theme is installed there should be a check if you try to uninstall an AdminTheme. And AdminThemeReno shouldn't have DefaultAdminTheme as dependency anymore but only "AdminTheme" class. This just makes more sense in my mind and prevents questions like this (which are completely understandable): https://processwire.com/talk/topic/10329-why-admin-theme-is-in-2-folders/ and questions about the old theme randomly popping up. As Ryan wants ProcessWire to be usable without AdminTheme, too, it's probably the better way to put the stuff in a module (as mentioned above) which can't be uninstalled (unless you know how to force uninstall modules). Please put this on the list for 2.7... Thanks, Nico1 point
-
i meant processwire weekly news - there was a link to this topic great! thanks again for loader1 point
-
I tried checking on some things, but as far as i can tell, the "skin" setting for each editor instance does need to be set in order to override the global skin setting. I think in the future there may need to be some additional setting for global ckeditor style to prevent the current behavior which is loading the default editor stylesheet, but then overriding the editor style with the skin parameter set in the json... So my suggestion would be to see if the module can hook into the ckeditor module with a setting for the option of global skin setting to lightwire. maybe another setting which "allow field-specific skins", and then if this is the case, then the fields that don't have a skin specifically set need to inherit the global setting, and specify that in the json (since right now there is no skin setting in the json for fields where it is not specifically set).. or maybe just modify the current system to where the skin is set in the json and no global style is loaded? but then there needs to be a way to override that.1 point
-
What blog? Ryan's? Blitz.io free plan is good enough for your scenario of testing 3 page impressions per second. You can try loader.io free plan as well.1 point
-
You could use "addHookProperty" to add runtime "variables" instead of a method. These can be used in runtime selectors and are more or less created the same way as normal hooks, but are called without the function parenthesis and therefore cannot have arguments. // runtime selector (no db involved) $pageArray->find("myRuntimeProperty=something"); // db selector (db involved; more features like or groups and so on) $pages->find($sel); // internally replaced by $pages->find("has_parent=$page, …"); $page->find($sel); If you'd also need the greater efficiency from calling less pages from the db you'd need to cache those values in real fields, so they are available to the database queries as well.1 point
-
With ProcessWire 2.6.7 or newer version, You can do something like : ready.php, simple example, you can extent this may i missed something and you can have better idea for best caching methods.. // You can set your site templates for cache or ignore cache $allowedCacheTemplate = array( 'home', 'basic-page', 'contact' => array( 'ignore' => true ), 'reference', 'reference-list' => array( 'list' => true, 'childTemplate' => 'reference', 'pagination' => true ), 'service-list' => array( 'pagination' => true ) ); wire()->addHook("Page::render", function(HookEvent $event) use($page, $user, $input, $allowedCacheTemplate) { $template = $event->template; // Check allowed cache templates, if template has ignore or don't have template return $event->return; if(isset($allowedCacheTemplate[$template]['ignore']) || !isset($allowedCacheTemplate[$template])) return $event->return; // Start Caching $avbfastcache = wire('modules')->get('AvbFastCache'); $_c = phpFastCache($avbfastcache->storage, $avbfastcache->getConfig(), $avbfastcache->expire); // Set default keyword $keyword = $template . $page->id . $page->modified . $user->language->id; // For list view, get children last modified unix time and add it to $keyword if(isset($allowedCacheTemplate[$template]['list'])) { $filterTemplte = (isset($allowedCacheTemplate[$template]['childTemplate'])) ? $allowedCacheTemplate[$template]['childTemplate'] : NULL; $getLastModified = $avbfastcache->getLastModified($page->id, $filterTemplte); $keyword .= $getLastModified; } // If there is a pagination on this template also add $input->pageNum to template if(isset($allowedCacheTemplate[$template]['pagination'])) { $keyword .= $input->pageNum; } // Out keyword is ready to use, check cache exist? $html = $_c->get($keyword); // If cache not exist create cache if($html == null) { $html = $event->return;; $_c->set($keyword, $html); } // return the result return $html; }); With this method you can cache template before render !1 point
-
this sovled the problem, million thanks and shame on me to not even try something so basic1 point
-
Not tested, maybe $p->removeAll() or $p->delete($p->filename)1 point
-
Disregarding your particular issue (which might mean that you serve this site with multiple domains, could be a caching issue, could be connected to your httpHosts setting in /site/config.php, or be something entirely different) for a moment, do you really need httpUrl, or could you use url instead? Relative URLs wouldn't have this issue at all. Just saying.1 point
-
The BMW Dealersites is a collaboration of various BMW dealers, brought together in a multisite ProcessWire setup with centralized and per-dealer contentmanagement possibilities. For anyone interesed, below a quick glance at the multisite pagetree: BMW enforces strict design guideliness for all websites that are built carrying the BMW logo. The guideliness are extensive but can be considered a bit outdated, since they do not take responsive possibilities into account yet. We managed to implement a responsive setup nevertheless, still complying to the guideliness. Which was quite a struggle, I can assure you As mentioned, the Dealersites is a collaboration of various BMW dealers. The idea is that all dealersites are basically the same (fields and templates), yet content may vary. This enabled us to create a centralized content module, in which content can be added and copied to all underlaying dealersites, minimizing the efforts needed to add and maintain content. See the screenshot below for an impression on how this works. We have been experimenting with hosting a bit. The sites are hosted using various Docker instances on an Amazon EC2 server, and mails are sent using Amazon SES. In the near future we plan on implementing ProCache3 with Amazon CloudFront. If you need any info on our experiences with this, just drop a line in this topic or sent me a DM. We have used quite a few modules, but nothing exotic. FormBuilder was used to create forms, some of which are handled by a third party URL to have added functionality: shooting Leads to an external webservice for example. The dealersites: http://www.vanlaarhovenbmw.nl http://www.vanhooffbmw.nl http://www.demaassche-venlo.nl http://www.demaassche-echt.nl http://www.nobracars-uden.nl http://www.nobracars-helmond.nl http://www.story-denbosch.nl http://www.story-waardenburg.nl http://www.story-nijmegen.nl Splashpages: http://www.nobracars.nl http://www.demaassche.nl http://www.bertstory.nl Work was done by us at X-com1 point
-
Hi Martijn, thank you very much! It works perfektly again Have a nice Weekend cu Ralf1 point
-
So I figured out part of the problem. When I disable Varnish I'm no longer logged out. The strange thing is, I'm using an exact copy of my development server which is also running Varnish w/o any logout issues.1 point
-
so that means 2 weaks of work, if i translate 10 files a day. gonna do it sometime1 point
-
Lots of additional updates today. I'll get them over to Ryan tomorrow, and hopefully they will make it to the dev branch later this week. The most notable is support for multiple user templates. (Thanks to LostKobrakai for reminding me of that feature.) The module config will now pick up any templates defined in your /site/config/ For example: $config->userTemplateIDs = array(3, 43); Now you can define separate image fields and/or display name properties for each of your user templates. I don't suspect this will be a commonly used feature, but it's nice to support it, and while implementing I discovered a nice use for it myself.1 point
-
There sure is - one of Ryan's commercial modules: https://processwire.com/talk/store/product/11-likes-fieldtype-single/1 point
-
Wow, thanks a lot for your responses so far! I've dropped Tom Reno a note as I think the Shibboleth integration would work quite smooth (concerning auto login capabilities and so on). Although I will definitely have a look at the LDAP module. I pretty much like the idea being able to build nearly everything with the core features of ProcessWire. On last question: We might be able to integrate the company's social features (there is a Facebook like application which can be partially included). But actually they are not very quick in adapting it to different environments and have performance problems. So I'm thinking about using the ProcessWire comment module by Ryan instead. This of course would make the Shibboleth integration necessary. Is there anything like a "like module" as well? We would love to use it for the news posts on our starting page. So far the ProcessWire community seems to be the most active community I've met! I pretty much appreciate your efforts and would love to contribute in anyway1 point
-
Thanks for the clarification, Pete. I was pretty sure that there's something like this, but wasn't sure at what state it was. Seems that there are a couple of solutions to this, in fact, and this one by Conclurer seems like the best choice at the moment This, I'd say, would in most (especially "enterprise" scale) cases be intentional. If you can't validate current user via the master server for whatever reason, you can't know for sure if the user still has a valid account.. and thus you definitely shouldn't let her in. Sure, stable connection is a necessity, but this is also the only way to be sure1 point
-
Glad to hear you like ProcessWire, and hope to be of help here. Also: welcome to the forum! Check out this post by Tom Reno. Apparently they're using Shibboleth, and he even mentioned the idea of turning this into a configurable module. You could always drop him a note and check if he's got any plans regarding this; I'm sure there are others who'd benefit from that kind of module too This depends a lot on how you want to manage your site. Above you mentioned per-user page-specific permissions, which is one approach you could definitely take; there are many examples of something similar floating around the forum, it's surprisingly easy to build yourself, and then there's the Page Edit Per User module by Ryan. On the other hand, if you're interested in a solution that's slightly less "fine-grained" but easier to manage, Ryan's Dynamic Roles module is also worth checking out. I haven't used it that much myself, so won't go into detail on it's inner workings; from what I can tell, it's used on many large-scale sites already. We've been using the UserGroups module for all of our "per-page view/edit" needs, and we're quite happy with it; might be partly because we've been heavily involved in the creation of this module, of course. UserGroups adds a new concept of "user groups", and lets you assign view or edit permissions for each given page to one or more of these groups, which in turn can contain any number of users. Permissions are inherited, so you don't have to specify permissions for each page individually. Wanted to answer this part separately, since the answer (to me) is quite obvious: absolutely not! On the other hand, a few modules here and there are not a problem, and most of the modules you'll find in the Modules Directory are of great quality. While you can't (and shouldn't, even if you could) build a ProcessWire site just by using installing a bunch of modules, you should feel safe to make use of those that do fit your needs. We're not like [insert the name of a very popular blogging platform here], and the answer to every need isn't "there's a plugin for that". With ProcessWire you'll most likely be doing much more hand-crafting, but for many popular needs there's also a handy module – and if there isn't, just ask and often you'll be surprised at how fast the community can answer with a full-fledged solution.1 point
-
the need you are describing was the primary motivating force behind this module: http://modules.processwire.com/modules/admin-page-field-edit-links i use it in a scenario much like what you describe (couldn't do without it!)1 point
-
FieldtypeMatrix, FieldtypeJSON or the table pro-field seem to be a good fit.1 point
-
It is certainly possible, I don't think it would be that big a deal. Note though that your usage would not be linear, would probably be something like a Gaussian curve so better measure peaks that way, and compound with days of the week. Storage is cheap so that's clearly not an issue, places like Digital Ocean provide you with good performance and you can upgrade/downgrade easily. I would start with a prototype of the site, and test using Apache JMeter, top and whatnot. Launch an instance, install your prototype and start stress tests watching if your site is more CPU, storage or memory bound, then adjust accordingly by tweaking your server and application settings, and throwing more hardware if need be. I am not an expert on infrastcture, but if I need it it's how I typically go at it. Hope it helps.1 point
-
You don't need so set a parent, just use a single selector: id|has_parent=1, include=hidden|unpublished|trash|all For the "include" part choose one of the values. Depends on your exact needs.1 point
-
My thoughts exactly, so I thought it would be a good idea to let .htacess rewrite any url with "/?p=$wp-id" to "/rewrite/$wp-id". I had planned to insert into the Page Path History-Database "/rewrite/$wp-id" and the corresponding "processwire-pageid" in the hope that the module could handle that URL format. Since I expect an overhaul on many posts in processwire, especially regarding the Page-Names and thus the Page-Urls, it would be interesting if and how the "Redirects"-Module or the new "Advance Redirects/Jumplinks" work with "Page Path History". But I will have definitely a look into both Modules and playing around. Due to the bilingual nature of the Wordpress and the used Language Module (q-translate *grmblxfix*), I was unable to use the MigratorWordpress-Module, because the Language Module only allowed exporting into one language. Using https://processwire.com/talk/topic/3987-cmscritic-development-case-study/ , I wrote my own module (which proved to be quite cool, since I learned a lot about Processwire) and like I said, everything works as it should. (But I'm still quite unsure about best practices, though)... For the Wordpress-Urls, I simply extracted them from the database, used Regular Expressions to clean them up a little (removed the Toplevel Domain, so that only "/?p=$wp_id" remained) and during the page creation process, I inserted them via MySQL into the Page History Module Database. protected function updateGUID($id, $guid) { $current = time(); $db = $this->dbConnector('dbuser', 'dbpasswd', 'localhost', 'database_name'); $sql = "INSERT INTO page_path_history (path, pages_id, created) VALUES(:path, :pages_id, :created)"; $query = $db->prepare($sql); $query->bindParam(':path', $guid); $query->bindParam(':pages_id', $id); $query->bindParam(':created', $current); $query->execute(); } Another thing that still bugs me, that although $current has the correct timestamp, any insert into the database results in a timestamp of (0000-00-00 00:00:00) but if I leave the field blank, the $query won't execute...1 point
-
Hey Ryan, thanks a lot, that worked perfectly! I wouldn't even dare thinking about hacking the core normally, but in this case I think it is ok, because this is just a temporary change either way in my case. Really nice to see, how flexible the permission system can be. I can understand that this being admin only is hard coded because of security considerations. Still it would be great to have this potentially available for users in some point in the future, especially for big websites that change a lot (in code). With kind regards, Marc1 point
-
The language translation tools are intended to be admin-only, so assigning permissions for that isn't supported by default. There are potential security implications with making it a default/supported capability. But it is something you could add relatively easily by editing the ProcessLanguage.module and ProcessLanguageTranslator.module files located in /wire/modules/LanguageSupport/. In the getModuleInfo() function of each, you'd want to add a 'permission' line, like this: static public function getModuleInfo() { return array( 'title' => __('Languages', __FILE__), 'version' => 100, 'summary' => __('Manage system languages', __FILE__), 'author' => 'Ryan Cramer', 'requires' => 'LanguageSupport', 'permission' => 'language-edit' // ADD THIS LINE ); } Then in your admin, go to Access > Permissions and add a new permission called "language-edit". Give that permission to any roles you want to be able to use these tools.1 point
-
Thanks for the reverse honeypot method! I'm now using both a regular honeypot (don't fill the field) and your reverse method in all my input forms. I can also recommend adding simple logging to see if it works or not. if ($honeypot == 1 || $securityfield != 1) { $log = new FileLog($config->paths->logs . 'detectedspam.txt'); $log->save('Spam catched: '.$sanitizer->textarea($input->post->body)); $session->redirect($config->urls->root); exit(); } 30 seconds after I implemented this, I got a spam message logged. urgh.. bitter sweet feeling..1 point
-
PageImage Manipulator - Tips & Examples * how to create a PNG with transparency for the watermarkLogo method If you can use adobe photoshop, you simply may download and install this action: photoshop_action_PW-png-creations.zip create an empty image (transparent, not white or black) of 2000 x 2000 pixel write / paste your text and / or logo in a single color, (e.g. black) when finished with your text you should have one single layer with text on transparent background then click the action PW-png-creations -> 2000px-square-to-smooth and you are done. Hhm, maybe before saving you want to tweak the global transparency of the image a bit. That one used in the ProcessWire example was set to 75% instead of 100%. Just try out what looks best for you. ------------------------------------------------------------------- * did you know that you can save to different file formats, regardless of source format? You only have to specify your desired format (gif, jpg, png) with the optionally options array with a key named outputFormat and pass it with your call to pimLoad() or use setOptions() before any other action-method: // assuming the first image is a jpeg $img = $page->images->first(); // define outputFormat $options = array('outputFormat'=>'png'); // apply it together with other actions $myPng = $img->pimLoad('myPrefix')->setOptions($options)->width(240)->pimSave(); //------------------------------------------------------------------------------------------ // you may also do it as a OneLiner only with the image format conversion $myPng = $page->images->eq(0)->pimLoad('myPrefix', array('outputFormat'=>'png'))->pimSave(); // or you can use the setOutputFormat method $myPng = $page->images->first()->pimLoad('myPrefix')->setOutputFormat('png')->pimSave(); ------------------------------------------------------------------- * (how) can I use the ImageManipulator with other imagefiles than PW-Pageimages? You can load any imagefile from your servers filesystem into the ImageManipulator with: $pim = wire('modules')->get('PageImageManipulator')->imLoad($imageFilename); // or $pim = $wire->modules->get('PageImageManipulator')->imLoad($imageFilename, $options); You can directly with the imLoad-method pass specific $options or you can do a separate call to setOptions(). Then you do your desired actions and last but not least you call save()! Most time I think the original passed file gets overwritten with the manipulation result, but you are also able to save to a different name and / or fileformat. If so, it is useful to get the final (sanitized) filename back after saveing. $optionalNewFilename = $pim->setOptions($options)->height(360)->flip()->blur()->save(); Also you may call this in one line if you prefer: if(false!==$wire->modules->get('PageImageManipulator')->imLoad($imageFilename,$options)->height(360)->flip()->blur()->save()) { // success !! } ------------------------------------------------------------------- * how can I use the PageImageManipulator with my own module/s? If you build a module that do some image manipulation you can define the PIM as needed dependency in your ModulesInfo method with the key 'requires'. You may also force to install the PIM if it isn't already with the key 'installs': public static function getModuleInfo() { return array( // ... 'requires' => array('PageImageManipulator'), 'installs' => 'PageImageManipulator', // ... ); } detailed infos are here: http://processwire.com/talk/topic/778-module-dependencies/ additionally, if you need to check if a module dependency has a minimum version number, you can do it in your install method like this: public function ___install() { // check that at least the minimum version number is installed $needed = '0.0.3'; $a = wire('modules')->get('PageImageManipulator')->getModuleInfo(); $actual = preg_replace('/(\d)(?=\d)/', '$1.', str_pad("{$a['version']}", 3, "0", STR_PAD_LEFT)); if(version_compare($actual, $needed, '<')) { throw new WireException(sprintf($this->_(__CLASS__ . " requires PageImageManipulator %s or newer. Please update."), $needed)); return; } // ... more code } ------------------------------------------------------------------- * global options in site/config.php You can create a config-array in your site/config.php. If you look into it you will find a config array for the ImageSizer that comes with the PW core $config->imageSizerOptions = array( 'autoRotation' => true, 'sharpening' => 'soft', 'upscaling' => true, 'cropping' => true, 'quality' => 90 ); You can define another array with these keys: $config->imageManipulatorOptions = array( 'autoRotation' => true, 'sharpening' => 'soft', 'upscaling' => false, 'cropping' => true, 'quality' => 90, 'bgcolor' => array(255,255,255,0), ); You don't have to specify all of the options. PiM reads the imageSizerOptions and merge them with the imageManipulatorOptions. So if you want to have different values you can specify them in imageManipulatorOptions to override those from imageSizerOptions. Only one option isn't present with the imageSizer: bgcolor. This is only used by the imageManipulator. ------------------------------------------------------------------- * using PiM together with the awesome Thumbnails Module (http://mods.pw/1b) If you use the Thumbnails Module together with PiM, you can set two options in the site/config.php under imageManipulatorOptions: $config->imageManipulatorOptions = array( // ... 'thumbnailColorizeCustom' => array(40,-35,0), 'thumbnailCoordsPermanent' => true ); For the colorize dropdown select you can define the custom color here and with the second param you enable/disable permanent storage of RectangleCoords and params. The coords and params are stored with Thumbnails Module per session, but are lost after the session is closed. If you enable permanent storage these data is written into a custom IPTC field of the original imagefile. ------------------------------------------------------------------- * some more examples will folow here . . . -------------------------------------------------------------------1 point
-
$numApproved = 0; $numPending = 0; $numSpam = 0; foreach($page->comments as $comment) { if($comment->isApproved()) $numApproved++; else if($comment->status == Comment::statusPending) $numPending++; else if($comment->status == Comment::statusSpam) $numSpam++; } echo "<p>$numApproved approved comments.</p>"; echo "<p>$numPending comments awaiting moderation.</p>"; echo "<p>$numSpam spam comments.</p>";1 point