alexm Posted April 24, 2022 Share Posted April 24, 2022 Hi again @kongondo, I've also got a little issue whereby attributes for sizes are as few as 1 or 2 characters for the sizes - e.g. S, M, L, XL, 2XL, 3XL The ajax search only kicks in when the query string length is longer than 3 characters. I've tried enabling "Use ajax/options pages" then adding the hook to init.php like so: $wire->addHook("/find-padloper_product_attributes_options/", function($e) { $q = $e->input->get("q", "text,selectorValue"); if(strlen($q) < 1) return []; $selector = "templates_id=62, include=hidden, title%=$q"; $fields = [ "id" => "value", "title" => "label" ]; return array_values($e->pages->findRaw($selector, $fields)); }); but unfortunately it doesn't retrieve the pages with 1 or 2 character titles. Is there anything I can do about this? I'm trying to tie the attribute option titles in directly with the way the supplier lists them. Any thoughts on this? Appreciate your time, thank you in advance ? Link to comment Share on other sites More sharing options...
alexm Posted April 24, 2022 Author Share Posted April 24, 2022 Sorted! I've updated the hook hookFindPadloperProductAttributesOptions in PadloperHooks.module. Obviously not ideal that I have updated it there, as it will get overwritten, but I can see in your notes that using site/init.php doesn't work. Link to comment Share on other sites More sharing options...
kongondo Posted April 25, 2022 Share Posted April 25, 2022 Hmm. I'll have to have a think about this. I might make this configurable. Ideally, although I see when it might come handy as per your use case, a 1-character limit should be avoided - to limit server hits, primarily. Link to comment Share on other sites More sharing options...
alexm Posted April 25, 2022 Author Share Posted April 25, 2022 Agreed, I did think that this might be rather resource hungry. But, so far so good. And like with my stupid amount of variants and products in general, that is with a TON of attribute options. The other conclusion I had was that people could alternatively add another field to that template, perhaps called shorthand/abbreviated for instance. And then use the long form name to search and have an alternative short form name for mapping or front end usage. 2 Link to comment Share on other sites More sharing options...
kongondo Posted April 26, 2022 Share Posted April 26, 2022 7 hours ago, alexm said: The other conclusion I had was that people could alternatively add another field to that template, perhaps called shorthand/abbreviated for instance. And then use the long form name to search and have an alternative short form name for mapping or front end usage. Yeah, good idea. It does create extra work for your editors though. Hopefully, they can live with that. 1 Link to comment Share on other sites More sharing options...
csaggo.com Posted April 26, 2022 Share Posted April 26, 2022 +1 for this solution (shorthand field), we ran into the same issue with S, M, L, XL and so on Link to comment Share on other sites More sharing options...
alexm Posted April 26, 2022 Author Share Posted April 26, 2022 @csaggo.com if you just want a short hand field, you can literally do as I suggested. Use the title field supplied as long version, then create a new field called shorthand attribute name and assign it to the padloped-attribute-option template. Otherwise, you can gamble on changing the hook as I have done and taking that extra server load. 1 Link to comment Share on other sites More sharing options...
csaggo.com Posted April 26, 2022 Share Posted April 26, 2022 @alexmoh yeah i thought you suggested making it part of padloper itself, but custom field on the template makes more sense as there will be all kinds of different cases/needs. 1 Link to comment Share on other sites More sharing options...
alexm Posted April 26, 2022 Author Share Posted April 26, 2022 @csaggo.com I'd rather @kongondo didn't make this a part of PadLoper as then it leaves this stuff open so specific user use cases. Go with that and bet that he won't add it as a feature as it wouldn't make sense ?? 1 Link to comment Share on other sites More sharing options...
kongondo Posted April 26, 2022 Share Posted April 26, 2022 Yes. A custom field is the way to go. Not only will it survive an upgrade, it also offers much more flexibility. Incidentally, you can add any custom field to different templates to suit extra needs. E.g., if you wanted your attributes or categories to have images, you could reuse padloper_images on their respective templates. Currently, the only exception is a repeater field on a product template. They don't play along nicely due to some JavaScript issues (on the part of Padloper). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now