Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/22/2023 in all areas

  1. Using RockMigration's MagicPages feature: <?php public function editFormContent($form) { $form->add([ 'type' => 'markup', 'label' => 'Published at', 'value' => date("Y-m-d H:i:s", $this->published), ]); } No additional fields needed as @Jan Romero said ?
    3 points
  2. Thanks for all of your comments and suggestions. I renamed the module to PromptChatGPT (thank you @gornycreative for the input!). The renamed repo can be found here: https://github.com/robertweiss/PromptChatGPT Additionally, I have included the composer vendor folder by default, which seems to be a better and easier way to distribute modules. Thanks to @wbmnfktr for bringing this to my attention. Regarding the curl/ssl errors, as you have already deduced, these seem to be linked to the external dependency https://github.com/orhanerday/open-ai. Therefore, if the issues you mentioned persist, we should consider creating a new Github issue there. For easier debugging, I have added a ›test settings‹ option to to verify if ChatGPT responds correctly. I have also included a new option to select templates that should include the dropdown option.
    3 points
  3. Perhaps obvious, but do not use float for money. It will result in rounding errors. Also, regarding allocations (if you go this way), consider early if you need more than one per payment. E.g. if you need to allocate payment per invoice/order row, or allocate overpayment separately, etc. And also give some thought to how you'll handle returns/rebates etc. (In my experience two-way sync is rarely necessary, since PW makes querying data easy anyway. But you will likely need some hooks to keep things like order payment status in line with payments.) I recently built a system that handles event registrations and product sales, and my approach was basically "approach 3". One question is if you need to also handle accounting reports, and at what level. Honestly this is all relatively simple until debit/credit entries, cost centres, accounts, etc. get into the picture. In my case I do need to handle that, so each order/allocation logs a separate accounting row, which I later use to produce a sensible report. Including actual time of each event, which is super important here.
    3 points
  4. @joshua Wow, you're faster than light ? Thank you ? https://github.com/webworkerJoshua/privacywire/releases/tag/1.1.2 Tested this on one of my sites and it works like a charm.
    3 points
  5. I couldn’t resist the hype and created a simple module using the ChatGPT API to process field values. You can find it on GitHub here: https://github.com/robertweiss/ProcessChatGPT ProcessChatGPT is triggered upon saving, if you select it in the save dropdown. It processes the value of a page field, which can be set in the module config, using ChatGPT. The processed value can be saved back to the same field or to another field on the same page, which can also be set in the module configuration. You can add commands to the value that will be prefixed to the source field content. This way, you can give ChatGPT hints on what to do with the text. For example, you could add ›Write a summary with a maximum of 400 characters of the following text:‹. One of my clients is already using the module to summarise announcement texts for upcoming music events on their website (Let’s face it, nobody reads them anyway ?). If anyone finds it useful, I would be happy to submit it to the official module list.
    2 points
  6. Okay, I got a proper answer once I switched to an account with credits. Awesome. { "request": { "model": "gpt-3.5-turbo", "messages": [ { "role": "user", "content": "This is a test for ChatGPT. Do you hear me?" } ] }, "response": { "id": "chatcmpl-...", "object": "chat.completion", "created": 1679504670, "model": "gpt-3.5-turbo-0301", "usage": { "prompt_tokens": 21, "completion_tokens": 18, "total_tokens": 39 }, "choices": [ { "message": { "role": "assistant", "content": "\n\nYes, I can hear you loud and clear! How can I assist you today?" }, "finish_reason": "stop", "index": 0 } ] } }
    2 points
  7. I imagine this may also be achieved without an additional database field using FieldtypeRuntimeMarkup: https://processwire.com/modules/fieldtype-runtime-markup/
    2 points
  8. The "published" hook is in the Pages class. So it should look something like this: $wire->addHookBefore('Pages::published', function($event){ $page = $event->arguments(0); if($page->template->name !== 'templateName') return; $this->message("the Hook has been called"); if($page->hasField("myDateField")) { $newDate = date("d.m.Y"); // Need to call "save" explicitely after publishing since saving is already done by then. // Wrapped it all in a single call, not changing modified user and timestamp again $page->setAndSave('myDateField', $newDate, ['quiet' => true]); } }); You could consider hooking Pages::publishReady instead and set your myDateField there, that would save you the second write to the database.
    2 points
  9. Use decimal, already in the core, see (FieldtypeDecimal uses InputfieldFloat): https://github.com/processwire/processwire-requests/issues/126 https://weekly.pw/issue/367/ "Float and integer fields are now considered compatible with the newly added decimal field, making it possible to convert these from one type to another." If you feel like applying custom formatting in the admin, see :
    2 points
  10. You can view the path history when the page is open in Page Edit, on the Settings tab: And from the API:
    2 points
  11. WebP to JPG Converts WebP images to JPG format on upload. This allows the converted image to be used in ProcessWire image fields, seeing as WebP is not supported as a source image format. Config You can set the quality (0 – 100) to be used for the JPG conversion in the module config. Usage You must set your image fields to allow the webp file extension, otherwise the upload of WebP images will be blocked before this module has a chance to convert the images to JPG format. https://github.com/Toutouwai/WebpToJpg https://processwire.com/modules/webp-to-jpg/
    1 point
  12. thank you @bernhard god, i still didn't find the time, but i WILL check it out in depth soon!
    1 point
  13. Ok... now we are talking! Adding billing details is necessary and creating a new API key afterwards probably as well. Did both and everything is up and running. Just did a small test and generated a full article just by giving a topic and a predefined action in the settings. Love it! Additional note: just switched back to my primary account, created a new API key there and it works there as well.
    1 point
  14. I think I should add some infos about generating a working API key in the readme ?
    1 point
  15. Ok, I created a new account at Open AI and generated a test API key, then I got the same error message as you. After adding a payment method, still no luck. But then I generated a new key AFTER adding the payment method, and now it works. Could you check if that works for you too?
    1 point
  16. I meant I got this result, not the developer's result..
    1 point
  17. I got that as well, though my credits were under a different account.
    1 point
  18. Hmm, this is weird. Does the error message already show up on the module config page or while saving a ›real‹ page and choosing ›Save + send to ChatGPT‹? For reference, the attached screenshot shows my feedback which works without errors.
    1 point
  19. For reference: https://processwire.com/docs/modules/types/
    1 point
  20. Another thought, you may want to record invoices separately from orders, to deal with unsatisfied or partially satisfied orders. Alternatively this might be handled by status fields on order lines. At the risk of repeating myself, getting the business specification right is paramount. PS I absolutely agree with @teppo regarding decimal fields. A slip on my part.
    1 point
  21. BTW, on the frontend I use this https://github.com/brick/money which works well. It is a bit verbose to do math like that, but worth the hassle.
    1 point
  22. It seems to be working here. If the code is going to be executed when the user is other than a superuser then you would need check_access=0 in the selector because the admin template is restricted.
    1 point
  23. The other thing you should play with is the Request Logger panel - lots of useful info collected by it.
    1 point
  24. Just thinking loud: Maybe it's enough to have some links to the related blog post in the docs. Sometimes I'm missing some code examples, so I'm searching through the blog and almost every feature is well documented and explained there, too.
    1 point
  25. Another reason for doing some deep thinking about the entity model before choosing. If payments can only ever belong to an order (and only one order) then they should be children of the order otherwise they risk being orphans. If payments can cover more than one order, then they should stand alone, but you need to do serious thinking about how they are allocated to each order if the amounts don’t match exactly. This might be achieved via an “allocation” field (float or decimal) in the order and the payment. And/or you might need to split orders down into order lines. An accurate understanding of the business model is required. Plus how it might evolve. Then do the entity modelling. Lastly decide how to implement in PW. And don’t forget that @Robin S‘s excellent ConnectFields module is just the biz for maintaining many-many relationships (e.g. between the two allocation fields referred to above).
    1 point
  26. ? How to provide solutions to the community for free forever working on ProcessWire ? ? Apply to the following job, do physical activity to prevent hypertension and improve mental health ?
    1 point
  27. Nice. Does the module offer a UI under the admin tree? I'm asking because there are naming conventions for PW modules. And the prefix "Process" is usually reserved for modules that have a page associated under the admin tree. Like ProcessPageLister etc. You might want to consider renaming your module before submitting it to the directory.
    1 point
  28. Just read the thread, and posting an idea to give future readers a solution I used on a setup in the past. You can mitigate this "existing issue on every frameworks" by automating the whole things by writing a dedicated script which will change the admin url to a random generated string once called (could be a SHA hash, or whatever). Then you create a scheduled task that is calling this script with delay you want. When the script is called, it change the admin url to the new generated random string and make a call to a webhook, which on my case, was known by a self-made Telegram bot. When I was in need to log-in, I asked the bot on Telegram the current admin url ?
    1 point
  29. That's how it should be. Have you called $image->removeVariations() in between or added "forceNew" => true to your $options when calling $image->size(), to make sure the thumbnail is created from scratch?
    1 point
  30. Behind the scenes entries in a PageTable field are just regular pages in a regular PageArray. Lets say you have a field "pagetable" and it is configured to use template "blog-post" for items. You can create a new page with new items in the pagetable field like this: // create page that holds pagetable items $p = new Page(); $p->template = 'basic-page'; $p->parent = '/foo/'; $p->title = "Bar"; $p->save(); // get parent id for pagetable items from field config $parentID = $p->getField('pagetable')->parent_id; // create item page for field pagetable $item = new Page(); $item->template = 'blog-post'; $item->parent = $parentID; $item->title = "Item Foo"; $item->save(); // add item page to pagetable field $p->pagetable->add($item); $p->save('pagetable'); Since the value of $p->pagetable is a PageArray, you can find and manipulate the pagetable items with methods from Pages, PageArray and WireArray. To remove a specific item: $item = $p->pagetable->get('title="Item Foo"'); $p->of(false); $p->pagetable->remove($item); $p->save('pagetable'); You can also use WireArray manipulation methods insertBefore(), insertAfter(), append(), prepend() to add items in a specific order.
    1 point
  31. I fixed the PHP 8 issues and also the problem mentioned in my previous post. See my pull request https://github.com/BlowbackDesign/EmailObfuscation/pull/15 for a solution. If someone has the opportunity please test and report back if there are issues. Actually, it should be a drop-in replacement. @Roope please consider my PR after testing.
    1 point
  32. And, for me, this is totally insane: open playground (need to be logged) and copy/paste the following (or "make your own wish"). This is the mind blowing response that appeared to me (except for a little error in the "files" selector): // find all pages with "foo" template, only with parent "FOO" and "bar" greater than January the first, 2021 and having a .jpg or .pdf File $pages = $pages->find("template=foo, parent=FOO, bar>='2021-01-01', files.ext=jpg|pdf"); // echo a bootstrap responsive table with id linked to admin edit echo '<table class="table table-responsive table-striped">'; echo '<thead>'; echo ' <tr>'; echo ' <th>ID</th>'; echo ' <th>Title</th>'; echo ' <th>Bar</th>'; echo ' <th>Files</th>'; echo ' </tr>'; echo '</thead>'; echo '<tbody>'; // for each page foreach($pages as $page) { echo '<tr>'; // if editable, echo link to admin edit if($page->editable()) { echo '<td><a href="'.$page->editUrl().'">'.$page->id.'</a></td>'; } else { echo '<td>'.$page->id.'</td>'; } echo '<td>'.$page->title.'</td>'; echo '<td>'.$page->bar.'</td>'; echo '<td>'; // for each file foreach($page->files as $file) { echo '<a href="'.$file->url.'">'.$file->name.'</a><br>'; } echo '</td>'; echo '</tr>'; } echo '</tbody>'; echo '</table>'; speachless... N.B. Performed in a second moment, the code is added with: $files = $page->files; foreach($files as $file) { if($file->ext == "jpg" || $file->ext == "pdf") { echo '<a href="' . $file->url . '">' . $file->name . '</a>'; }
    1 point
×
×
  • Create New...