Jump to content

LMD

Members
  • Posts

    90
  • Joined

Everything posted by LMD

  1. Ok, I've got it to work! Upgrading to MySQL ver. 9.2.0 did not work, changing from MyISAM to InnoDB did not work, but switching from MySQL to MariaDB (ver. 11.7.2) did work. I do not know enough about the technicalities of databases to know why, but I suspect it is that indexing issue from the previously mentioned error message. Thanks again for the help, it's all working as you describe now.
  2. I tried a completely fresh install and get a database error -- so I now think it is not a problem with RockCommerce specifically, but with PW and MySQL in general. The error message is complaining about indexing the JSON 'data' column. I shall return here with either a "hurrah" or a "boo-hoo" at a later date! Thanks for the help. And you are right, I should learn DDEV, I've always been put-off being on a Widnows machine.
  3. Thanks for the help... I have encountered some technical issues. When I tried to "Enable Product Variations" in RockCommerce settings, I got this error when I tried to "Save": Modules: Failed to init module: RockCommerce - SQLSTATE[42000]: Syntax error or access violation: 3152 JSON column 'data' supports indexing only via generated columns on a specified JSON path. The error disappeared when I reloaded the module page and the box was checked. So I continued... I added "Shoe Size" and "Colour" variations in the "Shop" -> "Variations" tab. Added the rockcommerce_variations field to the product template. Went to my test product page and created a variation for Shoe Size, added the required sizes and prices. Then hit "Save" and got the following Exception errors: PagesEditor: Error saving field "Variation" — SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dotnpw.field_rockcommerce_variation' doesn't exist FieldtypeRockGrid: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dotnpw.field_rockcommerce_variation' doesn't exist Futhermore the selected variation and prices did not get saved. Sure enough, when I looked in the DB the field_rockcommerce_variation table does not exist. I notice in the modules there are three modules that have not been auto-enabled, and nowhere (I noticed) did it mentioned they are needed? FieldtypeReVariations InputfieldRcVariations InputfieldRcPricing FYI using Laragon: PHP ver. 8.3.15 MySQL: 8.0.30 (used MyISAM when I installed PW) Thanks.
  4. Hi Bernhard - I purchased RockCommerce a couple of days ago to test out. I have done the quick start tutorial in the docs and it went well. However, I need product variations, but the docs aren't ready yet! The variations I need are for specialist shoes (ballet dancers) and fairly complex - the prices also change depending on the shoe size! Colour Pink White ...etc Size 1 1.5 2 2.5 ... 12 Is there anything I can read/a demo anywhere to get me started? Thanks
  5. I can't test this right now, but it might be simpler to put your functions in a separate file (e.g '_funcs.php') and then in '_init.php' use: // in _init.php require_once '_funcs.php'; By using 'require_once', it shouldn't matter how many times '_init.php' gets called, the '_funcs.php' file will only be included once.
  6. You can configure VS Code to understand "*.module" files as PHP. Go to "Settings" and then "Text Editor > Files". Under "Associations" press "Add" button and add "*.module" (without the quotes) under Item/key and "php" under Value. Hit "Ok". Might need to restart VS Code for it to take effect. Also, you need a double-asterisk at the front of the comment to get the code hints (and also make sure the variable name is correct/matches!): /** @var TextformatterMarkdownExtra $md_formatter */ $md_formatter = $modules->get("TextformatterMarkdownExtra");
  7. You forgot to call the fieldname 'button' - you are echoing the repeater items (which uses the ID as toString output). Try this: <div class="caption-cta-wrapper uk-margin-medium-top"> <?php // 'buttons' is a repeater field, so '$btn' is a repeater item foreach($page->hero->buttons as $btn) { echo $btn->button; // <-- fieldname! } ?> </div>
  8. Hi @fruid At the moment it looks like you are grabbing all pages (with parent id = 1) and iterating through them individually to find the ones matching the required menu. With a small number of pages this may well be perfectly fine, but if there are hundreds/thousands of pages it's not very efficient. It would be better to just grab only the pages in the required menu - unfortunately you can't (currently?) do that with a PW selector, but you can use a MySQL query directly combined with a PW find selector -- check out the following thread:
  9. In this case, you really need to ensure the user has the correct country code, otherwise there is a scenario where they could login to somebody else's account by accident! How about pre-filling the field, but not making it invisible, so the user can see and check it is correct? Maybe with a little country flag icon?
  10. I'm on a mobile, so can't test this but you could try the following... Create a dummy SVG file with a placeholder icon and module name all aligned and styled properly. Give the placeholder icon and text span containing the changable module name unique IDs. I assume the real icons are also SVG (e.g. FontAwesome) and not an image? On page save (with PHP, I assume), open the dummy SVG and regex search-replace the icon (open the icon code too if necessary) and module name. Save new code as a new SVG file. That would be my stating point.
  11. Is the number part of the username unique to each user? If so, why complicate things with the region part at all? Especially if you only want the user to enter the number. I fear that by asking too much of the user (making sure their region matches), it will just lead to more tech support enquiries.
  12. This page in the docs helps, but basically inside a module you can use: $this->page; $this->wire('page'); // preferred in Wire-derived classes (i.e. modules) However, for the example you gave above (renderPageTitle()), it might be easier to create a new method for the $page class with a hook. For example: /** * NOTE: the module will need to be set to be 'autoload' => true in the Module Info */ class MyModule extends WireData implements Module, ConfigurableModule { /** * Run when PW is "ready" (like ready.php file) - so it's where you place you ready hooks. */ public function ready() { // Add a hook to define the "renderPageTitle" for the $page class. // Called in your templates with with $page->renderPageTitle() $this->addHook('Page::renderPageTitle', $this, 'renderPageTitleHook'); } /** * The hook code itself (could have been an enclosure on the hook if simple enough) */ public function renderPageTitleHook(HookEvent $event) { $page = $event->object; // the $page class *instance* calling the method $event->return = $page->title; } } Alternatively, this is a good case for using Custom Page Classes (look at the most recent 'site-blank' profile for an example).
  13. In the regular site profile you can find the function that controls this output in the file called '_uikit.php' in the templates folder. Find the function 'ukBlogPost()' and go to the line defining the variable '$date' (see here on Github) to change it. Currently it is looking for the date (modified) and falling back to the created date string 'date|createdStr' -- just remove the 'date|' bit and leave 'createdStr'. Be sure to check the other functions in that file for other places the date may be displayed.
  14. Ahh, yes, I was not taking into account 'Pages' vs 'Page' objects. Which is silly of me, because the clue is right there in the "$page = $event->arguments(0)" bit of the hook method! Thank you!
  15. I'm trying to use a conditional "saveReady" hook for repeater items inside a module, but for some reason it isn't firing (and yes, I am making sure to make changes to the repeater when testing!). It works when NOT using a conditional hook (and checking for the template inside the hook function itself), so it's not an issue with anything except the conditional part of the hook. // THIS WORKS public function ready() { $this->addHookAfter('Pages::saveReady', $this, 'myHook'); } public function myHook(HookEvent $event) { $page = $event->arguments(0); if ($page->template->name === 'repeater_gallery') { bd($page); // Tracy dump } } // THIS DOES NOT WORK! public function ready() { $this->addHookAfter('Pages(template=repeater_gallery)::saveReady', $this, 'myHook'); } public function myHook(HookEvent $event) { $page = $event->arguments(0); bd($page); // Tracy dump -- does not get dumped. Is the hook not fired? } I'm using the latest DEV version of ProcessWire (v3.0.222). Is this a bug, or is it me?
  16. Ahh, yes.... I've only been putting it on the local parent element where required, because the <body> is controlled by a different template. But if your entire site is HTMX powered that is absolutely the way to go.
  17. I'm developing a site using HTMX to swap images in a gallery (it uses 'picture' element and 'srcset' so I didn't want to load all the markup at once) alongside PW regions and it works great. I haven't really encountered any problems or gymnastics -- but maybe my use-case is simple enough? <?php namespace ProcessWire; $imgMarkup = ''; $thumbMarkup = ''; $imgNum = 0; /** Build the gallery fragment (the bit that changes via HTMX) before output */ if ($page->gallery && $page->gallery->count() > 0) { $imgNum = $input->get('img', 'int', 0); // get image index number from GET var (AJAX and no-JS) $galleryImg = $page->gallery->eq($imgNum); // get the image from index // The image markup (actually rendered from a custom page class) $imgMarkup = '<picture> <source type="image/webp" srcset="..."> <img src="..." width=".." height="..." alt="..." srcset="..." sizes="..."> </picture>'; // If it is a ajax (HTMX) request, just echo the image markup and stop PW processing tyhe rest of the template. if ($config->ajax) { echo $imgMarkup; return $this->halt(); } /* When doing HTMX ajax swap, the rest of this template won't be rendered */ // Build the clickable thumbnails that do the swapping (simplified) foreach ($page->gallery as $item) { $thumbMarkup .= '<li><a href="..." hx-get="..."><img src="..." width="..." height="..." alt="..."></a></li>'; } } ?> <!-- The markup regions --> <pw-region pw-id="imageViewer"> <div class="image-wrapper"> <figure class="image-main-wrapper" id="mainImg"> <?=$imgMarkup?> </figure> <div class="image-thumbs-wrapper"> <!-- where the HTMX magic happens -- note the additional hx-headers, which allows PW's $config->ajax to work --> <ul class="image-thumbs" hx-trigger="click" hx-target="#mainImg" hx-swap="innerHTML" hx-headers='{"X-Requested-With": "XMLHttpRequest"}' > <?=$thumbMarkup?> </ul> </div> </div> </pw-region> <pw-region pw-id="pageContent" class="content-left">....</pw-region> <pw-region id="sidebarContent">...</pw-region> It just works... no need to faff with cancelling prepend/append templates etc, just rember to add the extra hx-header (also, you can do it once on a parent element), you don't need to add it to every call. I haven't ever tried, so I'm not 100%, but there might be a way to automatically add the header to every HTMX call with a bit of javascript in the header/footer. I feel all the tools are probably already there, but if there is an even easier way, though, that would be great.
  18. Not a problem, this time, but an FYI and a solution in case anybody needs it. When using a Dynamic Options field as an images/files custom field, the 'page' value of 'arguments(0)' is not the page being edited, but instead it's a dummy page used for the 'field-fieldname' template. If the actual page is required for some logic (a need I had), then this poses an issue... but there is a solution! In your 'getSelectableOptions' hook, do the following: $wire->addHookAfter('FieldtypeDynamicOptions::getSelectableOptions', function(HookEvent $event) { $page = $event->arguments(0); // Page data (which will be wrong for our specific use case) $field = $event->arguments(1); // Field data // 'foo' is an images custom field if ($field->name === 'foo') { /* Get the page -- where we get page from will be different in the admin (edit) and frontend.*/ $page = $this->page; // the current page route (sufficient for the frontend) /* However, in the admin edit page (check the process) */ if ($page->process === 'ProcessPageEdit') { // Get the id of page being edited from $input and then use that to fetch the page $page = $this->pages->get($this->input->get('id', 'int')); } $options = []; // empty array to return if no valid page is found // If it is a valid id... continue as usual, using the $page var if ($page->id) { if ($page->template->name === 'gallery') { $options = ['foo' => "Foo", 'bar' => "Bar"]; } else { $options = ['lorem' => "Lorem", 'ipsum' => "Ipsum"]; } } $event->return = $options; } // ... other fields as required can use the $page from args }); No idea if there is a different way, but this method is fairly simple, besides, it's not going to be a common issue. Hope this helps somebody. Here's the Tracy dump of the custom field "page" for the curious: ProcessWire\DefaultPage id: 0 name: '' parent: '' status: 'corrupted' template: 'field-images' caption: '' foo: => '' data: array 'caption' => '' 'foo' => ''
  19. When generating a WebP image from the originally uploaded file (not as a result of using the 'size()' method), I see the following file error in the logs: unlink: Given filename is not a file or link: /site/assets/cache/WireTempDir/.PFM0.24368300T1680350648RozEvGgLCG8JdZGUwLM/0/cookies.960x0.png-tmp.png Note that the actual original filename is 'cookies.png' -- but the error message appears to show PW has attempted to use a (non-existant) variation. The simplified code I'm using in the template (it will eventually be a srcset, hence the small 'width' to large file): // Cut code fetching the $img itself echo '<img src="' . $img->webp->url . ' " width="300">'; The strange this is, that the correct WebP image *is* generated and subsequently served ('cookies.webp'), it just throws a hissy fit while doing it (once generated no error is shown). This error does not occur when generating WebP images from variations. Is this a known issue, should I submit an issue on Github?
  20. Update: SOLVED! Never mind, I had moved a bunch of hooks to admin.php, including the DynamicOptions hook, which is why it stopped working on the frontend. I have put the hook back in ready.php and works as expected. Of course that makes perfect sense in retrospect. [--- Snipped description of the problem, it was a wild goose chase! --]
  21. Well, this is embarassing, I did actually try it yesterday and it didn't work, but I tried again this morning and it works just fine now. I don't know what changed - maybe I forgot to save something before. Sorry about that!
  22. Thanks for this great module! I was wondering if it would be possible to add support for making it work with custom image/file fields templates? At the moment the option to enable it is crossed out in FieldtypeFile modeule settings (in PW 3.0.211 dev).
  23. [Note to moderators: this topic is no longer about ProcessWire specifically, could it moved to the Dev Talk forum?] @Commander_Gal I think the first thing you need to do here is work out your budget. How much money do you have to spend per month/year? Your budget will determine your hosting plan. You can always expand it later. Secondly, how much experience with web development do you have? Have you ever had a website before, specifically, have you got experience running a web server? That will determine what type of hosting plan you have. For a personal project, you might be better off with shared hosting where you do not have to manage the server yourself (whether physical or virtual/cloud) - it is also cheaper. As for developing the site, you will need some sort of local webserver to build the site on your computer (I use Laragon, free and fairly easy to use/learn) and I recommend a PHP-friendly IDE (Integrated Development Environment) to code with (I use Visual Studio Code, again free and open source). That is not an easy thing to set-up. I took a look at PeerTube (https://joinpeertube.org) and noted on their home page "PeerTube platforms you visit are built, managed and moderated by their owners" -- that means you have to build and maintain a server (although the FAQ does say it can be a virtual machine, see the FAQ: Should I have a big server to run PeerTube?), and you host the videos uploaded to your instance.
  24. Hi there, TL;DR: Start by building your own personal site to learn ProcessWire/PHP, while considering all the implications of becoming a content host/publisher. Which it sounds like you're planning on anyway. It's very exciting when you have an idea for a new project isn't it? A few years ago I had a webcomic I used to run on ProcessWire. (long since archived to a static site* that never updates) and it was a such a pleasure to build on that I had the same idea to set-up my own comic hosting site using ProcessWire as the engine. I even got as far as starting to develop modules for it. Ultimately, I abandoned the idea for the following reasons: Hosting costs money. Hosting images costs more money than text. Like... a lot more. The larger and higher-quality the image, the more it costs to host, and comics tend to need high quality images. You also mention videos - are these to be hosted too, or linked via YouTube (for example)? Ok, so you could use a third-party image hosting service, but then that too will cost money if your needs grow. Also, any site that hosts user content is going to need regular backups, which will also grow in size and require safe storage. Your users won't appreciate their hard work going *poof* in the night. Technical support. Any site that has users creating and uploading content will need 24hr (or near 24hr) technical support -- not just for site maintenence, but also user support. Security. You need to ensure user data is safe and secure. Now, out of the box ProcessWire is one of the most secure CMS out there, but you still need to ensure the database and user data is secure (remember those backups? They need to be stored securely). The exact details of the hoops you need to jump through and what laws you need to comply with vary depending on where the site is hosted. Responsibility. Like it or not, you will be a publisher. You will be responsible for the content put on your site. You will need a cast-iron acceptable use policy... run it by a lawyer! You will also need to enforce it, have a reporting system etc. And how will you deal with DMCA takedown notices? Acceptable content. When it comes to what is acceptable content, will it be child-safe only? If not, how will you ensure kids can't access it? Even if it is intended to be child-safe, what safeguarding features will there be to protect kids? I looked at the above list and decided "fudge it, I'm too old for this sh*t". You, however, may reach a different conclusion, or may have thought of everything already! There is one more issue that was less applicable to me: technical starting knowledge. When I had the idea, I was already a PHP programmer of several years (before ProcessWire, I hand-build a site to publish my comic), but I get the strong impression that you are not just new to ProcessWire, but new to PHP (maybe even programming? Forgive me if not) in general. Now, as Jan suggested, building a small site first is a great way to learn - my comic is how I learned a lot of my craft. I recommend you build a site for your own personal content while you learn, and it will give you time to consider all the other things in my List of Concerns above. We will be here to help as you learn. --- * Which was super-simple to do with ProcessWire too!
  25. Thanks, that page doesn't quite answer my question, although it leads to pages that might, so I have a lot of reading to do. My main concern is that it must be really easy for my client -- they are definitely not tech savvy, so if a process is remotely tricky (e.g., just setting up an account in the first place), it's just not going to work. They have used PayPal in the past and did not like it!
×
×
  • Create New...