Jump to content

bernhard

Members
  • Posts

    6,312
  • Joined

  • Last visited

  • Days Won

    318

Everything posted by bernhard

  1. No. The point about repeaters is to give you the ability to input repeatable content. The sort order in the backend can be but does not have to be the defining factor for the sort order in the frontend. You can either use the sort order of the backend or you can reverse it. Or you can sort by another property (like created timestamp). Or you can filter content etc etc... $page->your_repeater_field->each('title'); // sort order like in the backend $page->your_repeater_field->sort('-sort')->each('title'); // reverse sort order $page->your_repeater_field->sort('-created')->each('title'); // newest first
  2. You'd need to tell us the use case before. Why do you (need to?) upload 100s of images to one single image field??
  3. absolutely! maybe a PDF to download and then a quick and easy JPG-based book using uikit lightbox or https://github.com/codrops/BookBlock combined with https://www.cssscript.com/drag-move-mouse-wheel-zoom/ for zooming in... JPG would have the drawback (or benefit) that text could not be copied and links could not be clicked...
  4. Thx, wowBook looks nice. Not perfect, but maybe a good option for this project. What would make a solution "better" in your opinion?
  5. Maybe I could just split the PDF into single pages and use pdf.js in combination with uikit lightbox... that way I could have a zoom feature plus all pdf features (like copying text and google indexing). Sounds nice, what do you think?
  6. Yeah pdf.js was one of the suggestions for my client. I've done that here: https://www.autohaus-bendel.at/fahrzeuge/408486-suzuki-vitara-1-4-gl-ditc-hybrid-allgrip-flash/ It's nice, but something where you can flip through the pages is definitely nicer. Not sure... PDF is indexable by google I think. JPG/PNG would not be. Also PDF can be downloaded at once. Maybe I'd need both solutions then, a PDF do download (and for google) and a nice flip implementation to quickly open and browse the magazine (without downloading megabites of data just to view one page)...
  7. I was afraid to hear that. Same here ? I've also found that on my research, but I don't really like that solution. First it needs jQuery which I don't really want to have on my frontend. Second if I add the PDF as jpg images I guess I will run into troubles regarding readability. It seems it does not provide a zoom feature? Also if I do use a JPG/PNG approach I'd just use a uikit lightbox and need no external dependencies. Maybe the easiest solution would be to just implement a zoom feature for uikit lightbox?? I have an idea... ?
  8. I want to show some PDF files on one of my sites. I konw https://www.yumpu.com/de/publishing-software/free and it's nice, but I'd prefer a self-hosted solution where my client just uploads the PDF and my website embeds it as a flipbook automatically. Do you know any good and free libraries or know how one could build such a tool (maybe 3d.js??)? Thx
  9. Thx for sharing ? Just a FYI: TracyDebugger has a similar feature ?
  10. I wonder if PW should check the memory limit during install? Done: https://github.com/processwire/processwire-requests/issues/449
  11. Integrate plausible analytics or umami into your ProcessWire backend https://processwire.com/modules/rock-analytics/ https://github.com/baumrock/RockAnalytics Quickstart: Install the module Setup plausible analytics (either self hosted or paid cloud) Copy the tracking code into your site's markup Copy the share URL to your module's config Donations ??? About plausible analytics Plausible is a "simple and privacy-friendly Google Analytics alternative". It is open source and you can either self host it or buy one of their hosted services. A live demo of their dashboard and its features can be found here: https://plausible.io/plausible.io Tracking Snippet When you add a website to your plausible dashboard it will show you a tracking code that you can paste into your site that you want to track. This is what I use to make sure that we only track users on the live site (not on local development) and only logged in users: if(!$user->isLoggedin()) { $src = "https://plausible.verdino.com/js/plausible.js"; echo "<script defer data-domain='{$config->httpHost}' src='$src'></script>"; } Providing a dynamic domain is handy because during development you can add a second website to your dashboard and see if everything works without messing up data of your live site account. Example: We want to track the site "example.com", so we add this site to our plausible dashboard. Then we add the snippet with the dynamic domain attribute. On local development we have the host "example.com.ddev.site" so all visits will not show up in the plausible dashboard for example.com; Now we add another website to plausible with the domain "example.com.ddev.site" and voila - we will see our dev-websites' visitors in realtime. Backend Menu Item By default RockAnalytics will create a menu item at the top level of your backend menu, but you can move that page to any place you like. For example you could move the analytics page under the "setup" page at the top of the screenshot. You can also rename the page if you don't like the label "Analytics".
  12. That's an interesting topic and the reason why I built RockForms. I initially released it open source in 2018 (see forum post), but I've built a new version that is not public yet. The module tries to solve exactly the pain points that you mentioned @Jonathan Lahijani. It is a wrapper around Nette Forms which is a brilliant library for creating secure and powerful forms. It takes care of all the hard parts when dealing with user input (security, remembering filled fields etc) and it is the only library that I know that let's you write code ONCE and get both client-side and server-side validation rules. By including a small JS file you even get live validation / live feedback with custom error messages. In my opinion that is the best UX you can get. The drawback of such modules / approaches is always that it get's harder to control the markup of your forms. That's why I have put a lot of effort into making the forms as easily customisable as possible. This is an example that defines custom markup that places two fields into one single row using tailwindcss: $form->addSelect("salut", "Anrede", [ 'f' => 'Frau', 'm' => 'Herr', ]); $form->addText("degree", "Titel"); $form->addMarkup("<div class='md:grid grid-cols-2 md:space-x-6'>{salut}{degree}</div>"); Note that {salut} and {degree} get replaced by full field markup that holds all the necessary form magic (field error, live validation...). Also it works great with alpinejs and/or uikit because you can easily set custom attributes: $form->setHtmlAttribute("x-data", "{affiliate:false, azubi:false}"); ... $form->addCheckbox("affiliate", "Ich bin Anschlussmitglied") ->setHtmlAttribute("x-model", "affiliate"); You don't need JQuery on your frontend - you can use the tools you want. And you get forms that fit 100% to the rest of your site. ?
  13. Yes, that's quite easy and something that I need all the time: <?php // site/ready.php $wire->addHookAfter("Pages::saveReady", function(HookEvent $event) { $page = $event->arguments(0); // only rename pages with template 'yourtemplate' if($page->template != 'yourtemplate') return; // only execute the hook when the page is created // otherwise the page name would be regenerated on every save if($page->id) return; // create a unique random pagename // see the methods docs for all available options $page->name = $event->wire->pages->names->uniqueRandomPageName(); }); I recommend to add notes to the backend to make it obvious what's going on and where: <?php // site/ready.php $wire->addHookAfter("ProcessPageEdit::buildForm", function(HookEvent $event) { $form = $event->return; $field = $form->get('_pw_page_name'); $field->collapsed = Inputfield::collapsedNoLocked; $field->notes = "Random page name is set via hook in ready.php"; });
  14. I've hit the same problem. I can add a config inputfield of type "text", but when I change it to "page" the selected page is not saved: <?php namespace ProcessWire; /** * @author Bernhard Baumrock, 06.07.2022 * @license Licensed under MIT * @link https://www.baumrock.com */ class FieldtypePageTest extends Fieldtype { public static function getModuleInfo() { return [ 'title' => 'PageTest', 'version' => '1.0.0', 'icon' => 'link', 'requires' => [], ]; } public function init() { parent::init(); } /** FIELDTYPE METHODS */ /** * Return the fields required to configure an instance of FieldtypeText * * @param Field $field * @return InputfieldWrapper * */ public function ___getConfigInputfields(Field $field) { $inputfields = parent::___getConfigInputfields($field); // this does not save the value $inputfields->add([ // change type to text and it works 'type' => 'page', 'name' => 'sourcepage', 'label' => 'Source Page', 'icon' => 'sitemap', 'derefAsPage' => FieldtypePage::derefAsPageOrFalse, 'inputfield' => 'InputfieldPageListSelect', 'findPagesSelector' => 'id>0', 'labelFieldName' => 'title', 'value' => $field->get('sourcepage'), ]); // this field saves properly $inputfields->add([ 'type' => 'text', 'name' => 'myfieldname', 'value' => $field->get('myfieldname'), ]); return $inputfields; } /** * Sanitize value for storage * * @param Page $page * @param Field $field * @param string $value * @return string */ public function sanitizeValue(Page $page, Field $field, $value) { return $value; } /** HELPER METHODS */ } The field "myfieldname" saves correctly, but the page field does not. Any help would be highly appreciated ?
  15. I've checked that package and it is <300kB in size. I'd be ok to add that to RockMigrations if someone provides a PR. Otherwise I think I'll remove the YAML support from the module before I officiallly release the module to avoid confusion.
  16. Yes, this shows that it's related to Spyc. Seems that the library did not have any updates since 2019 so there'll likely be issues with PHP8.1 - if anybody knows better solutions please let me know.
  17. Hey @BlindPenguin I think I got it working now. Can you try the latest version? Note that I changed the syntax! <?php namespace ProcessWire; /** @var RockMigrations $rm */ $rm = $this->wire->modules->get('RockMigrations'); $rm->createField('test_field7', 'options', [ 'label' => 'Test Field', 'label1020' => 'Test Feld', 'type' => 'options', 'optionsLang' => [ 'default' => [ 1 => 'VERYLOW|Very Low', 2 => 'LOW|Low', 3 => 'MIDDLE|Middle', 4 => 'HIGH|High', 5 => 'VERYHIGH|Very High', ], 'de' => [ 1 => 'VERYLOW|Sehr niedrig', 2 => 'LOW|Niedrig', 3 => 'MIDDLE|Mittel', 4 => 'HIGH|Hoch', 5 => 'VERYHIGH|Sehr hoch', ], ], ]);
  18. Is anything missing for that to work from the PW side? Couldn't you just create such a docker compose file and share it with the community? https://mariadb.com/kb/en/setting-up-a-lamp-stack-with-docker-compose/
  19. The terms did not change and will not change, though there will not be any updates/fixes/support. I'll write you a PM regarding the new version of RockForms
  20. The module is not public. There's an older version lying around in the forum, but the new version does definitely have a better syntax and is easier to use. NetteForms does not have a datepicker by default so you'd have to implement that on your own or use an existing solution: https://www.google.com/search?q=nette+forms+datepicker&oq=nette+forms+datepicker&aqs=chrome..69i57j33i10i160l3.2471j0j7&sourceid=chrome&ie=UTF-8
  21. Do you save the page after changing its name?
  22. thx @szabesz Hi @Andy thx for your kind words! well... I like to do thinks in code rather than clicking around a GUI, because then I have all in GIT and can automatically deploy it to production. In addition to that I love how you can write form code once and get frontend and backend validation of your forms automatically. The next point is that I don't like the embed methods via Iframe and I never got used to the other output method - how is it called? Direct output? Another point is that I try to avoid hook hell as much as possible. Hooks are great, but I started to adopt concepts where things that belong together are in the same file or folder. That's why every form that I create for RockForms is one single PHP file, that defines all the necessary pieces (fields, after submit action like sending an email, markup for the frontend, error messages...). <?php namespace ProcessWire; /** @var RockForms $rockforms */ $form = $rockforms->form('newsletter', [ 'token' => false, // disable csrf for use with procache! ]); $form->setMarkup("field(email)", "<div class='sr-only'>{label}</div>{control}{errors}"); $form->getElementPrototype()->addClass('mb-12'); $form->addText("email", "E-Mail Adresse") ->setHtmlAttribute("class", "text-gray-dark w-full focus:border-violet focus:ring-violet") ->setHtmlAttribute("placeholder", "Ihre E-Mail Adresse") ->isRequired(); $form->addMarkup("<button type='submit' class='btn btn-sm btn-pink !px-12 mt-6'>Newsletter abonnieren</button>"); if($form->isSuccess()) { $values = $form->getValues(); if($form->once()) { /** @var RockMails $mails */ $mails = $this->wire('modules')->get('RockMails'); $mails->mail('newsletter') ->to('office@example.com') ->subject("New Newsletter Subscription") ->bodyHTML($form->dataTable()) ->send(); $this->log('sent mail'); } $form->success('<span style="color:black;">Thank you for your subscription</span>'); } return $form; This is an example for an easy newsletter subscription form. For me it is also better to code my own module because then I have a lot more freedom and can add extensions and new features while working on any project that uses the module. For example the $form->dataTable() is something I need very often (send form data via mail or show form data in the backend). I guess I'll release this as commercial module soon - if anybody reads this and is interested in a closed alpha write me a PM ?
  23. These errors indicate that you have an entry for these modules in your database, but the files on the disk for these modules do not exist. That can happen if you install a module and then just delete the module files without uninstalling the module first. In the backend's module section you should have a "missing" tab where you can delete the entries in the db which should prevent the warnings from showing up in the future.
  24. That's the correct syntax, because you do not set a ProcessWire $config property but a server locale setting.
×
×
  • Create New...