Leaderboard
Popular Content
Showing content with the highest reputation on 03/28/2017 in all areas
-
I've done this several times, no issues here. The language tabs don't appear if there are only 1 language.3 points
-
Hey @Robin S - I just wanted to remind everyone how awesome this is It can reduce the number of required templates (and template files) substantially in some cases where you have a standard setup, but with some minor differences to the fields in each template. Of course you could take it to extremes and have just one template per site, so you need to be careful to find the right balance, but it's a really powerful addition to PW IMO. Thanks again!3 points
-
So what is happening there is that the file compiler is kicking in when you haven't manually declared the namespace. The file compiler turns: include($config->paths->templates . "views/{$page->template->name}"); into: include(\ProcessWire\wire('files')->compile($config->paths->templates . "views/{$page->template->name}",array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); The PW compile method is converting that path and adding the .php extension. You can test it yourself: Anyway, I don't think you should rely on the file compiler to do that - either add the extension, or use wireIncludeFile()2 points
-
$page->sort always worked this way, which is why most people simply avoided changing it most of the time. It might need some clarification now that there is a function which does prevent duplicate sort values. Rebuilding all sort values is a waist of db computation. Imagine you've 10000 siblings and you reorder just the 9999 to be the last one. If there are gaps in the first siblings sort values it'll rebuild all 10000 instead of just a few pages. I think you expect to set the new index of the page not the sort value, which in ProcessWire are currently different things. I see that it might be confusing, but mostly because people rarely dealt with that issue by now as sorting was mostly done via the GUI / modules. It would be great if you could formulate those issue you had in a github issue, so that ryan can improve on them.2 points
-
@LostKobrakai I took a look in the core sorting functions. Unfortunately it doesn't work as expected and the $pages API reference is faulty and should be updated: // set $page to have sort=5, moving any 5+ sort pages ahead $pages->sort($page, 5); // works as expected // same as above using alternate syntax $page->sort = 5; // WILL NOT moving any 5+ sort pages ahead it just changes the sort value. Duplicates possible $pages->sort($page); // WILL NOT set anything. This is a getter not a setter. Similar to $page->sort In the $page API reference, $page->sort is described as follow which is faulty too. Use $page->index instead to get expected/ described result. But you cannot use $page->index as a setter! Currently the only (nearly) working solution needs the following 2 steps $pages->sort($page->parent, true); // re-build sort values for children of $page, removing duplicates and gaps $pages->sort($page, 5); // sort +=1 for all pages above In this example you will get an unexpected result If the sort position related to the siblings was 4 before. There will be no change, because there is a gap at sort position 4 now. What I would expect using this function If I set sort I would expect a zero based position related to the page siblings. Example $pages->sort($page, 2); 3 page siblings having the sort values 4, 7, and 11. If I assign a sort value 2 to the page with the former sort value 7 I would expect the page moves to the end (last index number under 3 siblings), but currently it moves in the opposit direction and will be the first one related to its 2 siblings. Nice to have in the future (already available via PageMove module) // move page to the first or last position related to its siblings $page->moveFirst; $page->moveLast; $page->moveFirst($newParent = null); $page->moveLast($newParent = null); // move the page to an index position relative to its siblings, optionally change the parent too in one step $page->move($parent, $newIndex = null, $selector = 'all') // or simply $page->setIndex($newIndex, $selector = 'all'); Expecting a core update related to this I will not push the module to the modules directory. Feel free to pull it from github directly until this is available from core.2 points
-
Good tip @Can For those interested, here is the blog post about sanitizing directly with $input: https://processwire.com/blog/posts/processwire-2.6.14-brings-major-enhancements-to-sanitizer-and-input-api-variables/#sanitizer-and-input-are-now-a-couple2 points
-
@szabesz @pwired : Sorry for the late response. Been very busy with a deadline that inevitably dragged on and on ... For those who are interested, I've got the following for automating my deployment. By all means, it's not perfect nor is it complete but it does the job with a minimal investment of my time. I have structured my DB scripts into 2 categories. The dump_<xxx> scripts and the restore_<yyy2zzz> scripts. The dump scripts are to dump the DB contents as a whole where <xxx> signifies an identifier to the DB you're dumping (e.g. Dev, UAT, Live etc). So my dump_local.sh script looks like #!/bin/bash _now=$(date +"%Y%m%d") _file="../dumps/Dump$_now-LOCAL.sql" echo "Starting Dump to $_file..." /Applications/MAMP/Library/bin/mysqldump -h localhost -P 8889 -u root -p'PasswordHereWithTheQuotes' --single-transaction [DBNAME] "$_file" echo "Dump to $_file finished" Key things to note here is : 1) 1st line of code generates a datestamp 2) It then creates a path of the dump file in the dump folder 3) Then it calls MySQLDump using the predefined parameters. Obviously this is for my local installation, so for a server dump file you'll want to change the dump suffix (from LOCAL to DEV,UAT,LIVE or whatever), the hostname, user, password, port (which will be different to 8889 most likely. Mine is 3306 on our service provider) and DBName. If you;re wondering what the single transaction flag is ... The restore files are similar except for my scripts, I've chosen to do a specific one for each XXX2YYY variation. Not the most efficient, but I'm not a bash script ninja either. XXX being Source, YYY being destination in case your'e wondering. So my restore_local2dev.sh looks like : #!/bin/bash _now=$(date +"%Y%m%d") _file="../Dumps/Dump$_now-LOCAL.sql" echo "Starting restoring from $_file to dev ..." /Applications/MAMP/Library/bin/mysql -h [HostDBServerAddress] -P [HostDBServerPort] -u [HostDBUserLogin] -p'[HostDBUserPwdInSingleQuotes]' [HostDBName] < "$_file" echo "Restoring from $_file to dev finished" Notes : 1) I'm using mysql instead of mysqldump here 2) I'm assuming you already created a dump today of the DB file you're uploading (line 2 & 3) 3) There's a bit more involved here with the parameters but I hope the long descriptive labels are self explanatory. Feel free to contact me on this forum if you're unsure. By all means these should cover the basics that you need. Things to improve upon are obviously in the security side of things. There's -ssl options and SSL certificate options that I haven't looked in at detail. If anyone is using them and willing to give us a quick primer ....2 points
-
Custom Inputfield Dependencies A module for ProcessWire CMS/CMF. Extends inputfield dependencies so that inputfield visibility or required status may be determined at runtime by selector or custom PHP code. Overview Custom Inputfield Dependencies adds several new settings options to the "Input" tab of "Edit Field". These are described below. Note that the visibility or required status of fields determined by the module is calculated once at the time Page Edit loads. If your dependency settings refer to fields in the page being edited then changes will not be recalculated until the page is saved and Page Edit reloaded. Usage Install the Custom Inputfield Dependencies module. Optional: for nice code highlighting of custom PHP install InputfieldAceExtended v1.2.0 or newer (currently available on the 'dev' branch of the GitHub repo). The custom inputfield dependencies are set on the "Input" tab of "Edit Field". Visibility Show only if page is matched by custom find Use InputfieldSelector to create a $pages->find() query. If the edited page is matched by the selector then the field is shown. Show only if page is matched by selector As above, but the selector string may be entered manually. Show only if custom PHP returns true Enter custom PHP/API code – if the statement returns boolean true then the field is shown. $page and $pages are available as local variables – other API variables may be accessed with $this, e.g. $this->config In most cases $page refers to the page being edited, but note that if the field is inside a repeater then $page will be the repeater page. As there could conceivably be cases where you want to use the repeater page in your custom PHP the module does not forcibly set $page to be the edited page. Instead, a helper function getEditedPage($page) is available if you want to get the edited page regardless of if the field in inside a repeater or not. $edited_page = $this->getEditedPage($page); Required The settings inputfields are the same as for Visibility above, but are used to determine if the field has 'required' status on the page being edited. https://github.com/Toutouwai/CustomInputfieldDependencies http://modules.processwire.com/modules/custom-inputfield-dependencies/1 point
-
Hello everyone, I've been fiddling around a lot lately with docker containers for my local development on a linux machine. Tried many different options, also readily available processwire images and tutorials from the forum. But never got it right. Mainly because of permission issues with docker volumes. That is a tricky part on linux machines whereas on OSX it doesn't seem to be an issue. Then I discovered http://www.wordpressdocker.com/. And the setup with nginx as a proxy that routes requests to separate containers with the actual site install appealed to me. The whole thing sits on top of alpine linux containers which are really lightweight. So I decided to give it a try. And, first time since experimenting with docker, I got a running PW install. Rewriting was not working until I adjusted the nginx config. Now I have a fairly complex PW site running in a container. Everything is working, image upload/editing etc. So I'm really exited, especially since the dev site is now blazing fast compared to my old vagrant virtualbox vm setup. Honestly, I don't really understand everything that is happening behind the scene. But I managed to adjust the original files and build a new image that works with PW and doesn't have all the WP stuff. The nginx config I took from https://github.com/elasticweb/nginx-configs/blob/master/configs/processwire-2.conf Not sure if it covers everything for PW3 as well. I would very much appreciate if someone who is more in the know than me could take a look. All files for building the docker image are here https://github.com/gebeer/alpine-php-processwire A working image here: https://hub.docker.com/r/gebeer/alpine-php-processwire/ Documentation is kind of lacking. I took over quite a lot from the original project. But following the github README and the original documentation should get people started who have a little experience with docker already. If someone needs a more in depth step by step tutorial for setting things up, let me know and I'll put something together.1 point
-
This morning I pushed a module to github which extends the page api with moving and sorting capability. https://github.com/kixe/PageMove * CALLABLE (static & instance) * PageMove::execute($page, $parent = null, $newIndex = 0, $selector = 'all'); * $modules->get('PageMove')->execute($page, $parent = null, $newIndex = 0, $selector = 'all'); * * EXTENDED PAGE API * @method $page->move($parent, $newIndex = null, $selector = 'all') * @method $page->setIndex($newIndex, $selector = 'all') // set absolute index include=all * @method $page->getIndex($selector = '') // same as $page->index without argument @see getSelector() * * @method $page->moveFirst($parent = null) * @method $page->moveLast($parent = null) * @method $page->moveForward($steps = 1, $selector = 'all') * @method $page->moveBackwards($steps = 1, $selector = 'all') * * @property $page->moveFirst // same parent * @property $page->moveLast * @property $page->moveForward * @property $page->moveBackwards * * EXTENDED PAGES API * @method $pages->move($page, $parent = null, $newIndex = 0, $selector = 'all') * @method $pages->resortChildren($page, $selectorValue) * // same like core function $pages->sort($page, true); with capibility to change the sort condition Have a nice weekend.1 point
-
Awesome, thanks! Must admit I get a bit downhearted sometimes about my progress. What I do is read over my old posts, then I realise that I've actually learned hell of a lot over the last 6 months and am already making things more complex than I did previously (and actually writing php and javascript). Although my age doesn't help, that over the hill feeling creeps up on me quite a lot when I see people half my age programming all sorts of things I can't even understand a few lines of. Not stopping though, enjoy it too much.1 point
-
Yes, adding the namespace is the "correct" way to do things with PW 3 when starting new projects. The file compiler was built primarily as a way to facilitate easy upgrades from PW 2.x without needing to change any files, and also to support non-namespaced modules in PW 3.1 point
-
There is a great tutorial by @kongondo that might be helpful for situations like yours: https://processwire.com/talk/topic/3579-tutorial-approaches-to-categorising-site-content/1 point
-
OK. Note for later : sleeping is sometimes useful. So it eventually had nothing to do with PW search nor sanitizer. It was more about me being a moron. This came from libreoffice not inserting the correct apostrophe character in the source data sheets. A simple search and replace in my original CSV will sort this out (I had to change a few things anyway). Thank you all, folks, I could have lost hours before thinking of checking the source material. (as I should probably have done first....)1 point
-
I completely agree. I don't mind about the absolute sort value, but the page index should be in the right place. In my example it is enough if the page with previous sort value 7 get the index 2, which is the fact if a sort value of 12 is assigned (one more than 11) For handling pages the absolute sort value is not of interest it does say nothing, the index position is the important value. So it would be nice in addition to get the index via $page->index having a setting method. Of course I will do that. https://github.com/processwire/processwire-issues/issues/2251 point
-
Maybe this could help: http://ckeditor.com/addon/tableresize To force initial 100% you could use CSS: table:not([style]) { min-width: 100%; } Since Table Resize adds an inline style the initial 100% width should go away if the user resizes the table.1 point
-
Will it cause any issues if I convert all of my Text, Textarea & PageTitle fields to TextLanguage, TextareaLanguage & PageTitleLanguage without acctually adding additional languages for now? The additional languages will be added after months. Sorry if my question is stupid.1 point
-
Ok, so it is lossy. But my point was, that in comparison to TinyJPG it doesn't visually alter the image with darker colors and blur.1 point
-
<?php $pagearr = $pages->newPageArray()->add($page->myfield);1 point
-
Where did you read that Guetzil is lossless? https://arxiv.org/abs/1703.04421 "visually indistinguishable images" also "...by combining advanced psychovisual models with lossy compression techniques." It is lossy, so if you want to keep the original, you need to keep the original1 point
-
The following quote from the blog post is useful in understanding how your templates need to be structured in order for Markup Regions to work: So the general rule is: the place where you define your 'original' markup regions (that you will append to, etc, in your template files) needs to have the doctype or <html> element in it, and it needs to be the last piece of markup to be rendered. That's why your markup regions would typically be originally defined in an auto-appended "_main.php" so that it is rendered last, and any markup that you are echoing or outputting in your template files will reference those regions and appear before the doctype/<html> of _main.php.1 point
-
When Migrator and MigratorWordpress were written, there was no system "published" field in Processwire. There is now, so I just pushed updates to both modules to support writing to that system field. Unfortunately untested at the moment (no time today), but hopefully will work as expected. With that in place, you should be able to delete that "date" field if you wish and use the "published" field to get the same information. Cheers, Adrian1 point
-
Bootstrapping means 'require'-ing ProcessWire website from elsewhere, like this: <?php require_once '/absolute/path/to/your/PW/site/index.php'; foreach( \ProcessWire\wire('pages')->get('/')->children() as $ch ) { echo "{$ch->title}\n"; } I've just tried this so I won't lie to you: I literally just created this in in my home directory, ran it in terminal with PHP and got a list of page titles in the console. So by writing your own importer, people mean something like this: <?php require_once '/path/to/processwire/index.php'; $wire = \ProcessWire::wire(); // get stuff you want to import $articlesToImport = \OldCMS\DB::query($oldSiteDB, 'select * from articles join whatever'); // iterate over it and create pages for it foreach($articlesToImport->next() as $oldArticle){ $newArticle = new \ProcessWire\Page(); $newArticle->template = 'article'; $newArticle->parent = $wire->get('/articles/'); $newArticle->title = $oldArticle->get('title'); $newArticle->body = $oldArticle->get('html'); $newArticle->save(); } And that's it. You've just imported some articles from your old CMS to your brand new ProcessWire installation. Of course, on "real" pages you'll want to think about this for a bit; Maybe create pages for authors first, some categories, some tags, and then maybe add the pages in parts, so you don't timeout mid-import, or turn off timeout.1 point
-
And here goes some code. Place this on site/ready.php (or create a module from it) and edit the first lines to your liking: /*************************/ /******* EDIT HERE *******/ /*************************/ // ID of the page where the custom content is $this->pageID = 1; // name of the field where the custom content is $this->fieldName = 'body'; // name of html tag and id from the parent of the custom content on the 505 file $this->elementTag = 'div'; $this->elementID = 'message'; /*************************/ /******* END EDIT ********/ /*************************/ // regex to get the contents of parent element $this->regex = '/(<'.$this->elementTag.'\sid=("|\')?'.$this->elementID.'("|\')?>)([^<]|<.+>.*<\/.+>)+(<\/'.$this->elementTag.'>)/i'; // On save the content of the field on the 505.html file $this->addHookAfter('Pages::saved', function(HookEvent $event) { $page = $event->arguments[0]; if($page->id !== $this->pageID) return; $file = wire('config')->paths->templates . '/errors/500.html'; $content = file_get_contents($file); $field = $this->fieldName; $content = preg_replace($this->regex, '$1'.$page->$field.'$3', $content); file_put_contents($file, $content); }); // On render the edit page, save the content of 505.html file on the field to show it $this->addHookBefore("ProcessPageEdit::buildFormContent", function(HookEvent $event) { $page = $event->object->getPage(); if($page->id !== $this->pageID) return; $file = wire('config')->paths->templates . '/errors/500.html'; $content = file_get_contents($file); preg_match($this->regex, $content, $matches); if($matches) { $page->of(false); $field = $this->fieldName; $page->$field = $matches[0]; $page->save($this->fieldName); } }); The above code assumes that your "505.html" file has a <div> with the id "message" in it, you just have to adapt it to yours.1 point
-
1 point
-
Just so you don't miss them; there are sorting functions in the dev version of 3.0: https://github.com/processwire/processwire/blob/4ca684df83db90aa6cfe5a76ef7a830b399af721/wire/core/Pages.php#L841-L9161 point
-
We started using mustache template engine with PW. Since mustache is implemented in various languages. Currently I can render anything either server side or client side with js or php and both share the same code base. Data can be either objects arrays or json whatever you like. We also use patternlabs node mustache version for prototyping and so all patterns can be used 1:1 in PW later using some simple controller system based on Classes that extend PW WireData so all API can be used. We also use terrificjs for easy modular js components. So no vue or react but just to mention that there's everything possible in PW.1 point
-
I'm using Rochen Host and have enabled Let's encrypt on my MVS. Love it! Took longer to update google's webmaster tools and analytics than enabling my sites to TLS. My question is whether I should encourage my existing clients who have EV certs now to switch to Let's Encrypt when they expire?1 point
-
Czech Language Pack for PW 3.0 Pre-release version is online. Check it at github. https://github.com/PavelTajdus/ProcessWire-Czech-Language-Pack/releases1 point
-
Hi guys, Czech lang pack is on github, and pre-release version for PW 3.0 will be uploaded soon. So you can download, test, update, and hopefully colaborate on Github. You will find all releases on GitHub repo. And again, thank you Radek for your work on this. We all really appreciate that.1 point
-
Hi, after long time Czech Language Pack is online again. Project was transfered to github and we have new maintainer Pavel Tajduš. Module page is updated and work on PW 3 support already started. Thank you Pavel.1 point
-
1 point
-
main.inc should keep the largest possible code for all your different layouts and include sub-xy.inc files. Lets say for example you have the default layout with $bodycopy and $sidebar and additionally a onecolumn layout without sidebar: You define a new variable e.g. $myLayout: // here is how it would look like in the /site/templates/init.inc <?php $headline = $page->get("headline|title"); $bodycopy = $page->body; $sidebar = $page->sidebar; $myLayout = "default"; // we only write the name without the fileextension, this way we also can set a CSS-class in the body tag! // or you put it into the head of every template file, here: /site/templates/basic-page.php <?php $headline = $page->get("headline|title"); $bodycopy = $page->body . $page->comments->render(); $sidebar = $page->sidebar; $subnav = $page->children; $myLayout = "default"; include("./main.inc"); Now move the smallest possible segment from your main.inc into default.inc and replace it in main.inc with an include("./$myLayout"): /site/templates/main.inc <html> <head> <title><?php echo $headline; ?></title> </head> <body class="<?php echo $myLayout;?>"> <?php include("./{$myLayout}.inc"); ?> </body> </html> /site/templates/default.inc <div id='bodycopy'> <h1><?php echo $headline; ?></h1> <?php echo $bodycopy; ?> </div> <div id='sidebar'> <?php echo $sidebar if(count($subnav)) { echo "<ul class='nav'>"; foreach($subnav as $child) { echo "<li><a href='$child->url'>$child->title</a></li>"; } echo "</ul>"; } ?> </div> Lets say you don't want the sidebar on your homepage, then you define / overwrite in your /site/templates/home.php the $myLayout var with $myLayout = "onecolumn"; // we only write the name without the fileextension, this way we also can set a CSS-class in the body tag! Create a file called "onecolumn.inc" and put in your desired markup, e.g.: /site/templates/onecolumn.inc <div id='bodycopy'> <h1><?php echo $headline; ?></h1> <?php echo $bodycopy; ?> </div> To stile your onecolumn layout with CSS you need to append to your css something like: body.onecolumn div#bodycopy { width: 100%; }1 point
-
Thanks again. That helped. I'm using the API to build my forms. They have different names and ids already. When I create the submit button like // submit button! $submit = $modules->get("InputfieldSubmit"); $submit->label = " "; $submit->attr("value","Save Changes"); $submit->attr("id+name","submitprofile"); //Notice submitprofile here - that did the trick $submit->attr("class","btn btn-success"); $profileForm->append($submit); and check if data should be processed with if ($input->post->submitprofile) { //do processing here } It is working and other form submissions do not interfere anymore1 point