Leaderboard
Popular Content
Showing content with the highest reputation on 12/01/2014 in all areas
-
4 points
-
3 points
-
2 points
-
another use i just found is for rapid prototyping of repeating content, prior to committing to real fields. for example i'm making a testimonials slider for a client, but they have been tentative about many things on their site, so i'm not setting up any fixed fields now until they commit to certain elements of the front end; example - author: William role: Client text: Integer eu libero sit amet nisl vestibulum semper. Fusce nec porttitor massa. In nec neque elit. Curabitur malesuada ligula vitae purus ornare onec etea magna diam varius. - author: James role: Hippie text: Posuere erat a ante venenatis dapibus posuere velit aliquet. Duis llis, est non coeammodo luctus, nisi erat porttitor ligula, egeteas laciniato odiomo sem.2 points
-
HTML5 Geolocation is opt-in only, so I wouldn't rely on that. First-time-visitors are prompted to a popup for accepting the auto-detect. And if your website is not self-explanatory why it needs the geolocation I'd rather use that with caution. Probably best solution is to give the visitor the choice like: WEST | CENTRAL or [auto detect location]* Then somewhere on the site give an explanation why they should accept auto-detection like "* our website offers different content dependent on your location. We can auto-detect your location, you only have to allow this once". And addtionaly start detecting only if visitor has clicked the detect button.2 points
-
2 points
-
Ladies, Gentleman, GOT IT! Here it is: AllowOverride All or the second part of the httpd-vhosts.conf file here: <VirtualHost *:80> DocumentRoot "C:/mysite2" ServerName propertymarch ServerAlias propertymarch <Directory "C:/mysite2"> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all Require all granted </Directory> </VirtualHost> These PW forums are great. It is good to be part of this nice community. I hope this helps someone else. March2 points
-
This gets you the label in the context of the entered template. $templates->get("template_name")->fieldgroup->getField('body', true)->label; You could also do this to get for the template of the current page: $templates->get($page->template->name)->fieldgroup->getField('body', true)->label;2 points
-
This module allows you and your site editors to protect a page (and optionally its children, grandchildren etc) from guest access directly from the page's Settings tab. You can also limit access to certain roles. http://modules.processwire.com/modules/page-protector/ https://github.com/adrianbj/PageProtector It makes it very easy for editors to set up various password protected areas on their site, or to simply protect a new page or section while they are still working on it. Ability for your site editors to control the user access to pages directly from Settings tab of each page Include whether to protect all children of this page or not Optionally allow access to only specified roles Option to protect all hidden pages (and optionally their children) Ability to change the message on the login page to make it specific to this page Option to have login form and prohibited message injected into a custom template Access to the "Protect this Page" settings panel is controlled by the "page-edit-protected" permission Table in the module config settings that lists the details all of the protected pages Shortcut to protect entire site with one click In addition to the admin interface, you can also set protection settings via the API: // all optional, except "page_protected", which must be set to true/false // if setting it to false, the other options are not relevant $options = array( "page_protected" => true, "children_protected" => true, "allowed_roles" => array("role1", "role2"), "message_override" => "My custom login message", "prohibited_message" => "My custom prohibited access message" ); $page->protect($options); As alway, I would love any feedback / suggestions for improvements. Hope you find it useful! Page Protection Settings (settings tab for each page) Module Config Settings1 point
-
Pia - Pageimage Assistant Hello, today I can tell you that Pia Ballerina want to assist you with Pageimages and that can become really helpful! . . . Pia, in its current state, version 1.0.0, provides: a GUI (the module config screen) for quick and easy changes to the sitewide Pageimage default options an alternative way for calling the Pageimage resizing methods with PW selector strings three new methods as shortcuts to the resizing functions a new method called retinafy and its alias hiDPI, (introduced in version 0.2.0) . . . 2) Instead of ->width(), ->height(), ->size() you can call ->pia() now. With a PW selector string you tell Pia what image variation you want to have : . $image->pia("width=100, quality=80, sharpening=medium")->url; . If you want process ->width() just define width. If you want process ->height() only define height. If you want process ->size() just define width and height. If you want process ->size() with equal values for width and height, just define only size, or use the alias square: . $image->pia("width=480")->url; $image->pia("height=320")->url; $image->pia("width=400, height=300")->url; $image->pia("size=350")->url; $image->pia("square=350")->url; . So, yes, - I see. Now you may think: "Ok, nice looking girl, - and she can dance very well, - but for what should it be good that she is involved here? My very old buddies width, height and size - and me, - we don't need any Ballerinas between us!" . Yeah, I see what you mean. But this above is not what Pia is good for, this is just a little warming up for you. . In some cases one need to specify more than just width and / or height. If it comes to that you need explicitly populated options with the individual pageimages, Pia will become faster and more comfortable at some point. Also the code is looking more readable with Pia, at least to me: . // regular style #1: $image->width(800, array("upscaling" => false, "cropping" => true, "quality" => 80, "sharpening" => "strong")); // or regular style #2: $options = array("upscaling" => false, "cropping" => true, "quality" => 80, "sharpening" => "strong"); $image->width(800, $options); // now lets Pia dance: $image->pia('width=800, upscaling=0, cropping=1, quality=80, sharpening=strong'); $image->pia('width=800, upscaling=off, cropping=on, quality=80, sharpening=strong'); . For me it is that not only Pia begin to dance, my fingers do so too when writing selector strings instead of the regular array code. . Ok, last thing before we can go to stage: "You already may have noticed that Pia accepts few different values for boolean expression, yes?" for TRUE you can write these strings: "1, on, ON, true, TRUE, -1" for FALSE you may use one out of "0, off, OFF, false, FALSE" Ready? Ok, lets go to stage. . . . 3) Pia provide three new methods as shortcuts. This means that when using one of the shortcuts you have pre-populated options, regardless of the sitewide default settings: crop :: does what the name says contain :: is equal to the regular method: ->size($width, $height, array("cropping" => false)) cover :: this, Pias third child, is a new kid on the block . Let's have a closer look and compare it. We use Pias image from above as source for this example. (It's dimensions are 289 x 400 px) . . * crop $image->crop('square=100'); . it is 100 x 100 px and the name is: pia-ballerina_titel.100x100-piacrop.jpg . . . * contain $image->contain('square=100'); . it is 73 x 100 px and the name is: pia-ballerina_titel.100x100-piacontain.jpg . . . * cover $image->cover('square=100'); . it is 100 x 139 px and the name is: pia-ballerina_titel.100x139-piacover.jpg . . . Ok, you got it? . "Crop" crop out the area, "Contain" fits the image into the area, and "Cover" calculates the needed dimensions for the image so that the area is completly covered by it. . Following is a link with lots of those crop-, contain-, cover- variations. I have stress-tested it a bit: much variations . ---------- . . Later Additions: . * contain with option weighten Since version 0.0.6 contain can take an additional param called "weighten". (read more here) . . . * retinafy Since version 0.2.0 retinafy is added. It returns a markup string, e.g. a HTML img tag, where placeholders are populated with property values from the pageimage. Default properties are: URL, WIDTH, HEIGHT, DESCRIPTION. The method also can take an optional array with CustomPropertyNames. You also can use the alias HiDPI if you like. (read more here) . . ---------- . . You can get the module from the modules directory or from the repo on Github: . git clone https://github.com/horst-n/PageimageAssistant.git your/path/site/modules/PageimageAssistant . . Bye! . Classical ballet performance at the Aalto Theatre in Essen, in the context of the Red Dot Award ceremony 26 June 2007, Act III, Sleeping Beauty, the wedding reception Photos: Horst Nogajski - www.nogajski.de1 point
-
Needed to show someone how to quickly setup some settings for various things in a simple text area: could be used for slider settings, site settings, etc; What it does: gives you a matching variable for each key of each line... 1.) setup a textarea field for the settings ; i'm calling it settings_ta 2.) add delimited settings, 1 per line; i use a pipe (|) delimiter; example: address|some info here facebook|https://www.facebook.com twitter|https://twitter.com phone|(999) 999-9999 3.) in your _init.php, get the settings - replace the page number and the name of your settings field: $settings_ta = $pages->get(1644)->settings_ta; $settings_lines = explode(PHP_EOL, $settings_ta); foreach($settings_lines as $settings_row) { $settings_pair = explode('|', $settings_row); ${trim($settings_pair[0])} = trim($settings_pair[1]); } more condensed version, for those of you who like brevity... foreach(explode(PHP_EOL, $pages->get(1644)->settings_ta) as $settings_row) { $settings_pair = explode('|', $settings_row); ${trim($settings_pair[0])} = trim($settings_pair[1]); } now you can do this in your templates: echo $address; echo $facebook; echo $twitter; echo $phone; Edit: made the code simpler....; 2nd edit - added trim to support using ace editor with tabs Addendum: as an added convenience, you could use the Ace text editor module which would give you a monospaced text field and the ability to use tabs for your settings, which could be more readable and easier to edit. The code has been updated to support this by trimming the exploded strings prior to generating the variable/value. address | some info here facebook | http://www.facebook.com twitter | http://twitter.com phone | (999) 999-99991 point
-
-------------------------------------------------------------------------------------------------------------------- UPDATE: This module is not supported. It was only working for PW versions between 2.4.3 and 2.5.11 But since PW 3.0.10-devns, there is core support for the Imagick PHP extension, and with third party modules ImageMagick_CLI and Netpbm_CLI is supported too. And I think, when time goes on, there will follow some more. -------------------------------------------------------------------------------------------------------------------- Hi, for those who don't know it already, we have started to build an ImageSizer replacement based on Imagick / ImageMagick. Its actual state is that we now have implemented a basic color management and optionally an ICC-based more accurate color management. Due to not finding much answers and informations on the net about that we have had some struggle to get it working on different ImageMagick versions. And even if it works on three or four versions that we can get hands on, we need more informations of supported versions. There for it would be really helpful that you test that feature on as many different servers you can and report back the result. To make that as easy as possible I have created a Siteprofile together with the latest PW-Devbranch and a brandnew ImageSizer.php. You can get it above in this post as ZIP. It has many images for different tests and it is more robust now. after installing the site profile, you need to install the Imagick Resizer in the admin under section modules the frontpage is a site with different image tests to run the tests you need to be logged in (in the backend) we are interested in the results of ImagickResizer test cms-with-icc_short if the first test looks successful (all text is green) you may go on and test ImagickResizer test cms-basic_visual and maybe ImagickResizer test cms-with-icc_visual At the end of the page you should see a summary like that: array(13) { ["test"] string(18) "cms-with-icc_short" ["hasUsedCMS"] string(3) "6/6" ["executiontime"] string(12) "5.9393400000" ["engine"] string(18) "Apache 2.0 Handler" ["php"] string(6) "5.4.26" ["os"] string(81) "Windows NT KAWOBI 6.1 build 7601 (Windows 7 Business Edition Service Pack 1) i586" ["imageMagick"] string(5) "6.8.8" ["imagick module version"] string(5) "3.1.2" ["imagick classes"] string(56) "Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator" ["ImageMagick version"] string(38) "ImageMagick 6.8.8-4 Q16 x86 2014-01-29" ["ImageMagick copyright"] string(46) "Copyright (C) 1999-2014 ImageMagick Studio LLC" ["ImageMagick release date"] string(10) "2014-01-29" ["ImageMagick number of supported formats"] string(3) "225" } Please first visually check if the images look ok or if they have strange issues (e.g. very much to brighten). Report if the images are ok and copy/paste that summary array here into the thread (please use the [<>] code button when pasting - for good readability!). Do that for the first test (cms-with-icc_short) regardless if it succeeds or failed! If you do not see a summary, there is a great chance that you are not logged in or that you have selected a different test than that we are interested in As a visual reference you can look here for the short_test, the test with icc and here for a basic test result. Note: Without icc-cms the cymk and gray images do not look good, but this is expected!1 point
-
Hi I would like to share with you my first module. Module integrates PixlrEditor with a InputfieldImage. You can easily edit your images online. The module provides a link to edit each field type InputfieldImage. Have fun;) Warning: I have not tested yet on localhost. As Ryan pointed out. It does not work on localhost. Pixlr webservice must have the ability to get images from your server. Source: https://github.com/P...GIX/PixlrEditor Screenshots: Changelog 1.0.2Now Support Thumbnails Module - Thanks to joey102030 for the addition.1 point
-
Hi as we just prepare for the translation of all processwire modules we installed all Modules and realized that some ar simply crashing the complete sites when getting installed. I will list them here and perhaps the deveolpers or somebody else who would like to maintain them can try to fix them - otherwise IMHO they should simply be removed from the ProcessWire Repository if they are already in there. If they are not in than we won't load them to be translated until it is fixed anyway. All those Modules got freshly loaded with the very useful ModulesManager! We are using Processwire 2.5.10 If you are having Problems with your ProcessWire site simply check if you have perhaps installed one of those modules! Simply deinstall them or/and move them to another location if they are crashing the site i.e. This post will be edited when we discover more problems: MODULES CRASHING SITES MobileDetect Compile Error: require_once(): Failed opening required 'lib/Mobile_Detect.php' (include_path='.:/usr/share/php:/usr/share/pear') (line 57 of /.../public_html/site/modules/MobileDetect/MobileDetect.module) This error message was shown because you are logged in as a Superuser. Error has been logged. ProcessAbbreviate Compile Error: require_once(): Failed opening required '' (include_path='.:/usr/share/php:/usr/share/pear') (line 1091 of /.../public_html/wire/core/Modules.php) This error message was shown because you are logged in as a Superuser. Error has been logged. ProcessLanguageTranslatorTwigSupport Recoverable Fatal Error: Argument 1 passed to InputfieldSelect::addOptions() must be of the type array, null given, called in /.../public_html/site/modules/ProcessLanguageTranslatorTwigSupport/ProcessLanguageTranslatorTwigSupport.module on line 180 and defined (line 72 of /.../public_html/wire/modules/Inputfield/InputfieldSelect.module) This error message was shown because you are logged in as a Superuser. Error has been logged. TemplateEngineTwig Error: Cannot redeclare class Twig_Autoloader (line 17 of /.../public_html/site/modules/TemplateEngineTwig/twig/lib/Twig/Autoloader.php) This error message was shown because you are logged in as a Superuser. Error has been logged. Spex Compile Error: require(): Failed opening required '/.../public_html/site/templates/layouts/default.php' (include_path='.:/usr/share/php:/usr/share/pear') (line 186 of /.../public_html/site/modules/Spex/Spex.module) This error message was shown because you are logged in as a Superuser. Error has been logged. TemplateTwig Error: Cannot redeclare class Twig_Autoloader (line 18 of /.../public_html/site/modules/TemplateTwig/TemplateTwig/Twig/Autoloader.php) This error message was shown because you are logged in as a Superuser. Error has been logged. ProcessLatestComments Error: Class 'Comment' not found (line 59 of /.../public_html/site/modules/ProcessLatestComments/ProcessLatestComments.module) This error message was shown because you are logged in as a Superuser. Error has been logged. MODULES NOT SHOWING AS INSTALLED even they have been installed! FrontendUserRegistration LdapSignIn TextboxList MetroWire EleganceAdminTheme Compliance FrontendUserProfile SmartyTemplating TextformatterAutoParagraph Unify Teflon WireTasks BootstrapAdminTheme AppyAdminTheme FuturaAdminTheme ErgoAdminTemplate MODULES NOT SHOWING AS UPDATED AFTER AN UPDATE FlagPages ProcessJSONInstaller LanguageLocalizedURL MODULES CRASHING THE TRANSLATION TOOL INSIDE PROCESSWIRE UserGroupsHooks NOT USEFUL MODULES FOR TRANSLATIONS ProcessLanguageTranslatorTwigSupport --> It is radically deletes the ProcessLanguageTranslator Page when you dseinstall it and it does not offer multiple file select to be translated. If you have more than 10 files to be translated this means 10 times the same clicky click procedure every time until all 10 files are able to be translated - it wastes a lot of time! OTHER PROBLEMS WHEN INSTALLING MODULES VersionControlForTextFields --> snapshot module seems to be doubled - why not simply checking and deinstalling the one which is to much instead of bringing up that error. Warning: there appear to be two copies of module "PageSnapshot" on the file system. Please remove the one in /site/modules/ unless you need them both present for some reason. 1. /site/modules/VersionControl/PageSnapshot.module2. /site/modules/VersionControlForTextFields/PageSnapshot.moduleMarkupLoremIpsum--> Why does it want to deinstall when we want to install?Could not remove directory /.../public_html/site/assets/MarkupLoremIpsum.module TextformatterSoundcloudEmbed --> Path wrong FuturaRemixed CustomPageRoles -->Could not open zip file ServicePages --> Displaying the code of the site in the frontend! CryptoPPP --> not able to be installed and therefore many other modules which depend on that cryptoPPP are simply not installable and not working1 point
-
1 point
-
Repeaters are stored in admin with own template not "admin" template, so a logged in superuser see's them but others not. it's not a bug. You could exclude admin or by template if you want superuser not see them. has_parent!=21 point
-
Fair enough, but you could at least copy the HTML, CSS, JS, strip all sensitive data (replace content with lorem ipsum, replace logos, links etc.) and post a copy somewhere? The description you gave is just too minimal. It's probably a CSS issue, but without more infos, I'm afraid no one can help you.1 point
-
I would let the visitor choose. Or at least make sure you have a scenario, what to show when somebody deactivates the geolocation feature.1 point
-
Hi Teppo and Marcus thanks for having a look at it! Yes some are not compatible but often they are simply not updated ;-) to the current working version. As time goes by you will realize that also in Processwire the amount of modules and dead no more maintained modules will rapidly increase. To avoid a chaos like on other CMS I really recommend to make a rule that those not showing at least the latest stable level which woudl be 2.5 get removed to an archive. At TYPO3 that system worked pretty good after it was introduced as many Module Developers use their modules also as portfolio for their abilities etc. And immediately even Developers who did not maintain their extensions over years updated very fast to 6.2 to be again present and presented to the public. The Modules manager usually directs you to the native tools if he can't install stuff. As we tru to get the translation stuff up and running we like to have all modules and even those old ones in unless someone really don't use them anymore. But actually we will se what will get used as that will be translated the rest probably not. There are lots of admin themes which are I guess complete obsolete and if than should be removed. Keeping a repository updated working and clean with only maintained modules also helps to speed up developing and is god for the image of a CMS too.1 point
-
Thanks for the heads up regarding module versioning. I learned that the modules not showing up as being updated have one thing in common: Version numbers below 1.0.0 (like for example, my FlagPages module). I just installed FlagPages on a PW 2.5.10 system, and though its version is set as 022 (0.2.2) ProcessWire somehow understands it as 0.1.8 and offers an update to 0.2.2. I'll test FP's ability to run under 2.5+ (it totally should), and will then bump both version number and compatible PW version.1 point
-
So the en_US language folder shows 134 core and 256 module files to be translated. I have uploaded also all modules and templates and created a "modules crashing sites" folder where I have taken those modules whch crashed the site during installation or at any later point. It is mainly the templating stuff like TWIG and SPEX afaiks. I am still waiting for the confimration but actually everyone can already help to translate those files. I will see if I can create a Profile with all those modules for transtaion purposes. Let's see. Than everybuddy could help to get things done! using a local installation and than pushing the stuff to github again. or another way would be to use our translation installation (it has the multilanguage package frontend and backend.. But here I would need to see if it is possible tor restrict users to edit only their language and don't touch others. Perhaps sopmeone knows how to do that in Processwire. This way we would not need at first place weblate and could start immediately until they confirm but the downside would be that there won't be a review process. But I think if we have teams they can coordinate themselves and check by themselves as it will be mainly them afterwards who will need those translations. Right now all processwire modules which can be installed by the modulemanager have been installed and could be translated currently I am running core 2.5.10 All translations still get stored in a traditional way in assets/files on a page with PageID but I will than move those to github into the site/languages/ folderwith the correct two letter codes for language and flavour. From there everyone can pull the translations again to his site and store it where he ants ;-) until we have a better solution which first checks the files folder for a local translation and if there isn't any available than checks the languages folder and use that one. If your module is not on that github send me the link and I will install and than upload it if it installs without any problems on 2.5.10 + (always the highest version) Please keep your modules updated and working with the upcoming versions. It also would be good if the Japanese and greek Translators would shorten their package name to simply Japanese and Greek like all the other ones did already. Thanks. The files are still loading so give it some time until it will appear on git. I will let you know.1 point
-
Thanks, I'll take a closer look at the ones I've got access to, probably later today. It should be noted that you've also been installing some modules that have not been declared as compatible with 2.5, which is why your comment about "removing from the directory" seems a bit off. Either way it's a good thing if we can catch (and preferably update) such modules. Another note would be that while ModulesManager is a great module in itself, it would be nice to rule it out as a cause to the issues, i.e. installing problematic modules with native tools and seeing if that causes the same issue These are never intended to be installed simultaneously; VersionControlForTextFields is for PW 2.4.0 or earlier, there's no reason to use it for anything later than that. Also, PageSnapshots.module is not identical between these modules, so removing one of them would only render one of the modules unusable -- not a valid solution. Admittedly that's a bit of a weird situation you've got there, but also one that mostly happens if you start blindly installing everything you can get your hands on, and is easily fixed by removing one of the modules. I'll see if I can easily add some way of preventing that without unnecessarily complicating the modules themselves. It might make sense to add a new "incompatible" list to module config; this way module authors could specify modules known to be incompatible with theirs. Not sure if this really is common enough to justify such a thing though1 point
-
Hi all, I found a small glitch in HannCode version 1.9. This only affects Hanna Code tag names which contain a . (dot) character and at the same time contain attributes. For example: [[admin.email]] or [[admin_email recaptcha="true"]] both work as expected and get processed and replaced. But this [[admin.email recaptcha="true"]] does not. In file TextformatterHannaCode.module change line 242 from if(preg_match('!^([-_a-z0-9]+)([\s,]|$)!i', $expression, $matches)) { to: if(preg_match('!^([\.-_a-z0-9]+)([\s,]|$)!i', $expression, $matches)) { solves the issue. What is the best way to submit bugfixes/patches? Should I fork this on github and post a pull request?1 point
-
$fields->save() would save details about that field - various settings etc, rather than the contents of the field on that particular page. $event is coming from the event that is hooked, so in this case, @majkiris is hooking page save, so by getting the first argument from the save event, he is getting the page object. You could also do: $page = $event->argumentsByName("page"); The first argument, eg arguments[0] won't always be the page object, it depends on the hook. Sometimes, for example, it might be the width of an image. Hope that helps a little.1 point
-
I think what you are looking for is: $page->save("total"); If you did just $page->save() you'd end up in a loop because your hook would get called again each time it saves itself. EDIT: Oh and in case you haven't figured it out, you need to set the field value first: $page->total = $ratTotal;1 point
-
1 point
-
Macrura, thanks for testing/using the module. The current master branch only uses WireData on object like structures and regular arrays for numeric key structures. I renamed the module to FieldtypeDataStructrue (because it now supports more than YAML) and have a separate repo for that, what you want is all there on the dev branch. Check it out, I added a bunch of features (including your wanted WireArray output and a couple of new input/structure types, beside YAML) and the whole thing is unit tested, so it SHOULD be pretty stable: https://github.com/owzim/FieldtypeDataStructure/tree/dev More detailed info on the new version: https://github.com/owzim/FieldtypeDataStructure/blob/dev/README.md For now you should create a new field and not change the fieldtype on your existing one to the new FieldtypeDataStructrue I think it now became pretty powerful, I am planning to make a video to cover it and all it's possible use cases. Please (all) share your thoughts on how else it could be used.1 point
-
When you are editing a page, it is possible to highlight a word and hyperlink to a page, but I do not see a way to highlight an email address and hyperlink that. The only way I see if a customer wants to do this is to edit via html, and type mailto: in front of the email address. I know its not the best practice due to spam bots, but users still seem to want to do it sometimes. Thanks!1 point
-
1 point
-
It would be great if PW would resize images using Imagemagick/graphicsmagick if one of those libs is installed as theyy provide far better quality and use less memory than GD or GD2. Just an idea.1 point
-
I've been inlining media queries in my LESS files (I haven't gotten around to using SASS yet, and because of AIOM) for a while now. As you say the CSS is a mess but I'm OK with that. I usually have a variable at the top of my LESS file: @mobile: ~"handheld, only screen and (max-width: 767px)"; When I need to use it: foo { margin-bottom: 3rem; @media @mobile { margin-bottom: 20rem; } } If I find myself needing more breakpoints I just add a variable with a different max-width.1 point
-
1 point
-
Lets see if we can get a quick-start tutorial going here. We'll start with something really simple and then work up from there. Tell me when something makes sense and when it doesn't and we'll adjust as we go. My thought is that we'd make a tutorial that plays on the 'hello world' phrase and lists information about planets in the solar system, starting with Earth. To keep it simple, we'll assume that the basic site profile is installed, as that's what comes with ProcessWire (so there's no need to uninstall anything). But we won't start using any of it's files tat this stage. Instead, we'll start out by creating our own files. STEP 1 – Create a template file Create a new file called: /site/templates/planet.php, and copy+paste the following HTML into that file: <html> <head> <title>Earth</title> </head> <body> <h1>Earth</h1> <h2>Type: Happy planet, Age: Millions of years</h2> <p>Earth (or the Earth) is the third planet from the Sun, and the densest and fifth-largest of the eight planets in the Solar System. It is also the largest of the Solar System's four terrestrial planets. It is sometimes referred to as the World, the Blue Planet, or by its Latin name, Terra.</p> </body> </html> The above is just a plain HTML file with nothing specific to ProcessWire. We will use this as the starting point for our template, and we'll go back and modify it later. STEP 2 – Add a template to ProcessWire Login to ProcessWire admin and go to Setup > Templates. This page shows a list of templates currently in the system. Click the Add New Template button. On the next screen that appears, you'll see it found your "planet" template file. Check the box next to the planet template and click Add Template. You may ignore any other options that appear on this screen. STEP 3 – Creating a page using your template Your planet template is now in the system and ready to use, but it's not being used by any pages. So lets create a page that uses the planet template. In the ProcessWire admin, click Pages in the top navigation. This is a site map if your page structure. We want to create a new page under the homepage, so click the new link that appears to the right of the home page. The next screen has 3 inputs: title, name and template. Enter "Earth" for the title, and the name should populate automatically. For the template, select planet. Then click Save. Now you have created a new page using the template that you added. You are now in the page edit screen and you should see your title field populated with "Earth". Click the View link that appears on this page edit screen. You should see the output of the HTML from step 1. Click the back button in your browser to return to the edit screen. STEP 4 – Creating a new field Now you know how to create a template and a page using that template. You could create more pages using the same template if you wanted to. But that wouldn't be particularly useful – this template file is just a static HTML file. Lets make it dynamic by creating some fields and adding them to it. We are going to create 3 fields to represent the pieces of data that currently appear in our static template. These include the planet's type, age in years, and a brief summary. We will call these fields: planet_type, planet_age and planet_summary. In ProcessWire admin, click Setup > Fields. This screen shows a list of fields currently in the system, most of which are general purpose fields for the basic profile. For the purposes of this tutorial, we are going to ignore those and create our own. Click the Add New Field button. On the next screen, enter "planet_type" for the Name, select "text" as the Type, and enter "Planet Type" for the Label. Then click the Save Field button. Now that your field is saved, you are on the Field Edit screen. At this point, your field is created and ready to be added to your planet template. Optional: While editing your field, click the details tab where you'll see a select box for Text Formatters. Select "HTML Entity Encoder" – this ensures that characters like "<", ">" and "&" will be converted to HTML entities and not confused as HTML tags. While not required, it's a good practice for text fields like this. After you've done that, click the Save Field button. STEP 5 – Creating more new fields In step 4 we created the planet_type field. Now we want to create the planet_age and planet_summary fields. So in this step, you'll want to do the same thing for the remaining two fields: Create the planet_age field exactly like you created the planet_type field, but enter "Planet age in years" for the label. Create the planet_summary field exactly like you created the planet_type field, but chose "textarea" as the Type and enter "Planet summary" for the label. Note that a "textarea" field is just like a "text" field, except that it can contain multiple lines of text. STEP 6 – Adding new fields to your template Now that you've created 3 new fields, you need to add them to your planet template. In ProcessWire admin, click Setup > Templates > planet. You are now editing your planet template. In the Fields select box, choose planet_type, then planet_age, then planet_summary. You will see each added to the list. Cick the Save Template button. STEP 7 – Editing a page using your template Now that you have new fields added to your template, go back and edit the Earth page you created earlier and populate the new fields that are on it. In ProcessWire admin, click Pages at the top, then click the Earth page, and click the edit button that appears to the right of it. You are now editing the Earth page you created earlier. You should see the new fields you added, waiting for text. Enter "Terrestrial planet" for Planet Type Enter "4.54 billion" for Planet Age in Years Paste in the text below for Planet Summary and then click Save. STEP 8 – Outputting dynamic data in your template file While still in the page editor from step 7, click the "View" link to see your page. Note that it still says "Happy planet" for type (rather than "Terrestrial planet") and "Millions of years" rather than "4.54 billion years". That's because the page is still being rendered with just the static data in it. We need to update the template file so that it recognizes the fields we added and outputs the values of those fields. Edit /site/templates/planet.php and replace the static text in there with tags like this, replacing field_name with the name of the field: <?php echo $page->field_name; ?> If supported by your server, you may also use this shorter format which some people find easier to look at and faster to enter: <?=$page->field_name?> Here is the /site/templates/planet.php file updated to output the content of the page using tags like the above: <html> <head> <title><?php echo $page->title; ?></title> </head> <body> <h1><?php echo $page->title; ?></h1> <h2>Type: <?php echo $page->planet_type; ?>, Age: <?php echo $page->planet_age; ?> years</h2> <p><?php echo $page->planet_summary; ?></p> </body> </html> After making these changes, save your planet.php template file. Now view your Earth page again. You should see it properly outputting all of the content you entered on the page, including "Terrestrial planet" for Type and "4.54 billion years" for age. Any changes you make from this point forward should be reflected in the output. STEP 9 – Creating more pages, reusing your template For this last step, we'll create another page (for Jupiter) using the same template just to demonstrate how a template may be reused. In ProcessWire Admin, click Pages and then click the new link to the right of the home page. Enter "Jupiter" as the Title and select "planet" for the Template. Click Save. Now that you are editing the Jupiter page, enter "Gas giant" for Type, enter "4.5 billion" for Age in Years, and copy+paste the following for Planet Summary: Click the Publish button and then View the page. You should now see your planet template being used to output the information for Jupiter rather than Earth. CONCLUSION In the above, we covered the basics of how to develop in ProcessWire, including the following: Creating templates and their associated template files Creating basic text fields and adding them to templates Creating and editing pages that use your templates Outputting the values of fields in template files If all of this makes sense so far, I thought we'd follow up next with a tutorial to take this further: Adding and outputting photos for each planet Creating navigation that lists all the other planets that have pages in the system …and we'd keep building upon the tutorial from there. If you all think this tutorial is helpful, then perhaps this can be a draft for a real tutorial we'll put on the site, so all of your help is appreciated in making this as good as it can be.1 point
-
It is supercool. Be sure the check these short tutorials from Youtube: https://www.youtube.com/watch?v=IRelx4-ISbs1 point