-
Posts
327 -
Joined
-
Last visited
-
Days Won
5
Everything posted by BrendonKoz
-
Neat! I like the readability score - it provides some useful context back to the authors. I was originally looking to see if it'd be possible to integrate the hemingwayapp(.com) interface as a field for similar reasons, but gave up. I instead just created a "Estimated Reading Time" field for site visitors as a feel-good (for me) feature. (I'll share it in case it's useful. The $page->reading_time is a hidden integer field in the template.) Multilingual sites could use the referenced source study to define times based on available data. <?php // ready.php // Blog/News Post Page - set reading time $wire->addHookBefore('Pages::saveReady(template=news-post)', function(HookEvent $event) { // Get values of arguments sent to hook (and optionally modify them) $page = $event->arguments(0); // Get the word count of the summary and body fields (combined) $summary_word_count = count(wire('sanitizer')->wordsArray(strip_tags($page->summary_textarea))); $article_word_count = count(wire('sanitizer')->wordsArray(strip_tags($page->rte))); // Set the value for the reading time field (number) based on word count // To provide a range, a text value would have to be returned (and stored), but is possible by calculating cpm, // wpm_top, wpm_bot and determining variance // Source Study: https://iovs.arvojournals.org/article.aspx?articleid=2166061 $cpm = 987; // average characters per minute, for English $wpm_bot = 161; // English values for reading speeds $wpm_top = 228; $wpm_ave = ceil(($wpm_bot + $wpm_top) / 2); $page->reading_time = ceil(($summary_word_count + $article_word_count) / $wpm_ave); // Populate back arguments (assuming they've been modified) $event->arguments(0, $page); }); As for your actual question... I haven't done this myself, but looking at the module and the field's settings, I believe you need to: Edit the settings of the "InputfieldTinyMCE" module. Look for the (image below) External Plugin files section, expand it if necessary, and it'll show you where to place your necessary file(s) for your additional plugins. Once your additional plugin(s) have been added properly to the InputfieldTinyMCE module's settings correctly, I do believe you'd then need to go to your TinyMCE field(s) that you want to take advantage of the plugin(s), and add/enable them. To do so, edit your field(s), go to the Input tab, and configure the necessary section(s) (I would assume the "External plugins to enable" would be the first to change) - my example image is blank only because I haven't added any plugins to my system. InputfieldTinyMCE module config: TinyMCE field Input tab setting:
-
Unrelated question to PW - it's a problem with Twitter
BrendonKoz replied to Leftfield's topic in Pub
In a long thread of similar issues, it's often blamed on Twitter's crawler failing to load for some reason, and the cache getting corrupted. It may take a few days to clear. It (your site) worked for me today, multiple times. Ignore the grammarly icon overlay. ? -
Unrelated question to PW - it's a problem with Twitter
BrendonKoz replied to Leftfield's topic in Pub
I just ran your home page's minified HTML source through a code beautifier so I could read it a bit better, removed all IMG elements, CSS link and JS references, and uploaded it to a subdomain of our hosted website. I tested linking to the "test.html" file via Twitter and it did not unfurl to create a card. I then noticed that you're declaring both Facebook Graph and Twitter Card meta tags. I have not done that; I've used Facebook Graph meta tags, and only added the Twitter Card meta tags that don't also exist under Facebook Graph, so I removed all of your Twitter meta tags except "card" and "site", and tried it again. This time it loaded up a preview card. The image didn't load, but it may be because the domains don't match (I'm not sure about that one). This is what I used: <meta property="og:title" content="Digital Marketing Montenegro: SEO & Online Marketing Expert"> <meta property="og:description" content="Digital Marketing Montenegro. Top SEO & SEM Services for Brands. Increase Website Traffic & Leads. Get a Free Quote from Miljan Vujosevic Today!"> <meta property="og:type" content="website"> <meta property="og:image" content="https://vujosevic.com/site/assets/files/1/web-1.1200x630.jpg"> <meta property="og:url" content="https://vujosevic.com/"> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site" content="@VujosevicCom"> I'm not saying that will fix everything (as when I tried it the image didn't render), but it at least did get a card view to show up! -
Unrelated question to PW - it's a problem with Twitter
BrendonKoz replied to Leftfield's topic in Pub
I didn't see anything in particular that looked out of place from quickly looking it over either. In fact, the unofficial Twitter Card Validator rendered a Twitter card as you'd expect from your markup. Usually if something changes without you doing anything, the fault isn't on your end - or at least with your code (maybe, like you said, a change to the server, like a robots.txt file or some sort of proxy, server protection, redirection, etc.). Since Twitter's official validator/renderer isn't really active anymore, it's hard to know what isn't working and why. If you have a different server (host) and web domain that you could test against, maybe export the source code of your homepage, along with the image (and path) and recreate it elsewhere and see if linking to that test/temporary location works as expected. At the very least - if it works - it would eliminate the rendered HTML code as being the issue. -
Unrelated question to PW - it's a problem with Twitter
BrendonKoz replied to Leftfield's topic in Pub
The official Twitter Card Validator tool no longer functions and renders a preview, why they didn't just remove the tool is unknown to me. Instead, they direct devs to just start creating an actual tweet (no need to send it) to test rendering/preview functionality. I get the same error with my website using the Twitter Card Validator, but it renders as expected when writing out a tweet. What's the difference between your site and mine that I tested against? Your HTML is minified. Maybe that has something to do with it? I'm not sure. -
At this level of uncertainty, this is where I'd probably set up xdebug to integrate with an IDE to step through processes. Alternatively, maybe Ryan's ProfilerPro in ProDevTools to compare how the module version works vs the traditional?
-
This is pretty cool - thanks for sharing! For your color assignment, if this might help, I'd used Chart.js for a PHP-based project in the past and didn't want to have to manually assign colors, so I used the data label to dynamically generate colors for the chart. Here's the helper function I came up with. In my case, I found that the haval128,4 hashtype worked well for color differentiation/contrast, but another option may end up being slightly better with different datasets. ? <?php /** * Convert a string into RGB array (with alpha transparency option) * * @param string $string Any text to be represented as color * @param string $hashtype Hashing algorithm which supports a 32-character output * @return array RGBA color set */ function string_to_rgba($string, $hashtype = 'md2') { // 32-char options: md2, md4, md5, ripemd128, tiger128,3, tiger128,4, haval128,3, haval128,4, haval128,5 if (!in_array($hashtype, ['md2', 'md4', 'md5', 'ripemd128', 'tiger128,3', 'tiger128,4', 'haval128,3', 'haval128,4', 'haval128,5'])){ $hashtype = 'md2'; } $fullhash = hash($hashtype, $string); $hash = substr($fullhash, 0, 8); $colors = str_split($hash, 2); foreach ($colors as $i => $color) { $decimal = hexdec($color); if ($decimal > 230) { $decimal -= 25; } else if ($decimal < 50) { $decimal += 50; } $colors[$i] = $decimal; } $colors[3] = intval($colors[3] / 255 * 100); return $colors; }
-
The "summary", just in case this was overlooked, isn't (entirely) an in-built feature for the module. It needs to be told what field in your template(s) will be used for the search result summary when rendered. From the documentation on the Modules page, under the "Options" heading, check the render_args property of the module's config, and look for the below: // Summary of each result (in the search results list) is the value of this field. 'result_summary_field' => 'summary', In the config, the "result_summary_field" points to the field used in your instance of ProcessWire this module is being used in that will be used to render the search result template's summary. So if in your templates you either don't have a summary field, or the field you use to define a summary is named differently, you'd need to use whatever value you have for your template(s). If maybe you used something like "short_description" as a page summary field, go with that. If you don't have a summary, you could use a "body" or "content" field, and in the render template use some form of string truncation, such as sanitizer()->truncate($your_summary_field, 80). If you're using JSON, slightly further down is a different section for that: // These settings define the fields used when search results are rendered as JSON. 'results_json_fields' => [ 'title' => 'title', 'desc' => 'summary', 'url' => 'url', ], Does that help at all?
-
That was likely a conscious decision with their htaccess rules to prevent numerically traversing an entire forum (and instead requires parsing HTML to identify internal hyperlinks, so more processing power on the part of bad bots). Good find though! I much prefer shorter links. ?
-
Hooking ProcessPageAdd::getAllowedTemplates -- Odd behavior
BrendonKoz replied to BrendonKoz's topic in General Support
I somehow managed to miss this reply. Thank you for both of your replies, @Robin S! I did manage to get this working, with some oddities here and there that had to be worked through due to how I was checking/setting access permissions. I chose not to explicitly set permission for each and every template per role since I'm using a field that's added to the templates to determine access, so it seemed doubly difficult to do that, and my hope was that inheritance would work properly most of the time. So far that's fairly true, with occasional exceptions (ex: nested repeaters since repeaters have their own system templates). It felt a little hack'ish but I checked against the template name and if strpos() found a match to "repeater_" against $page->template->name, then I'd allow access to the edit method (add didn't cause an issue the way I had it written). I wasn't sure how else to check if a template of a page being checked for access belonged to a repeatable fieldtype. -
Disabling/Uninstalling SessionHandlerDB is supposed to log out any users - did you get logged out prior to seeing that message? I should've mentioned it would be a good idea to back up the database prior to disabling, just in case, but since you just moved hosts, I'd imagine whether you did or did not get a backup prior to disabling the module, you should have the ability to restore that table and its data, if need be - and/or restore to your prior host's backup state. I know a lot of people have had issue with the SessionHandlerDB, which is why I think it's a good idea to see if running the site with it disabled might help. Unfortunately, you also want to be able to use your site, and it seems something is holding on to a cache and/or expecting the table to exist. I'm not familiar with all of the modules you've mentioned, so maybe one of them needs it too?
-
I haven't personally messed much with the table salt things, but usually that's related to passwords. If you can log in successfully, I'm thinking that's OK (and I would not change it). If you have a feeling there may be an issue with SessionHandlerDB, try disabling it temporarily to see what happens.
-
I tried accessing your website (and the problematic page) last night and also encountered the error. The error message that I received was about a proxy server having issue, however. Is the current host using nginx or Apache? If there's a proxy server somewhere in there (if not nginx) then it's going to be beyond my experience/capabilities to know how to help. Otherwise, maybe look into why that particular page section (Newsboard) seems to cause trouble when other pages mostly load rather quickly. ProDevTools' ProfilerPro might be useful here, if identifying problem areas on your own ends up being difficult to find.
-
How to enable for other users (during dev)?
BrendonKoz replied to BrendonKoz's topic in Tracy Debugger
Thanks - that did it! Looks like forcing "isLocal" was what I needed here. In this case it's not a guest, though I'm guessing the permission level is equivalent to guest. (I haven't explicitly added any tracy related permissions to roles.) -
I had thought I had Tracy enabled for all users (excluding guests) awhile back and disabled it. Now I can't seem to re-enable it now that I need to diagnose some things. I am not restricting non-superusers (or superusers for that matter), the Tracy Debugger is enabled, and I even tried to match the IP address using PCRE pattern of /.*/ with no luck.
-
I'm responding with no experience using custom page classes, so if my reply is just silly, I apologize. ? Perhaps I'm missing something, but I think my question here is also the question that ProcessWire is throwing an error about. Where do your ProcesswireTemplate::INDIVIDUAL_CAR_CHOICES and ProcesswireTemplate::INDIVIDUAL_CAR_CHOICE variables' values come from? In fact, where is the ProcessWireTemplate class located? There's a Template class in wire/core, but I'm not seeing a Processwire* class anywhere. If those classes/values don't exist, that could cause the errors to be thrown. If you're moving the code to another class, maybe it's not actually being called/used and ProcessWire is falling back to using the standard Page class?
-
This is really neat. If the action relates to a topic, can the topic name be linked to the actual topic? (I saw people viewing topics that I hadn't read in a long time and recall it being interesting; currently have to go back to the forum and search for it). Related to PWGeeks - is the "last updated" status the last time the related project was (determined to be) updated, or the last time PWGeeks checked the project's status? I ask because the very last page (279 as of right now) shows a last update time based on my current clock time. Ordering by "Recently Modified" shows FieldtypeFolderOptions on the first paginated page, but was last updated (Github) 4 years ago. I love the PWGeeks project, btw. ❤️
-
So far my solution to this seems unnecessarily complex. I have a primary RepeaterMatrix field (`content_body`). I've duplicated that field and called it "content_column". I created a Repeater (standard) field, added a simple number field (for column width, for now) and the "content_column" field. I've added "content_row" to "content_body" as a new item. I'm using field-based file rendering, so I have a file structure such as: fields: - content_body.php - content_body/field1.php - content_body/field2.php ...etc... So now I've got to duplicate the files for rendering the contents of the "content_column" RepeaterMatrix, which is basically just a copy/paste of all the individual fields of the "content_body" folder, and maintain changes between the duplicated files. I tried to add "content_body" to "content_row" as a subfield, but I kept getting 503 errors in the admin and ultimately had to revert the database to recover. ?
-
My difficulties were in understanding how to set up the fields to allow such a scenario, but not make it ridiculously complicated to maintain, or for the editing end-users. I suppose offering a numerical value for the column size (ex: 2-10) per matrix item would also be a valid solution, and far more customizable. As silly as it sounds, the reason I was thinking of offering varied custom sizes is because some of our users are extremely tech-averse, and will mess that up. ?
-
I have a single RepeaterMatrix field that I'm using to generate a bunch of available components. Most of the remaining components left to create are intended for columnar-layout options...in this case, equal width 2-column, 3-column, and 4-column options, as well as a 30/70, and 70/30 split. Ultimately I'd prefer to offer just the column option, and leave the content of the columns up to the end-user, rather than locking it into a "1 image, 1 textarea" style option. I'm having a hard time coming up with a way to offer the dynamic option, while also limiting the column count, and am curious how others might've tried solving this issue. It can't be all that unique! EDIT: Looks like I might (manually) recreate my RepeaterMatrix field and add it into a FieldsetOpen field along with a few settings (fields), such as a min/max number (2-4) and base the layout on that for the frontend. I don't need to force the columns to match the numbers of the column setting, the components would just flow into the number of columns as needed. Definitely not the most efficient, I'm sure, but it should work. It's too bad (at least without RockMigrations) that I can't easily create a duplicate of a RepeaterMatrix field! ?
-
Uploaded PDF file is not the proper, full size; becomes corrupted
BrendonKoz replied to BrendonKoz's topic in General Support
Verified: It was our webhost's (Dreamhost) customized, and overly intrusive mod_security settings. -
Problem with selector after upgrading from 3.0.210 to 3.0.229
BrendonKoz replied to lpa's topic in General Support
@lpa Reading over the ProcessWire Weekly, apparently there was definitely an issue that was fixed in the recent dev version. https://weekly.pw/issue/514/#latest-core-updates -
Problem with selector after upgrading from 3.0.210 to 3.0.229
BrendonKoz replied to lpa's topic in General Support
Just a passing thought without testing or checking, but it looks like banner_file and video_file are string-based values, whereas is_html5 and html are boolean-based (true/false). If that's correct, it's possible that some stricter checking needed to be done for PHP 8.x compatibility, and you might need to break that selector up into multiple parts. -
Hooking ProcessPageAdd::getAllowedTemplates -- Odd behavior
BrendonKoz replied to BrendonKoz's topic in General Support
It seems as though ProcessPageAdd::getAllowedTemplates is called so many times that it doesn't actually always have a $parent value on each call (because of how my authentication is configured). I had to test for null on that value, and exit gracefully if null, and if not then I could enter into my logic. The manual assignment of values worked because it forced a value each time regardless of what was passed into the method as a $parent value for the $event object. EDIT: This now works for a superuser account, but not for a standard account. It seems there's something else in permissions that I'm missing. Updated hook method, without any added business logic of my own, is now: public function allowTemplates($event) { // Not all calls pass in an argument value if (is_null($event->arguments('parent'))) return; // Identify the intended parent template and fetch its allowed (template) children $parent_t = $this->wire->templates->get($event->arguments('parent')->template); $child_t = $parent_t->childTemplates; // Assign the allowed children to an array we can set to return $allowed_templates = []; $allowed_templates[$parent_t->id] = $parent_t; foreach ($child_t as $t) { $t = $this->wire->templates->get($t); $allowed_templates[$t->id] = $t; } // I like sorted values ^_^ ksort($allowed_templates); // Return the expected template array back to the calling process $event->return = $allowed_templates; } If I give "Edit Pages", and "Create Page" permission to the role for the child template, and "Add Children" permission to the parent template for the role, then I can create a Job Listing (child) under the Job List (parent). However, once I do that, everyone with the role can successfully do this, despite me trying to send FALSE (or some similar value) back through any available hooked method. I can't seem to override a strict parent/child relationship.