Leaderboard
Popular Content
Showing content with the highest reputation on 01/27/2016 in all areas
-
Background - I came across http://www.responsivebreakpoints.com/ the other day and thought it was a nice idea, but that could be done in PW using the API. In a nutshell, what it does is create an image width breakpoint at roughly every 20kb of file size between a minimum and maximum pixel size. According to this article on CSS-Tricks, "If you’re just changing resolutions, use srcset", so the markup is as suggested there. There is already the excellent Srcset Image Textformatter which works on images in RTE fields, but if you want responsive images elsewhere in your templates, you need to do the markup and decide on breakpoint sizes yourself. However, Field Templates have got you covered! Just save this as a field template file in /site/templates/fields/my_image.php as described above. <?php $maxWidth = 1000; //largest breakpoint $minWidth = 200; //smallest breakpoint $srcQuality = 40; //jpeg quality of the 'src' image $srcsetQuality = 80; //jpeg quality of the 'srcset' images $breakpointStepFileSize = 20; //i.e. 20kb $class = ""; //change this if you want to add eg "class='responsive'" $horizAspect = $value->width / $value->height; $minSizeArea = round($minWidth * ($minWidth / $horizAspect)); $maxSizeArea = round($maxWidth * ($maxWidth / $horizAspect)); $areaDiff = $maxSizeArea - $minSizeArea; $minFile = $value->width($minWidth, array('quality' => $srcsetQuality)); $maxFile = $value->width($maxWidth, array('quality' => $srcsetQuality)); $minFileSize = $minFile->filesize; $maxFileSize = $maxFile->filesize; $fileSizeDiff = $maxFileSize - $minFileSize; if($fileSizeDiff > ($breakpointStepFileSize * 1024)){ $numBreakpoints = round($fileSizeDiff / ($breakpointStepFileSize * 1024)); for($s = 1; $s < $numBreakpoints; $s++){ $breakpointStepArea = $minSizeArea + (($areaDiff / $numBreakpoints) * $s); $breakpointWidth = round(sqrt($breakpointStepArea * $horizAspect)); $breakpoints[] = $breakpointWidth; } } $src = $value->width($maxWidth, array('quality' => $srcQuality))->url; $min = "$minFile->url {$minWidth}w, "; $out = "<img src='$src' srcset='$min"; foreach($breakpoints as $breakpoint){ $bp = $value->width($breakpoint, array('quality' => $srcsetQuality))->url; $out .= "$bp {$breakpoint}w, "; } $out .= "$maxFile->url {$maxWidth}w"; $out .= "' alt='$value->description' $class>"; echo $out; Then use something like echo $page->render->my_image; in your page template and you'll get something like <img src='/site/assets/files/1/photo.1000x0.jpg' srcset='/site/assets/files/1/photo.200x0.jpg 200w, /site/assets/files/1/photo.482x0.jpg 482w, /site/assets/files/1/photo.651x0.jpg 651w, /site/assets/files/1/photo.785x0.jpg 785w, /site/assets/files/1/photo.899x0.jpg 899w, /site/assets/files/1/photo.1000x0.jpg 1000w' alt='pic' > (Bear in mind that PW has to create all these image variations on first page load, so it will take a moment.) Give it a try and see what you think!8 points
-
So, some days later I'm the one who has submission powers in product hunt. They just sent me an invite And... here it is! https://www.producthunt.com/tech/processwire PS: You don't need an invite to register and upvote, and we need those upvotes to appear on the homepage5 points
-
They won't let me login without a Twitter or Facebook account - what is the world coming to4 points
-
I posted this here https://processwire.com/talk/topic/11998-growing-processwire-in-2016/?p=111884 but I thought it would be better to open a new thread to catch the attention of more people. Today I submitted PW to Product Hunt. https://www.producthunt.com/tech/processwire This is a site with great exposure, but only if PW gets featured on the homepage. For this it has to be reviewed by the Product Hunt team and one of the most important factors is the number of upvotes. So, what are you waiting for? Why are you still here? Edit: If anyone would like to suggest different pictures for the header and thumbnail, go ahead.3 points
-
$page->addStatus(Page::statusLocked); $page->removeStatus(Page::statusLocked); Have a look at the cheatsheet.3 points
-
Disturbing read Willy! but good idea - disposable Twitter account worked a treat - I've voted!2 points
-
2 points
-
2 points
-
Here a link to a search for "StatusLocked" on the PW Github repo: https://github.com/ryancramerdesign/ProcessWire/search?utf8=%E2%9C%93&q=statuslocked&type=Code That should show you what you need.2 points
-
Product Hunt will receive the following info: your public profile, friend list and email address. Sorry there seems to be no opt out for this. Isn't there another way to upvote for processwire without spreading my private data around ?2 points
-
@pwired It's not about fitting images, but about serving images in an appropriate size to each user. Mobile users will thank you about not needing to download that 1920 * 400 herobanner your using on your biggest layout breakpoint. @rick Such things would probably already be in the core if image resizing wouldn't be such a resource consuming task on multiple fronts.2 points
-
Thanks for testing Spica! All what you have found out belongs to sharpening, and indeed there are two instances where currently no memory-check is invoked. Those both (not several!) instances belong to the unsharpMask function, what is enabled by default to create the best possible result for your images. So, as we have to find a balance between fast image processing and to avoid going out of memory, every user should take a bit care with his sites. If you are low on memory, you definetly should limit the max dimensions for upload images. Besides that, you uncovered that we need to describe more features we have under the hood with image processing. With a slide change in the $config settings we can disable the usage of the UnsharpMask for sharpening and switch to another algorithm, what needs much much lesser memory. This unsharp algorythm was there earlier, but we decided to switch to the visually better working USM by default in times where 256M seems to be a common value for memory usage. Conclusion: we will implement memory checking for those two instances currently not covered too, and we will provide flags within the $config settings that enables users to simply switch between sharpening algorythms in systems with low memory. Once again, thanks for your tests and reports, it is much appreciated.2 points
-
You need to get in in context $p = $pages->get(1040); $label = $p->fields->get('body', true); echo $label; // or if you are sure the page is there, a one-liner echo $pages->get(1040)->fields->get('body', true); Edit: I could have sworn @LostKobrakai was asleep . Beaten, again2 points
-
It's a php.ini directive and should be set there, if possible. If PHP runs as an apache module, you should be able to set php_value user_agent "PHP" there. Or you could set it in PW's init.php. ini_set("user_agent", "PHP " . PHP_VERSION);2 points
-
Ok, after a quick crash course with Github, I managed to upload the module for testing. I've included my test templates which should give an idea of how to use the module. I use UIkit for testing, so that's the markup you'll find in the templates. Obviously this is early code and has only been tested by me, so don't use it for anything other than testing. The module does NOT sanitize, so you need to ensure you have sanitized your message before you use the topicSave() or commentSave() methods. Documentation is nonexistent, but the module is fairly straight forward and I can help where needed. So, thoughts, issues, insults? Does it have potential? and if anyone wants to add to it etc, please let me know. Link removed - HermodBB is now discontinued and is now being developed as LiteBB. I will update the thread with further information.2 points
-
jonithlnljani how ? wolud makes.infinite ploop no ? or how u.say in englich. circle jerkey or.recurses no ending.samasaras likes when trimmer beard in.bathroon w 2 mirror & u see millonions of willys2 points
-
Hello and happy new year to everybody This little module adds an unselect button to PageListSelect. You can define to which PageLists the button is added via module config (CSS selector). it solves this issue: https://processwire.com/talk/topic/9677-unselectclear-button-for-pagelistselect/ https://github.com/BernhardBaumrock/PageListSelectUnselectButton Changelog: v 2.0.0 - added support for ajax loaded fields including repeaters - added sanitization for the jquery selector1 point
-
A collection of links and information for front-end development. Front-end forms Create simple forms using the API https://processwire.com/talk/topic/2089-create-simple-forms-using-api/ Gist code for the above link https://gist.github.com/somatonic/4027908 Build and process generic forms from page templates https://gist.github.com/somatonic/5011926 Build and process forms manually with the API https://gist.github.com/somatonic/4027908 Upload images https://gist.github.com/somatonic/4150974 Form with fields rendered in a table https://gist.github.com/somatonic/5415646 Manual form markup with file upload handling https://gist.github.com/somatonic/5233338 Form Builder (module) Building front-end forms on your website has never been so simple. ProcessWire Form Builder lets you create, edit and publish forms with no development necessary. http://modules.processwire.com/modules/form-builder/ Front-end member management FrontendUser: login, logout and register users / members (module) https://processwire.com/talk/topic/9811-frontenduser-login-logout-and-register-users-members/ Member login, logout, password reset https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/?p=15919 Popular front-end UI frameworks UIkit http://getuikit.com/ Semantic UI http://semantic-ui.com/ Foundation http://foundation.zurb.com/ Bootstrap https://getbootstrap.com/ Materialize http://materializecss.com/ Skeleton http://getskeleton.com/1 point
-
Okay, I must really like ProcessWire. I registered with a throw-away account and voted.1 point
-
out for this. Isn't there another way to upvote for processwire without spreading my private data around ? i alsos donut like.to spread my.privates a round withs tweetster u.can jus make throws away acct to uses.for this stuffs butt fecesbook tweetster and friendsters blocked in.my cuntry butt i stil haves myspaces butt no work w produt hunter butt at lest not blocked .i keep try to make work1 point
-
Sure, but horst's idea does not rule it out. If you process the image right after the upload, you (the admin user) need to wait for the resizing process, but what if you change your mind before checking the related page on the frontend and decide to re-upload the image? In that case you need to wait twice, or more (depending on how many times you have changed your mind). So the answer to this question is not as straightforward as it might seem at first.1 point
-
Glad that worked for. Just in case you don't know you can avoid the need for an entire module to add simple hooks like this. You can place the hook and method in site/templates/admin.php There are also site/init.php site/ready.php and site/finished.php files that you can make use of. More reading here: https://processwire.com/blog/posts/processwire-2.6.7-core-updates-and-more/#new-core-files-for-site-hooks1 point
-
Thank you so much for your advice adrian!!! Now it works! <?php class RepeaterLastItemCatcher extends WireData implements Module { public static function getModuleInfo() { return array( // The module'ss title, typically a little more descriptive than the class name 'title' => 'RepeaterLastItemCatcher', // version number 'version' => 2, // summary is brief description of what this module is 'summary' => 'Dieses Modul fängt den letzten Eintrag des Repeaters "" ab.', // Optional URL to more information about the module 'href' => 'https://onur-sahin.de', // singular=true: indicates that only one instance of the module is allowed. // This is usually what you want for modules that attach hooks. 'singular' => true, // autoload=true: indicates the module should be started with ProcessWire. // This is necessary for any modules that attach runtime hooks, otherwise those // hooks won't get attached unless some other code calls the module on it's own. // Note that autoload modules are almost always also 'singular' (seen above). 'autoload' => true, // Optional font-awesome icon name, minus the 'fa-' part 'icon' => 'smile-o', ); } public function init() { // add a hook after the $pages->save, to issue a notice every time a page is saved $this->pages->addHookAfter('FieldtypeRepeater::savePageField', $this, 'catchLastItem'); } public function catchLastItem($event) { /* Die Argumente sind die Parameterübergaben folgender Methode -> ___savePageField https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module#L958 */ $page = $event->arguments[0]; // Der zuletzt hinzugefügte Text des Referenz-Repeaters $lastSavedReferencesText = $page->referencesList->last()->referencesText; // Das zuletzt hinzugefügte Bild des Referenz-Repeaters $lastSavedReferencesImage = $_SERVER['SERVER_NAME'].$page->referencesList->last()->referencesImage->first()->url; // Testweise mal ausgeben im Backend $this->message("lastSavedReferencesText: " . $lastSavedReferencesText); $this->message("lastSavedReferencesImage: " . $lastSavedReferencesImage); // Ab dieser Stelle kommt dann die Facebook-SDK zum Einsatz... } }1 point
-
1 point
-
Also check out this module for adding more flexibility to the automated page name: http://modules.processwire.com/modules/process-setup-page-name/1 point
-
@Rick: If an author modifies a page, i would assume that he inspect the result on the frontend, before publishing a page. Exactly with this inspection, he raises the first page load and all imagevariations get created. And as an author or admin user, he has / should take this time to wait. After that, the first regular visitor gets presented the cached variations. Hhm, or not?1 point
-
Just a guess based on a quick look through the repeater source code, but maybe try hooking: FieldtypeRepeater::savePageField https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module#L958 Also possibly: InputfieldRepeater::processInput (although this is before the repeater has saved, so not sure if it will be of any help) https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module#L2361 point
-
Your version is not working because the runtime selector currently does not support parsing "today" to it's timestamp like the db selector engine does. $pages->find("template=repeater_events, end_date>today, sort=end_date, limit=2"); $pages->get("template=events")->events->find("end_date>" . time() . ", sort=end_date, limit=2");1 point
-
Just my opinion, but this type of functionality should be included in the core image functions as each image is uploaded and saved. We as developers nust account for the greater diversity in user devices in the future. Having images processed on the backend (vs frontend page render) based on styles specific to a project (config options) would be tremendously helpful. Set it and forget it, type of thing.1 point
-
Sorry, I was unclear. I did not mean to optimize for 64M. It is just a limit, as 512M also is. And 512 can be easily reached and lead to break the page when we use large images and lots of instances for effects. I can not come up with a solution as I am not realy into the code. I have no clue how often the instances are needed or how to deal best with it. My consideration is: What environment is needed to not get broken pages? Is it predictable? If I now set the limit to 256 or even 512, does it guarantee to not cause any error? If these errors can not be avoided by the script, how to calculate the max. needed limit (therefore we should know how many instances are needed for what effect)?1 point
-
$templates->get("package")->fields->getField("body", true); $templates->get("package")->fields->getFieldContext("body");1 point
-
That's still an error even if it's gone. I'm in a pw 305 project but haven't notice this, will check later again. Thanks for the info.1 point
-
I tested like this my target picture (thumb) is 2500x1870 I tested two memory limits, 128 and 64 with array('sharpening' => 'none') both tests rendered the image with sharpening on 64M Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 10000 bytes) in /Applications/MAMP/htdocs/ProcessWire-dev/wire/core/ImageSizer.php on line 1632 128M Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 18700001 bytes) in /Applications/MAMP/htdocs/ProcessWire-dev/wire/core/ImageSizer.php on line 1655 then with your imageSizer.php modification and sharpening on 128M image gets rendered 64M Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 10000 bytes) in /Applications/MAMP/htdocs/ProcessWire-dev/wire/core/ImageSizer.php on line 1678 So it seems to me, that there are several more instances created for different image effects which take the memory uncontrolled. Even if 64M may seem to be a very low memory to someone, but as devices resolution may rise in future high resolution images even higher memory limits may get broken.1 point
-
@horst: Strange things are going on. As you proposed I set autoRotation to false in both the config settings imageSizerOptions and adminThumbOptions, and put your image call in a template, used by a newly created test page. Result: Already with the upload of the test-image to the images field of the test page the created thumbnail was autorotated (i.e. displayed upright). Viewing the page, the half-sized image is oriented correctly, too. Inserting the original, full sized image into the body field (textarea/CKEditor) resulted in an autorotated output (backend and frontend). In the folder /site/assets/8765/ (where 8765 is the id of the test page) there is the file image test_1.jpg (width 600), not rotated like the original, and the half-sized image test_1.300x0.jpg, rotated to the correct orientation. (*) To crosscheck I reset the autoRotation settings in the config both back to true. Now both the admin-thumbnail in the backend and the half-sized image in the frontend are displayed not rotated (the latter one, inserted by the template, of course doesn't show in the frontend). But the full sized image inserted via the CKEditor ist autorotated correctly, both in backend and frontend... Thanks a lot, Horst, for your help! (*) Another strangeness: The original file I uploaded was test_1_.jpg, i.e. the name had a trailing underscore. This obviously is removed by PW processing the image. (But I don't think that has any influence on the problem in discussion.) EDIT: I also called your function checkOrientation(), it returned nothing.1 point
-
Don't put anything in the wire directory - put it in site/modules/AdminTheme/ I don't recall if it has to be prefixed with AdminTheme to work, but do you have any reason for not following the convention already used for AdminThemeDefault and AdminThemeReno ?1 point
-
Nope, there is no workaround for this and I don't really think there should be - call one "image" and one "images" (or similar) and it will be a lot simpler for you to remember which one belongs where and will also make more sense in your template API code.1 point
-
Hang on there sir..... you actually mean to say I got something right on here? There's hope for me yet in the coding world.1 point
-
$pages->delete($page, true) That will also permanently delete any child pages, media items etc.1 point
-
Thanks Horst, for the explanation. if I put your snippet into my template I do get bool(true) bool(true) as output, so the memory limit should be read. But when I set my output dimension of the image up I still get: Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 18700001 bytes) (line 1655 of /usr/www/users/user/ProcessWire/wire/core/ImageSizer.php) Dont know why line 1655 causes the error, as I am only resizing with image->width and image->height1 point
-
The Imagesizer detects the settings of the Exif orientation tag and autocorrects this where needed, if it is enabled. The setting to enable / disable this for all variations can be set in $config->imageSizerOptions "autoRotation". The default is true: $config->imageSizerOptions = array( 'upscaling' => true, // upscale if necessary to reach target size? 'cropping' => true, // crop if necessary to reach target size? 'autoRotation' => true, // automatically correct orientation? 'sharpening' => 'soft', // sharpening: none | soft | medium | strong 'quality' => 90, // quality: 1-100 where higher is better but bigger 'hidpiQuality' => 60, // Same as above quality setting, but specific to hidpi images 'defaultGamma' => 2.0, // defaultGamma: 0.5 to 4.0 or -1 to disable gamma correction (default=2.0) ); There is an extra setting for this for AdminThumbs, default is true, too: $config->adminThumbOptions = array( 'width' => 0, // max width of admin thumbnail or 0 for proportional to height 'height' => 100, // max height of admin thumbnail or 0 for proportional to width 'scale' => 1, // admin thumb scale (1=auto detect, 0.5=always hidpi, 1.0=force non-hidpi) 'upscaling' => false, 'cropping' => true, 'autoRotation' => true, // automatically correct orientation? 'sharpening' => 'soft', // sharpening: none | soft | medium | strong 'quality' => 90, 'suffix' => '', ); Please ensure that you have autoRotation set to true for both use cases.1 point
-
I have to say that the form API works pretty well in the frontend. I have several sites where I use it without issues. Once you get the hang of it, it is actually quite nice to interact with. Only thing I am missing is a more easy way than the current to get more control over the rendered markup. Formbuilder comes to the rescue here. If I remember correctly, when UI framework support was introduced to formbuilder, Ryan stated that the core functionality was altered to easier support UI frameworks. But I never found any hints on how to easily alter rendering of form markup (especially field wrapper's markup and attributes) other than through hooks. Nevertheless, I agree that it would be nice to have a docs section dedicated to this topic. Or at least have a link collection to relevant forum posts that deal with frontend forms, processing and saving of input values. Links I can come up with quickly: https://processwire.com/talk/topic/2089-create-simple-forms-using-api/ and, of course, Soma's great gists (big kudos) https://gist.github.com/somatonic/5011926 (build and process generic forms from page templates) https://gist.github.com/somatonic/4027908 (build and process forms manually with API) https://gist.github.com/somatonic/4150974 (upload images) https://gist.github.com/somatonic/5415646 (form with fields in table) https://gist.github.com/somatonic/5233338 (manual form markup with file upload handling)1 point
-
Hi adrianmak, here's a good read: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Markup/MarkupAdminDataTable/MarkupAdminDataTable.module It's not that don't want to fish and cook for you, but fishing your self will give you more experience.1 point
-
1 point
-
The docs says: $page->of(false); // outputFormatting must be OFF https://processwire.com/api/multi-language-support/multi-language-fields/#getting-and-setting "The value of a multi-language or language-alternate field is affected by the "outputFormatting" setting of a page. On the front-end of your site, outputFormatting is always turned on, unless you've turned it off." "When outputFormatting is ON, the value of a multi-language field is a string (as it shows in most examples on this page). That string reflects the value from the current user's language. If the value is blank in the current user's language, the value from the default language will be there instead. However, when outputFormatting is OFF, the value of a multi-language field (like $page->body) will instead return an object of type LanguagesPageFieldValue, rather than a string. That object contains all of the translations available for the given field." I'm not sure that this solves anything, I'm just guessing. Sorry if I'm mistaken.1 point
-
Example for a use case with importing things. This is a raw draft with a bit pseudo code: // you have created a queue in PW, the ID of the page is 2000 for example // here is some skeleton code for an importer that uses this queue // get and validate the queue handle if(! ($queue = $pages->get('id=2000')->wireQueue())) exit(); // we could not get the Queue page // now start to scan / read data for your imports, wrap each record into an array and put it into the queue foreach($pages->find(YOURSELECTOR) as $p) { $data = array($p->field1, $p->field2); $queue->addItem($data); } // now start to process your items by pulling one after the other from the Queue while($timer < $maxtime) { $data = $queue->getItem(); // process the $data ... } $session->redirect('./');1 point
-
Agreed. This is a surprisingly common gotcha for regular users. Opening the page tree again to unselect selection is not very intuitive.1 point
-
1 point
-
Translation Problems Path of 'Datepicker translation file' is set in translation file (json) of inputfield DateTime. File (/wire/modules/Jquery/JqueryUI/i18n/jquery.ui.datepicker-de.js) exist and is accesible. cache cleaned Datepicker still uses default regional settings Need help, any ideas? # Edit 23.04.2015 Problem solved, edited jquery translation by adding timepicker regional settings. (/wire/modules/Jquery/JqueryUI/i18n/jquery.ui.datepicker-de.js). Example below (german) /* German initialisation for the jQuery UI date picker plugin. */ /* Written by Milian Wolff (mail@milianw.de). */ /* edited by kixe: timepicker settings added 23.04.2015 */ jQuery(function($){ $.datepicker.regional['de'] = { closeText: 'schließen', prevText: '<zurück', nextText: 'Vor>', currentText: 'heute', monthNames: ['Januar','Februar','März','April','Mai','Juni', 'Juli','August','September','Oktober','November','Dezember'], monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun', 'Jul','Aug','Sep','Okt','Nov','Dez'], dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'], dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'], dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'], weekHeader: 'KW', dateFormat: 'dd.mm.yy', firstDay: 1, isRTL: false, showMonthAfterYear: false, yearSuffix: ''}; $.datepicker.setDefaults($.datepicker.regional['de']); $.timepicker.regional['de'] = { timeText: 'Uhrzeit', hourText: 'Stunde', minuteText: 'Мinute', secondText: 'Sekunde', millisecText: 'Millisekunde', timezoneText: 'Zeitzone', currentText: 'jetzt', closeText: 'schließen', timeFormat: 'HH:mm', isRTL: false }; $.timepicker.setDefaults($.timepicker.regional['de']); });1 point
-
Logic is too broad a term. There is presentational logic and there is application logic. IMO the logic you want to keep out of the main template is application logic, not presentational logic. If there is presentational logic that applies to most pages in the site, then I really prefer to have it in the main template, or at least include()'d from the main template. It comes down to what's going to simplest to maintain long term. If something presentational needs to be manipulatable by other templates, then of course it should go in it's own placeholder variable. But if it's not, then delaying that output or moving it somewhere else is just more overhead and things to keep track of. This is of course just fine, and everyone's got different methods that work best for them. But I would also suggest that the more markup you can keep in your main template (that's common to most pages) then easier it is to maintain over time. Easy to maintain means different things to different people, so I should qualify that to me "easy to maintain" is when the site-wide markup is in fewer places, fewer files to update, etc. I don't think the holy grail is necessarily eliminating html tags from your template files. That's what I did with the blog profile, sticking to an MVC approach. But I don't find it as maintainable as default site profile intermediate method (maybe for a team, but not for an individual developer). Further, and somewhat to my disappointment, I think most find the blog profile (sticking to an MVC approach) difficult to understand. The fact is that this approach means more files, more things to keep track of. It's the right solution for some cases, but it's no holy grail. I think instead the holy grail is KISS + DRY (keep it simple stupid + do not repeat yourself). If you've got markup going in a template file where the same markup is going in another template file, then put it in a shared function, include file, template/view file or a class/hook or something (I prefer functions myself). If you've got to change something, make sure you only have to change it on 1 place. The end result ends up being most template files have little or no markup, not unlike the MVC blog profile… but a whole lot easier to understand and maintain– you've KISS'd it, minimizing the number of places where markup appears and not adding extra unnecessary overhead and files. The benefits of going further MVC become apparent when you work in a team where the concerns are split along the same lines as the files. In that case, more files is beneficial. The front-end markup girl/guy focuses purely on the view files, and the back-end developer focuses purely on application logic. But if it's not a team project like that, and isn't going to be, then following that approach is kind of like trying to avoid stepping on the seams in a tile floor as you walk across it… Think of "main" as meaning "main" (like primary), not "all". One example of different layouts can be seen in the intermediate profile's _main.php where it adds a has-sidebar class to the body tag when a $sidebar variable has something in it. But there's no requirement that _main.php be used by every template file. You can disable the $config->appendTemplateFile in your /site/config.php and include your own, like Martijn outlined above. Or you can edit your template in the admin: Setup > Templates > [your-template] > Files. Check the box to disable auto-inclusion of _main.php, or specify what file you want it to include instead.1 point
-
Hi there, in need for a light knowledge base software and not happy with solutions such as MediaWiki, Dokuwiki or Confluence I decided to try to build such a tool based on ProcessWire. At the moment this profile is lacking of features, but doing well in the context it is created for - a somewhat protected simple knowledge base for internal use. It has some basic features but I'm aware that there's still way to go. So if anyone is interested, please find the code attached here or on GitHub: https://github.com/marcus-herrmann/ProcessWire-KnowledgeBase-SiteProfile I exported the data from a PW 2.4 installation, but not have tested it yet against older versions. Installation Before running the installer of ProcessWire copy/replace /site-default/install/ /site-default/templates/ /site-default/modules/ with the folders from this zip. Constraints It's not possible to export user roles with ProcessWire's Site Export Module this profiles templates are checking just whether they are accessed by an anonymous or logged in user. Features Tagging of wiki-articles Set articles to globally sticky ( = for all users) Personal bookmarking of articles for logged in users When using markdown to author wiki-articles, code highlighting via highlightjs Included modules Fredi MarkupSimpleNavigation Hopefully this profile is useful for you in any way. Best, marcus Edit: Forgot GitHub link... ProcessWire-KnowledgeBase-SiteProfile-master.zip1 point