Jump to content

sz-ligatur

Members
  • Posts

    70
  • Joined

  • Last visited

Everything posted by sz-ligatur

  1. Good morning @gebeer, that looks promising – so far I didn't make the step to use the findRaw() but I will – looks like a huge potential to get my search run better. Thank you so much for your detailed examples. I will definitely dive into that and try to use it further up in my data collecting process. Btw. its about 650 documents and 430 tags. For now I just tried your 1-liner… Result: 1:4! The nested if takes avg 0.28s, your version 0.07s – now found 423 matches takes 30s instead of 120s for building the cache file (on my slow local machine). Looks like a good start for today – thank you @gebeer!
  2. Hello @Jan Romero, thank you for the clarification. Very helpful. I could add the individual items to WireCache now. As far as the resultlist is concerned, there are unfortunately still a few things going on. The list consists of several sequential finds() and there is a tag list as an isotope filter-menu*, ... so I'm leaving the MarkUpCache continue to run for now. A very special thanks for your sidenote... that explains many a… I wasn't aware of what I was doing, and yes indeed I had problems with WireCache after hijacking it. *while trying to find the bottleneck(s) with profilerPro I found one exceptional hungry candidate, but that's another topic.
  3. Hello, I'm struggling with a query in search results that slow down the rendering way too much. So much I appreciate the processwire api, I may have done stupid things with it. I have a site-search for documents (pages). After retrieving the matches, I query for the used tags at each page to render a tag-filter menu (isotope.js). In addition there is a counter on each tag label to show the usage of this tag by documents in the current result list. Thats my code… //$matches : found pages //$tags : collection of all tags used by $matches (a tag is a page) //$page->tax_tag : is page reference field at document pages, multiple select foreach ($tags as $tag) { $usage = 0; foreach ($matches as $doc) { if ($doc->tax_tag->has("id={$tag}")) $usage++; } $label = "{$tag->get('title')} {$usage}"; … } I guess that's award-worthy for producing as many unnecessary database hits as possible ... 😇 What do you think is the right way to get this data out of the database? Is anybody out there with a blazing sql-query to get all that tag-info in one hit?
  4. Hello @ryan, maybe you can give me a short hint if it is in principle not possible to have subcaches in a cache call? In the meantime I tried my luck with namespaced caches - without success - same result as described above. Thank you!
  5. Thank you @bernhard! I can reproduce this behaviour in three of my instances (all are using your awesome modules) – but they all share some boilerplate code of mine… so I won't exclude some mistake on my side. One fresh install with no custom additions nor using rf or rm has no issues so far. To my excuse, I do the first steps with your modules and custom PageClasses and latte … for me a lot of new stuff to learn – so no stone is left unturned… and maybe i messed up something. I'll keep a look at it and report back here, if I find anything causing this… hopefully not too embarrassing at the end 🤭.
  6. Hi @bernhard, thank you for replying… echo $page->test_options->title… in ready.php works as expected in _main.php it gets replaced by page title field, same in main render file latteRenderer.php or any section.latte template file a bd($page->test_options) looks good a bd($page->test_options->title) shows the page title instead a tracy console call echoes correct $page->test_options->title
  7. Hi @bernhard, I'm not 100% sure if it's correct to assign it to RockFrontend – today I found a strange one: I'm using a field FieldtypeOptions v0.0.2 with value and title as entries. It's config is radios = only single value. I'm used to call it as noted in the api example: // Ausgabe einer einzelnen Auswahl: echo '<h2>' . $page->test_options->title . '</h2>'; // Ausgabe mehrerer Auswahlen: foreach($page->test_options as $item) { echo '<li>' . $item->title . '</li>'; } Actually it's output is different in context with RockFrontend and its renderLayout() function. One has to use the ->first() call to get the title, otherwise the page-title gets rendered instead. This is the case in any template file, if it's a section.latte or main.php … same thing - please see attached screenshot. Any ideas what's going on? It's not a big thing, but it took me some time to figure it out and maybe worth fixing it with regard to compatibility. The field settings: 'test_options' => [ 'label' => 'test-options', 'flags' => 0, 'type' => 'FieldtypeOptions', 'inputfieldClass' => 'InputfieldRadios', 'optionsLang' => [ 'default' => [ 1 => 'a|ONE', 2 => 'b|TWO', 3 => 'c|THREE', ], ], ] 2023-01-12_18-28-41.pdf
  8. Hi there, I've optimized a search for items with MarkUpCache for all predefined searches (e.g. like a category) – that did work well so far using code [A] in my search template file. Today I tried to not only cache the list in its whole markup, but in addition each item in its separate cache-file. [A] and [B] On first load, it leads to an error: You must attempt to retrieve a cache first, before you can save it. (in /wire/modules/Markup/MarkupCache.module line 120) - I can see the single items cache files are generated (item-####), but the cache dir results-for-#### is empty Reloading the (search)page subsequently runs without error, but still no cache file for the list in results-for-#### Where is my mistake? I'm stuck – would be pleased about a tip. // [A] --------------- //@search tpl file.php $cache = wire("modules")->get("MarkupCache"); if (!$data = $cache->get("results-for-###", 3600)) { $data = renderResultList($foundpages); $cache->save($data); } //using $data for output echo $data; // [B] --------------- //@_func.php //render a result list of items function renderResultList($items) { $out = ''; // cycle through all the items foreach ($items as $item) { $out .= renderResultListItem($item); } return $out; } //render a single item function renderResultListItem($item) { $cache = wire("modules")->get("MarkupCache"); $cachefile = "item-{$item->id}"; if (!$data = $cache->get($cachefile, 3600)) { $data = $item->title; //…add more markup and data $cache->save($data); } return $data; }
  9. Hi Adrian, I tried to get it running – without success. I guess some things have changed in the module requirements since 2015… e.g. I tried autoload = true, but no changes. As I put a bd() in the two functions I've got no output, so they aren't called at all. It would be a great help as a startingpoint for some inheritance needs - your approach to make it work in Admin-views is quite promising. Thank you in advance. Sebastian
  10. I just recognized that all my image-field-templates with custom fields (e.g. caption, location , …) get (re)populated with the field "title" as it is set as global. How do you handle that? Just keep the field and set it to not required and hide it in edit-screens feels a bit strange. I think keep title a global field is a good idea – how do you handle this in combination with the image-field-templates? Thanks for any hints.
  11. Hello @Gadgetto, first of all my big thanks for your work on this useful module. The first steps were a pleasure, but now questions of detail arise here and there. 1) An error message concerns the function [Update order] in the backend - if fopen() is not active here, cURL is used for PUT. The following error complains about RAW Data in this context: "Raw data option with CURL not supported for PUT". phpinfo: cURL is enabled in version 7.64.0, PHP 7.4, processwire 3.0.165 I was able to work around the error by setting allow_url_fopen to on, but wonder why the error occurs when using cURL - does this need a fix? As Ryan notes [post], you can expect fopen() to be disabled more often on hosting servers in the future. 2) I'm using the "deferred payments" option and it would be helpful to be able to set the payment status in the SnipWire admin. Is there a good reason why you did not implement this feature? e.g. "Mark as paid", (or the whole set of possible values: Paid, Deferred, PaidDeferred, ChargedBack, Refunded, Paidout, Failed, Pending, Expired, Cancelled, Open, Authorized). 3) SnipCart sends the webhook order.notification.created on various events - but on SnipWire side it is ignored/not registered. So SnipCart receives a 400 and reports an error. I guess this log-message matching was not a top priority, but for the user it leads to uncertainty if the log data in SnipWire is not completely the same as in SnipCart. Especially since the "Mark as Paid" feature is not available in SnipCart - the timestamp for setting this flag is well worth logging in the notifications section for the store owner I think. I would appreciate your feedback - and of course I'm also interested in what the further plans are on your side for the module (in terms of feature extension or also support for SnipCart v3 etc.). Thanks again! Sebastian
  12. Hello Ryan, thank you for your instant reply. I'm sorry to admit that I don't fully understand the context - but I'll reach out to @Gadgetto to see how far this might mean a bug fix for snipWire. Its a function in SnipWire orders admin where I've got this error.
  13. In connection with SnipWire I had problems today with API calls that should be executed as put. The function [Update order] caused an error: "Raw data option with CURL not supported for PUT". cURL is enabled on the server in version 7.64.0, PHP 7.4 After finding the explanation below, I enabled allow_url_fopen in the php settings - so the error disappeared, everything seems to work now. I am now confused because I read this as cURL not working correctly – as it is used as a fallback in WireHttp. Is that so? Could someone with more insight enlighten me here? Should I be happy that it's working with fopen() and forget about the cURL error? Thanks!
  14. Hi dotnetic, I try to use your /processwire-language-pack-helper setup. I've got it running locally so far, but whenever I try to edit a language file I get the error: ProcessWire: ProcessLanguageTranslator: Unable to load textdomain Any ideas whats wrong? Another question regarding translations and suggestions for edits: in case of changes for existing terms – is it intended to first discuss any change here or should I make my PR in any case and it's up to you to accept or deny it? (for example I would suggest to replace "Umdrehen" with "Spiegeln" at the image action select - like its used to be called in all image-editors). Thank you!
  15. btw at https://processwire.com/modules/german/ the link for Download is broken now (https://github.com/jmartsch/pw-lang-de/archive/master.zip) (I guess ist should read /main.zip)?
  16. I'm not sure if that fit to your needs - I did that before in a template file, for a page that renders different output depending on URL segments: //the custom url $itemurl = "{$page->httpUrl}/{$slug}"; //alter seomaestros canonical url $page->seo->meta->canonicalUrl = $itemurl; // set custom og:url $wire->addHookAfter('SeoMaestro::renderMetatags', function (HookEvent $event) use($itemurl) { $tags = $event->arguments(0); $group = $event->arguments(1); if ($group === 'opengraph') { $tags['url'] = '<meta property="og:url" content="'.$itemurl.'">'; $event->return = $tags; } });
  17. …ah… thank you adrian! I rember seeing that before. The whole change from v0.2.0 to v0.3.0 is kind of nebulous for me… I should read about namespacing I guess. And it works! I namespaced all my hanna codes now, changed all wire('…') to $…-> and prefixed my custom function calls as you mentioned.
  18. Ah, I forgot to mention it, I tried already – adding <?php Namespace Processwire; doesn't change anything…
  19. I have trouble with latest update v0.3.0 – my hanna code stops working. In v0.2.0 I could use #1: wire("pages")->get($someid) – in v0.3.0 it throws error "Call to undefined function wire()". It's easily fixed by calling $pages->get($someid) instead - but I wonder why it's now the opposite as it was in v0.2.0 where I couldn't use $pages? #2: Inside the hanna code I call custom functions defined in _func.php (included @ready.php – I once moved the include from site/_init.php to ready.php to be able to use the shared functions in hanna code). That worked with v0.2.0, now in v0.3.0 I receive the same error as above "Call to undefined function myFunction()"s I guess I've got something basically wrong here… I have no clue how to get my custom functions work inside hanna code. Anybody can shed a light … ? ProcessWire: 3.0.165 PHP: 7.4.11
  20. Hello kixe, I guess it's a good idea that the pph-module is working silently in the background for non-super-users. And your examples are good to know and helpful. Thank you for your instant reply!
  21. Hello, I have a need, that the pagepath-history module should be accessible for a certain editor role (the output like under "settings"-tab › " What other URLs redirect to this page?" @page-edit). Is there a way to achieve this for core modules? E.g. add permissions for a module via hooks?
  22. Hi Robin - thank you for your improvement on that. I guess there is a typo in CustomInputfieldDependencies.module @Line 52, the comma breaks the installation… $this->hideInputfield($inputfield, $field,);
  23. After changing a table field to paginated (limit = 30) I can't figure out the right tags to display the total in admin list label. My current template settings for fields to display in admin lists looked like this: Termine: {schedule.count} – but this now displays only the count of page #1. Is there an equivalent tag for getTotal() in the field options? I tried {schedule.total}, {schedule.gettotal} … with no success. Can anybody point me in the right direction?
  24. @Wanze – congratulations for version 1.0.0 and a big thank you! @adrian: i've got it working now to correctly display the og:image in admin view – below the hook with inheritance mode as follows: if page og:image is empty, travel up tree until there is one at closest parent, use this. If no og:image found until home use default og:image from settings-page (a special page for sitewide settings). should go @ready.php /** * In addition to module SeoMaestro * if page has no og:image set, inherit from closest parent with given og:image * if no og:image is set in branch until home -> fallback to default og:image @settings-page */ $this->addHookAfter('SeoMaestro::renderSeoDataValue', function (HookEvent $event) { $group = $event->arguments(0); $name = $event->arguments(1); $value = $event->arguments(2); $isAdmin = ($this->page->rootParent->id == 2); if ($isAdmin) { $page = wire('pages')->get(wire('input')->get->id); } else { $page = $event->wire('page'); } $field = "og_image"; // used field for og:image // @config: one element or NULL if empty // no default output if empty $configpage = "1049"; // holding site-wide default og:image (og_image here set as required) if ($group === 'opengraph' && $name === 'image') { bd('og image is: '.$value); bd('page is: '.$page->id); // do nothing if page has og:image if ($value !== "") return; $sitedefaultimage = wire('pages')->get($configpage)->getFormatted('og_image'); //scenario 1: fetch default image assigned in field-settings (get formatted) // config field settings @og_image accordingly, what page to use if empty //scenario 2: inherit from next upper parent-page in tree with assigned image // @config @og_image: no setting for default value $selector = "og_image.count>'0'"; $option = $page->parent($selector); if ($option->id) { $value = $option->getFormatted($field); $src = $option->title; } else { $value = $sitedefaultimage; $src = "site-settings"; } $value = $value->httpUrl; bd("og:image inherited from: {$src}\n{$value}"); $event->return = $value; } }); I corrected $value = $value->url; to $value = $value->httpUrl;
  25. Hi adrian, I had a similar situation, and found an editor friendly solution using hooks: https://github.com/wanze/SeoMaestro/issues/8#issuecomment-486658463 Maybe that's a starting point?
×
×
  • Create New...