Leaderboard
Popular Content
Showing content with the highest reputation on 08/22/2022 in all areas
-
Or just use the URL Path Hooks function ? https://processwire.com/blog/posts/pw-3.0.173/#introducing-url-path-hooks /site/init.php <?php $wire->addHook('/hello/world', function($event) { include($this->wire->config->paths->templates."test.php"); return true; }); Now you can use the Url "https://your.site/hello/world/" - and the content comes from /site/templates/test.php5 points
-
v1.17.0 adds a nice helper to download webfonts automatically to /site/templates/fonts Austria is hit by a wave of legal letters demanding 190€ from website owners that serve google webfonts from the google servers directly instead of self-hosting them. Selfhosting fonts on the other hand is tedious!! I know there is the google-webfonts-helper, but I wanted something better integretad into my PW workflows. So RockFrontend now downloads all the necessary files for you (eot/woff/woff2/ttf/svg) by sending separate HTTP requests to google with different user agents and saving the fonts with a readable name to /site/templates/fonts Simply paste the url and hit save:3 points
-
3 points
-
With the ease of Processwire in my hands I feel I can almost do anything to make the website of my dreams ? It's actually getting easier by the day to just not rushing into things and start to think about structure first. Now I am focused what I want to display, later on how to make it look. But there are still some things I do not find with ease on the PW docs. For example, possibilities for sort. By mistake I found out sort=-title (minus sign), is actually sorting on title from Z to A. Another thing is, the difference between Finding and Getting pages it beyond me. Could not found it, did not get it ?. Right now, I am developing a website as affiliate. This means I display product redirecting to certain sellers. But my children have a large part in it: they enhance the look, improve images, test things, and give feedback. My steps to a professional website so far: Getting to know Processwire, so much information to grab. I now know, at install, the code on the pages are examples, not mandatory! Structure files in the root of the website first. Then templates, and pages - according to my idea (what is logic and what is not handy in my situation. Find a template to use with ease: I have found a great free HTML bootstrap 5 template that I use right now. Try behavior design: what would you do on this website you are looking at right now? Take regular breaks, don't try to push things in a limit time, do not make it difficult. But the main thing is: Processwire is so much fun to develop websites (no joke) 10+ for PW. Enjoy3 points
-
You can also create a new template (ex. api) with just the title field. Create the template file (ex. api.php) and publish a page on your site without access restriction (ex. domain.com/api) and that's it. In your template file (which is your entry point) you can use: $input->post(), $input->get() or urlSegments to get the request data, and then you can include files, or execute functions or whatever you want. Finally you print everything in JSON format, or in html format if you want to use htmx. Piece a cake! ?2 points
-
This is in the selector docs, right were you would expect it ? Granted, the page is pretty long and cluttered when you’re just scrolling through, but it’s great for CTRL+F’ing and the table of contents at the top is very helpful. Mostly “find“ means “I have some criteria, give me any pages that match it” (only those the user may view, by default). “Get” means “I know exactly which page I want, give it to me”. Get gives you one specific page, Find gives you multiple. There is also pages()->findOne() if you only want a single page – the difference here is that this will check if you have access first, while pages()->get() will always give it to you if it exists, even if it’s unpublished or hidden. Anyway, rock on! I’m sure you will be enjoying PW for years to come ?2 points
-
thank you guys for your helpful answers! as i'm still a pw rookie this helps a lot! crawling through all the articles and posts mentioned here i ended up with an approach mostly similar to what @Pixrael suggests and i'm happy to see this work like a charm ??1 point
-
Check this : https://processwire.com/api/ref/page/children/ // Render navigation for all child pages below this one foreach($page->children() as $child) { echo "<li><a href='$child->url'>$child->title</a></li>"; } So in your case: $children = $pages->find("parent=/categories/, sort=title")->children(); foreach($children as $child) { // ... manipulate $child here }1 point
-
Awesome ? I'm looking forward for a video about RockMigrations!1 point
-
Where? Thx fixed it ? Yeah, that's an improvement ? It's always good to add a note somewhere when doing magic via hooks to make debugging easier!1 point
-
Yes, I couldn’t get it to work either, I amended my comment ? Bernhard’s snippet has a syntax error, here’s the working code: wire()->addHookAfter('Pages::saveReady(template=foo, id=0, status&'.Page::statusTemp.')', function($event) { $event->arguments(0)->status = 1; }); I also added the status check, because you don’t need this to run for every new page. API-created pages will be published by default, for example. Also I’m not sure I would just set the status to 1, in case PW or some other hook wants to set something else, like Locked or Draft or something. Probably better to just remove the ones you want to remove specifically.1 point
-
When ProcessPageAdd quick-creates a page, it gives it a temporary status Page::statusTemp that is removed when the page is next saved using the UI. I imagine you need to remove this status in your hook to make the lightning symbol go away. The temporary status is there so pages that were accidentally created can be cleaned up automatically. I would probably hook ProcessPageAdd::processQuickAdd instead of Pages::save: https://github.com/processwire/processwire/blob/master/wire/modules/Process/ProcessPageAdd/ProcessPageAdd.module#L1091 Edit: Can’t get processQuickAdd to work… Maybe because it redirects the hook doesn’t get a chance to run? Still, it should be sufficient to hook into ProcessPageEdit::execute: wire()->addHookBefore('ProcessPageEdit::execute', function(HookEvent $event) { /** @var Page $page */ $page = $event->object->getPage(); //if the page has statusTemp it was probably created by ProcessPageAdd::processQuickAdd if ($page->hasStatus(Page::statusTemp)) { $page->removeStatus(Page::statusTemp); $page->removeStatus(Page::statusUnpublished); $page->save(['quiet' => true, 'noHooks' => true, 'noFields' => true]); wire()->message('Auto-published that for you. You’re welcome.'); } });1 point
-
@Arcturus, I just released v0.1.4 which adds a hookable method for users like yourself who want to do advanced customisation of the CKEditor inputfield, so you don't need to hack the module itself. See the updated readme. Setting the stylesSet property is working for me. $wire->addHookAfter('InputfieldMarkupCKEditor::ckeReady', function(HookEvent $event) { /** @var InputfieldCKEditor $cke */ $cke = $event->arguments(0); /** @var FormBuilderForm */ $form = $event->arguments(1); /** @var FormBuilderField $field */ $field = $event->arguments(2); if($form->name === 'test_form' && $field->name === 'my_cke_markup_field') { $cke->contentsCss = '/site/templates/MarkupCKEditor/contents.css'; $cke->stylesSet = 'ckstyles:/site/templates/MarkupCKEditor/ckstyles.js'; } }); CKEDITOR.stylesSet.add( 'ckstyles', [ { name: 'Special heading', element: 'h2', attributes: { 'class': 'special-heading' } } ]); Make sure the prefix you are using in the setStyles property matches the style set name in the JS file.1 point
-
https://stackoverflow.com/a/200666 Thanks for forcing me to look that up, and I'm happy I'm safe with my preferred way of writing php using <?php and <?= ? Update 08/2022: Now my favourite way is using LATTE via RockFrontend: {$page->title} instead of <?= $page->title ?> ?1 point
-
Yeah, although the short tag <? seems nice, I have read that you should avoid it, because it has to be enabled on the server and XML also uses <?. Every field that you didn't make a required field I would add an if condition, because it could be potentially empty. ?1 point
-
Hi Folks! After a few years went by, i still ask myself if there is an easy way to set a default text/values for text/textarea fields? What do you think? Or am i the only one who needs something like that?1 point
-
In programming, it is called variable scope. This throws an error because you are using the variable $modules inside the anonymous function and that function does not know what $modules is :-). This should work: <?php $forms->addHook('FormBuilderProcessor::emailFormReady', function($e) { //$pdf = $modules->get('RockPdf'); <= DOES NOT WORK. function does not know 'modules' $pdf = wire('modules')->get('RockPdf');// <= WORKS. function knows GLOBAL FUNCTION wire() $pdf->write('TEST'); $pdf->save('./generated_pdfs/' . date('yy-m-d_H_i') . '.pdf'); } ); PHP variable scope https://www.php.net/manual/en/language.variables.scope.php wire() Function https://processwire.com/api/ref/functions/wire/1 point
-
From my linked post: https://processwire.com/talk/topic/17346-hook-on-repeater-field-save/?do=findComment&comment=152504 ProcessWire has a feature to track changes. If there are no changes unneeded hooks do not get fired. This is not only better for performance (I guess) but also great for conditional hooks: https://processwire.com/blog/posts/new-ajax-driven-inputs-conditional-hooks-template-family-settings-and-more/#new-conditional-hooks1 point