Jump to content

Tyssen

Members
  • Posts

    323
  • Joined

  • Last visited

Everything posted by Tyssen

  1. This is how I did it: $mb = $modules->get('MarkupMenuBuilder'); $items = $mb->getMenuItems('Main', 2); foreach ($items as $item) : if ($item->isCurrent) : $currentID = $item->id; $parentID = $item->parentID; endif; endforeach; $subItems = $items->find("parentID=$parentID"); foreach ($subItems as $subItem) $output .= '<a href="'.$subItem->url.'">'.$subItem->title.'</a>';
  2. I haven't checked pages with output that the others use, but one page that uses the Srcset Image Textformatter should take something like <img src="image.jpg"> in a CKEditor field and transform it to: <img src="image.jpg" srcset="image_320.jpg 320w, image_480.jpg 480w"> based on settings you enter into the module for the size variants. The output is just the normal non-srcset version of the image.
  3. I have some text formatters applied to CKEditor fields – Profields Auto Links, YouTube video embed, and Srcset Image Textformatter. The modified output's not working with the Twig set up. Is there something else other than setting autoescape to false that needs to be added to done?
  4. If you've created a menu like this: Parent 1 - Child 1.1 - Child 1.2 Parent 2 - Child 2.1 - Child 2.2 and you're on page Child 1.1, is there a way to just get the siblings of the submenu, i.e. Child 1.1, Child 1.2? And every time you change to a page under a different parent, it shows only the child menu items?
  5. Ignore me, I'm an idiot. I had caching turned on for the template I was testing. 🥴 I have come across another problem though. I have a ProFields table field with a text and two checkbox fields. I'm looping through the rows like this: <tr> <th scope="row">{{ row.field_field }}</th> <td> {{ row.field_match }} </td> <td> {{ row.field_training }} </td> </tr> field_field renders OK, but with the checkbox fields in the template, I get "field_training|match does not exist or is not callable in this context". But if I add {{ page.field_status.first.field_training }} outside my loop, I get the correct output.
  6. Ah, I guess because responsive mode sends a different user agent. TBH, it's a config setting I'm not sure I've ever actually stopped and read properly. But good to know how to fix it. 👍
  7. Hi Moritz, I was following your Using Twig with ProcessWire article today to set up a site for using Twig and have come across a strange problem. When I first started, I quickly created some templates and added a few words in them to see if they were rendering correctly. Then I began working on the site properly. Everything was going fine until I tried to test a page in responsive view. Suddenly, everything I'd been adding to my twig templates had disappeared and I was being shown the small amount of dummy text I'd started with, like a cached version of the very first page rendered. I found that switching to responsive mode had logged me out of PW and it wasn't until I logged back in that everything I'd been working on displayed again. The being logged out when switching to responsive mode is weird enough, but a separate issue, (setting $config->sessionFingerprint to false fixes it) but do you know what might be preventing my pages displaying correctly unless I'm logged in?
  8. Does anyone else get this? Testing a page on the front end in either Chrome or Firefox and if I enable responsive view, I get logged out of the control panel. :?
  9. Apologies if this has been asked before (I searched but didn't find anything), but most of the pages of my site, I want the meta title format to be Page Name – Site Name. But for the home page, I want it to be Site Name – some text. I don't see a way to do that.
  10. This relates specifically to a problem I'm having with the Template Engine Twig module by Wanze, but I feel like it's probably a more general problem that could occur with any module installed with Composer. Feel free to move it though. The full error message I'm getting on both front and backend is If I move the vendor folder above webroot, the composer error goes away but when I try to access a page on the front end, I (unsurprisingly) get: I've tried adding {# FileCompiler=0 #} to the end of the only twig template I have at the moment (which just has plain text in it). But I'm getting the composer error on both front and back end so I wouldn't think that would help anyway. I've also tried composer dump-autoload. So why is the vendor folder getting copied to the FileCompiler folder? And is there anything I can do to stop that happening? Or stop the class name clashes?
  11. I'd like to be able to use both TextformatterImageInterceptor and Srcset Image Textformatter on the same CKEditor field. If I have Srcset Image Textformatter first in the list of formatters on the field, it adjusts the <img> tag as expected, but the markup from TextformatterImageInterceptor doesn't get output. If I have them the other way around, the markup for TextformatterImageInterceptor gets output, but Srcset Image Textformatter throws errors relating to the settings that you can turn off/on with checkboxes in the module's settings, generate HiDPI and LQPI images and width/height attributes. If I turn those three settings off the <img> tags get output but the src and srcset attributes are blank. Is this just a problem with these two modules not playing nicely together or can't you have two text formatters that alter image markup on the same field?
  12. @nbcommunication Great thanks. I wasn't sure whether there was going to be something straightforward like that or not. 👍
  13. @nbcommunication Yes, it's OK for me now. Another question though: you say that the module doesn't require OAuth for authentication but if I try and set up the module on my local version of the site, which isn't accessible outside my local network, I still get the same error. So at the moment, I only have an authorised account on the production version of the site (the same domain as I entered into the OAuth settings). How do I get my local version of the site authorised so I can work on template changes in my local environment?
  14. I'm getting the same error but mine says: "Could not add user account account_name".
  15. Yes, that was what I was after, thanks. 👍 I had been looking at getMenuItems before, but for whatever reason, it wasn't sinking in.
  16. #1. #1 and #2 are almost the same except that #2 also has a custom link to a PDF file included in it.
  17. If I have a menu like this: - Item 1 - Item 2 -- Item 2.1 -- Item 2.2 - Item 3 how would I output a menu just for the children of Item 2?
  18. @OLSA In my case, I have a base product which can have a variety of different add-ons added to it. So base price might be $50 and you might have 10 add-ons which are all different prices. So the final price could be $50 + add-on A + add-on B but it could be $50 + every permutation of 10 different numbers added to each other, e.g. A+B A+B+C A+C A+B+C+D B+C+D etc. For everyone else who has replied so far, thanks for your suggestions. I'm actually looking into using https://github.com/violet-php/streaming-json-encoder as it will avoid having to load the whole data set into memory, which is similar to what @LostKobrakai suggested. No, because in some cases, the add-ons are for subscription products with Stripe. If they were separate products, then each one would need to be a separate subscription which then gets messy to manage for the customer and client.
  19. And in case you're wondering, Snipcart does have different price modifier data-attributes that can be used which would avoid all of this, but… and this is why I'm still having to do it this way… you can only choose one option, e.g. if you buy a shirt it might come in S, M or L and the price might go up the bigger it gets. But you're only choosing one modifier. In my case I have a base product which can be ordered for 1, 3, 6 or 12 months (which changes the base price), but it can also have a range of optional add-ons added to it which also change the price.
  20. Ideally, yes, there would only be unique combinations. But it's not been set up to filter them out yet because it's not strictly necessary. The reason for that is a little hard to explain. This is for a site that uses Snipcart. The way Snipcart works, you click on a button which has data-attributes for price and ID (and other things) on it and it adds the item to the cart and then at the end of the process, by way of validation, Snipcart returns to your page to check that a button exists with the price and ID that you added to your order. You can either have hidden buttons in the page with the data-attributes that match the order, or you can instruct Snipcart to use a JSON file which contains all that info instead. This is why changing prices on the fly doesn't work, because the price that you've arrived at by selecting different combinations of options, has to exist somewhere that the Snipcart validator can access. So to answer another of your other questions, yes I do need to be able to present several thousand different combinations to the Snipcart validator, not a site visitor, otherwise the order won't validate.
  21. This isn't strictly a Processwire question, but it is being used on a PW site, so if anyone has any ideas about this question, I'd be most grateful.
  22. Thanks, that was it. 👍 parent.parent didn't work but I did a find on the template instead.
  23. I'm outputting the items in an ordered list so that's showing the count for me. The max number it displays is 50. I've temporarily disabled the site's prepend and append files so the only thing showing on the page now is the output from the selector I posted above. Are there any config settings either in config.php or in the admin which might restrict the number?
×
×
  • Create New...