Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/05/2021 in all areas

  1. Wow! Well, that was a can of worms I opened! ? OK, let me come clean and say that I have actually tried - many times! - to load PW on various platforms before. Always Linux based - and let me also say that I have never succeeded. I'm not really interested in a Laragon - Windows approach. I really wanted to get it to run correctly on a Linux based platform. I've tried nginx as well as Apache as the server platform, and neither have set up correctly despite following all the comments and suggestions (except, as I've said before, the 'unzip software' which is, I believe classed as a 'nice to have but not essential'. This time, after yet another frustrating and initially unsuccessful attempt, I thought 'b***r it - I'm going to see what the community can make of this!' Now, despite comments about everything in the one folder, that is NOT how I have things set up. I have an 'index' file in the /var/www/html directory that links to a number of useful applications - node-red; php-lite-admin; webmin etc and these are, of course, in their own sub-folders. And work!! The obvious, and apparently sensible approach, with PW was to put this in a sub-folder, too. No-one ever suggested that wasn't the correct approach! My comments are, then, based on an actively and apparently correctly working web-server and a - supposedly - fool-proof and 'simple to install' CMS and, I'd still argue it wasn't. OK, I accept that my server knowledge isn't that of a professional web designer - but I was 'encouraged' that that wasn't apparently necessary with PW. And, yes, a knowledge of virtual hosting is something I could obviously improve on. But - and I reiterate - that isn't what PW advises me. It tells me 'you are ready to go!' and yet only the front page shows. Now, OK, thanks to the patience of many people here, I ultimately get it working - and I understand the comment 'it wasn't PW - it was your server set-up' because clearly PW was ready to go....but only after making Apache changes. And I'd argue that PW could have better informed me that would be necessary. I really like Jan Romero's remarks, and agree that PW, whilst good, could be made better for less experienced users with an unblinkered look at the install process. And - if that takes place (and it would have to be by persons far more experienced than me!), then.....well, I may have achieved one of my unstated objectives! Thanks again for all the patience, comments and advice - Mike
    2 points
  2. Umm yeah I mean did you run that code? From the looks of it I would say it should rain errors, but if it works for you, that’s great! Allow me to step through and critique it anyway: $this->addHookAfter("ProcessPageAdd::buildForm", function(HookEvent $event) { //get the result of the hooked method, which is a form (class InputfieldForm). //it’s also the only form we care about here, so calling it $form is fine. $form = $event->return; //this gets the parent page, so we can stop doing anything unless we are //at the correct position in the page tree. good. //note the indent I added, though ;) $parentField = $form->getChildByName('parent_id'); $parent = pages()->get($parentField->value); if (!$parent->matches('template=dashboard_customer')) return; /*this is going to error, because $page does not exist here. you CAN *call the current page by writing any of this instead of $page (you *don’t WANT to do that here, though. read on before you change this): * - page() (if you have functions API enabled in config.php) * - wire('page') * - $wire->page * - $this->page * - $this->wire('page') *see https://processwire.com/docs/start/api-access/ *since this is confusing and for all other reasons stated in that link *i would recommend simply always using page() etc. */ $pageid = $page->id; /*this is just weird and unnecessary unless your template labels contain *slashes and end in .php, which in itself seems weird and unnecessary? *if you want a template’s name (usually the same as the template file *without the extension), just use $template->name. * ===> importantly, none of this makes sense because when this code runs, you <=== * ===> cannot know the page’s id nor its template!!! <=== * ===> you want to give the page ITS OWN id for a name. this is impossible to <=== * ===> know at this time, as the page has not been created yet. the template, <=== * ===> likewise, has not been chosen by the user. this code BUILDS the drop <=== * ===> down field that lets the user choose a template! <=== */ $template = basename($page->template->label,'.php'); //this was my suggestion to get the page name field from the form, however, //as we see below, you have discovered a better way, which is great! $nameField = $form->getChildByName('_pw_page_name'); //this was my suggestion to make the field invisible. as you’ve discovered, //you could also use $nameField->collapsed = Inputfield::collapsedHidden. //there is a difference, though! AFAIK, Inputfield::collapsedHidden will //completely REMOVE the field from the form output, so you can’t change it //with javascript. that was my main reason to use the class instead, //because you may actually want to do that. $nameField->wrapClass = 'InputfieldHidden'; //this shouldn’t work because of the $page business above. I guess it will //result in "() " because neither $pageid nor $template can have any //reasonable values. //moreover, you can’t use parentheses or spaces in page names, so they will //get stripped or converted to - anyway. remember this is the page name, not //the title. $nameField->value = "($pageid) $template"; //this is unnecessary because we have already put $event->return into the //variable $form. $titleField = $event->return; //this is great, but you should remove the above line and use $form instead. if(!$titleField->has('title')) return; //this is a great way to get the title field from the form! also a great way //to get rid of it. it will still allow you to put a value inside at this point. $titleField->title->collapsed = Inputfield::collapsedHidden; }); Now to do what you really want, you need to hide the fields you want to hide in this ProcessPageAdd::buildForm hook and use an additional hook to set the values. That second hook will have to run at some point when all the things you need to generate those values are known. Since you want to use the page id (there is no real reason to have the page id in the name that I can think of!), that point has to be AFTER the page has been saved. That’s fine, but if you contented yourself with just the template name + a number generated by PW, you could use the Javascript option I suggested above and obviate the second hook. It’s no biggie either way, so whatever. You could hook Pages::added, making your entire code look like this: $this->addHookAfter("ProcessPageAdd::buildForm", function(HookEvent $event) { $form = $event->return; $parentField = $form->getChildByName('parent_id'); $parent = pages()->get($parentField->value); if (!$parent->matches('template=idee')) return; //using the neater way to edit the field! $form->_pw_page_name->collapsed = Inputfield::collapsedHidden; $form->_pw_page_name->value = 'this is a temporary name nobody should ever see, just leave it'; $form->title->collapsed = Inputfield::collapsedHidden; //no default value for the title }); $this->addHookAfter('Pages::added', function(HookEvent $event) { //this time, we can get the page that has just been created! $page = $event->arguments(0); //same as above: only run under certain parents if (!$page->matches('parent.template=idee')) return; $page->setAndSave('name', "{$page->id}_{$page->template->name}"); });
    1 point
  3. Ok i think i fixed it now. $this->addHookAfter("ProcessPageAdd::buildForm", function(HookEvent $event) { $form = $event->return; $parentField = $form->getChildByName('parent_id'); $parent = pages()->get($parentField->value); if (!$parent->matches('template=dashboard_customer')) return; $pageid = $page->id; $template = basename($page->template->label,'.php'); $nameField = $form->getChildByName('_pw_page_name'); $nameField->wrapClass = 'InputfieldHidden'; $nameField->value = "($pageid) $template"; $titleField = $event->return; if(!$titleField->has('title')) return; $titleField->title->collapsed = Inputfield::collapsedHidden; });
    1 point
  4. OMG - I found the problem... I have changed the field name of the image and didn't change it in the template... ? Everything works fine now again! I wish you all a happy and peaceful Advent season! Cheers, Christian
    1 point
  5. Hi @Frank Schneider Have you enabled urlSegments in template settings for mitglied_edit page?
    1 point
  6. Fully agree on this.
    1 point
  7. Short URLs VS Flat URL Structure Does URL Length Affect SEO? https://www.searchenginejournal.com/does-url-length-affect-seo/425230/ Google: No Benefit to An Artificially Flat URL Structure https://www.searchenginejournal.com/google-no-benefit-to-an-artificially-flat-url-structure/400609/
    1 point
  8. @Robin S is a genius! ? Based on his posts in the github issue I did the following and finally got the bug fixed (it seems): For Server Side Resizing: Search for "$corrections = array(" in all your files. You should find 3 files: Replace those arrays with this one: $corrections = array( '1' => array(0, 0), '2' => array(0, 1), '3' => array(180, 0), '4' => array(0, 2), '5' => array(90, 1), '6' => array(90, 0), '7' => array(270, 1), '8' => array(270, 0) ); This did already fix my issue. Client Side: Replace PWImageResizer.js with this file created by @Robin S and delete the old minified version PWImageResizer.min.js to make sure that the new version is loaded: https://github.com/processwire/processwire-issues/files/4660217/PWImageResizer.zip Would be great to hear if that also fixed your issue @Mikael ? Thx again @Robin S for the great work!!
    1 point
  9. Ok got it. I had to access children of children. The $release is from another foreach loop where I'm getting the page's children and with the below code I'm getting the children of children with only one and lowest value from a float field. <?php foreach($release->children("limit=1, sort=pad_price") as $p) { ?> <?= $cart->renderPriceAndCurrency($p->pad_price) ?> <?php } ?>
    1 point
  10. @Macrura Thanks for pointing this out. I couldn't find a documentation, about toolbar items available within processwire. I tried all of the CKEditor fullpackage and all items are usable. Here a complete list: Source, Save,NewPage, Preview, Print, Templates Cut, Copy, Paste, PasteText, PasteFromWord, -, Undo, Redo Find, Replace, -, SelectAll, -, Scayt Form, Checkbox, Radio, TextField, Textarea, Select, Button, ImageButton, HiddenField Bold, Italic, Underline, Strike, Subscript, Superscript, -, RemoveFormat NumberedList, BulletedList, -, Outdent, Indent, -, Blockquote, CreateDiv, -, JustifyLeft, JustifyCenter, JustifyRight, JustifyBlock, -, BidiLtr, BidiRtl, Language Link, Unlink, Anchor Image, Flash, Table, HorizontalRule, Smiley, SpecialChar, PageBreak, Iframe Styles, Format, Font, FontSize TextColor, BGColor Maximize, ShowBlocks About
    1 point
  11. actually this is in the core, all you need to do is add these to your toolbar (you don't need to add any plugins): so where your first line would look like this out of the box: Format, Bold, Italic, -, RemoveFormat you can change it to be like this: Format, Bold, Italic, Underline, -, RemoveFormat, -, TextColor, BGColor
    1 point
  12. This option is not included in core. 4 steps to get this option: Download CK Editor Plugin from here: http://ckeditor.com/addon/colorbutton Place the plugin-folder in /site/modules/InputfieldCKEditor/plugins/colorbutton/ Enable Plugin in Fieldsettings of the TextareaField under the Input Tab -> Plugins (checkbox) Add 'TextColor' to the CKEditor Toolbar This procedure is similar to any other plugin you want to use. Edit: Thanks Macrura (next post)
    1 point
×
×
  • Create New...