Jump to content

Leftfield

Members
  • Posts

    117
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Leftfield

  1. I've just tried and it worked like a charm. I will go nuts
  2. Hey @ceberlin thanks!!! I thought to do it anyway and add more functionalities in the next update. For now, change the function checkTextLength in SeoTextWidth.js // Text length checking and warning (updated) function checkTextLength(input, fieldConfig) { const span = $('<span class="detail"></span>').insertAfter(input); input.keyup(function() { const text = $(this).val(); const width = Math.round(calculateTextWidth(text, fieldConfig.font)); // Round to whole number if (width > fieldConfig.maxWidth) { span.html(`<i class="fa fa-exclamation-circle"></i> <span class="text-danger">Warning:</span> Text exceeds max width (${fieldConfig.maxWidth}px).`); span.addClass('text-danger'); } else { span.text(`Estimated Width: ${width}px`); // Display rounded value span.removeClass('text-danger'); } }); }
  3. @BrendonKozNo. The Validator validated every 10th time. Once, the tweet pulled the full image. Once, it created space but an empty image. Several times, it created a thumbnail with no image, too. I will try HTML and another server tomorrow first thing in the morning. I tried from the same server, another website in ProcessWire, and it worked. Not anymore. (edit) I tried with another CMS from another server; it was a different CMS, and it worked.
  4. @BrendonKozI've tried that. But I'm going to try it again right now and will let you know. Thanks for the effort, mate!
  5. @BrendonKozthanks for helping me!!! I've tried the non-minimized version (it worked before as-is). I even changed the brackets at the end from "/>" to ">" and back. It's incredibly frustrating because I have no idea what to do, and I'm not server-oriented enough to test it from that side, like ports. I believe I've missed something, but I can't see it.
  6. I don't want to share a link here (it is my signature), but I have a problem: when sharing a link on Twitter (X), it doesn't pull images anymore. The problem started "recently," and I can't replicate it. I rewrote the code, removed it, and placed it again, cleared the cache every time, tried with meta twitter:image:src, had a look at the cpanel (no IP blocked), read about 100 websites, and I am completely powerless. I hoped someone here could help me. I got the following error when using the Twitter Card Validator: ERROR: Failed to fetch page due to: HttpConnectionTimeout
  7. It is ready. Sorry for the second post. Kind regards and thanks!
  8. Hey @ryan:) In the meantime, I updated the module, and TBH, I wasn't sure if it meets the conditions for the listing in the module directory. I look forward to sharing it (and hopefully updating it with more functionality).
  9. @BrendonKozthanks mate! I have to try it. Brilliant! @bernhard Yes, for me, it is a fun little thing but very useful. Here's screenshot attached.
  10. Hi @All, I made the page with only admin access so I can check in frontend visually (a chart) and links - what pages are most linked from blog pages and where I forgot to use this opportunity. This is important for SEO and removes manual labor. If you have any suggestions, feel free to shoot. Simple explanation: I got template=post and want to see stats with inner links to the homepage and service pages. Thanks @poljpocketfor helping me out! <?php namespace ProcessWire; // Calculate Internal Link Counts and Linked Pages $pages = wire('pages'); // Get all relevant pages directly in one query $relevantPages = $pages->find("template=post|service|home"); $blogPosts = $relevantPages->find("template=post"); $mainPages = $relevantPages->find("template=home|service"); // Function to check if a post DOES NOT link to ANY PUBLISHED service OR home page /** @var PageArray $mainPagesLinks */ $mainPagesLinks = $wire->wire(new PageArray()); foreach ($mainPages as $mainPage) { // this will remove duplicates by default $mainPagesLinks->append($mainPage->links("template=post")); } // Calculate Internal Link Counts and Linked Pages $linkCounts = []; $linkedPages = []; foreach ($relevantPages as $page) { $linkCounts[$page->id] = 0; $linkedPages[$page->id] = []; if ($page) { $items = $page->links(); if ($items->count()) { foreach ($items as $item) { if ($item->template != 'admin') { $linkCounts[$page->id]++; $linkedPages[$page->id][] = $item; } } } } } arsort($linkCounts); // Prepare data for the circle chart $chartLabels = []; $chartValues = []; foreach ($linkCounts as $pageId => $count) { if ($count > 0) { $page = $pages->get($pageId); $chartLabels[] = $page->title; $chartValues[] = $count; } } ?> <div class="container py-5 mb-5 links"> <div class="row py-5"> <div class="col-12 col-md-4 offset-md-4 pb-5"> <canvas id="linkCountChart" width="200" height="200"></canvas> </div> <div class="col-12 col-md-8 offset-md-2"> <div class="accordion" id="internalLinksAccordion"> <?php foreach ($linkCounts as $pageId => $count): ?> <?php if ($count > 0): ?> <?php $page = $pages->get($pageId); ?> <div class="accordion-item"> <h2 class="accordion-header" id="heading<?= $page->id ?>"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse<?= $page->id ?>" aria-expanded="false" aria-controls="collapse<?= $page->id ?>"> <?= $page->title ?> (<?= $count ?>) </button> </h2> <div id="collapse<?= $page->id ?>" class="accordion-collapse collapse" aria-labelledby="heading<?= $page->id ?>" data-bs-parent="#internalLinksAccordion"> <div class="accordion-body"> <?php if (!empty($linkedPages[$page->id])): ?> <ul> <?php foreach ($linkedPages[$page->id] as $linkedPage): ?> <?php if ($linkedPage->template != 'service'): ?> <li><a href="<?= $linkedPage->url ?>"><?= $linkedPage->title ?></a></li> <?php endif; ?> <?php endforeach; ?> </ul> <?php else: ?> <p>No internal links found for this page.</p> <?php endif; ?> </div> </div> </div> <?php endif; ?> <?php endforeach; ?> </div> <h3 class="pt-5">Posts without Links to Service and Home Pages</h3> <table class="table"> <thead> <tr> <th>Post Title</th> <th>Edit Link</th> </tr> </thead> <tbody> <?php // echo results foreach ($blogPosts as $post) { if (!$mainPagesLinks->has($post)) { echo "<tr>"; echo "<td><a href=\"{$post->url}\">{$post->title}</a></td>"; echo "<td><a href=\"{$post->editUrl}\">Edit</a></td>"; echo "</tr>"; } } ?> </tbody> </table> </div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script> document.addEventListener('DOMContentLoaded', function () { // Chart data is now defined within the JavaScript scope const chartData = { labels: <?= json_encode($chartLabels); ?>, datasets: [{ data: <?= json_encode($chartValues); ?>, backgroundColor: [ 'rgba(255, 99, 132, 0.8)', 'rgba(54, 162, 235, 0.8)', 'rgba(255, 206, 86, 0.8)', // Add more colors as needed ], }] }; const ctx = document.getElementById('linkCountChart').getContext('2d'); const linkCountChart = new Chart(ctx, { type: 'doughnut', data: chartData, options: { plugins: { legend: { display: true, position: 'bottom', }, } } }); }); </script>
  11. Working like a charm. Thanks @poljpocket!!!! PS: I will post my code now on the other thread so everyone can grab
  12. I want to list all pages from template=post that don't link to template=home|service.
  13. Hey :). Thanks for helping me!!! Nope. I got the links the same way. Made pie chart, list of all links with number of links pointed to them. But for some reason I can't get pages which do not link other pages (with different template).
  14. UPDATE on 15 May 2024: Google started to calculate (truncate) the meta title for 20px Arial yesterday. The Module has been updated.
  15. Oh man, and I've put it in the field description :D. I was born just a few hundred kilometers from the Tesla's house. It seems like I am Jang for his Jing.
  16. @BitPoetthanks for helping me out!!! All I can get is (normal). Just pasting part of the code: 2024-05-15 09:27:23 leftfield http://localhost/test/ Running TextformatterImgDataUri 2024-05-15 09:27:23 leftfield http://localhost/test/ Running TextformatterImgDataUri 2024-05-15 09:27:23 leftfield http://localhost/test/ Running TextformatterImgDataUri 2024-05-15 09:27:23 leftfield http://localhost/test/ Running TextformatterImgDataUri 2024-05-15 09:27:23 leftfield http://localhost/test/ Running TextformatterImgDataUri
  17. Hi @All I am checking if the post pages have no links to the service or home pages. If they don't, list them. All I can get is a list of all the post pages with links. I've tried to rewrite this function like 100 times but no luck. What am I doing wrong? // Get all relevant pages directly in one query $relevantPages = $pages->find("template=post|service|home"); $blogPosts = $relevantPages->find("template=post"); $mainPages = $relevantPages->find("template=home|service"); // Function to check if a post DOES NOT link to ANY service OR home page function postHasNoLinksToMainPages($postPage, $mainPages) { $mainPagesIds = $mainPages->explode('id'); foreach ($postPage->links() as $link) { if (in_array($link->id, $mainPagesIds)) { return false; // Found a link to a main page, so return false immediately } } return true; // No links to PUBLISHED main pages found, so return true } // echo results foreach ($blogPosts as $post) { if (postHasNoLinksToMainPages($post, $mainPages)) { echo "<tr>"; echo "<td><a href=\"{$post->url}\">{$post->title}</a></td>"; echo "<td><a href=\"{$post->editUrl}\">Edit</a></td>"; echo "</tr>"; } }
  18. Hey, @BitPoet I'm excited about this module (and I really need it!). I appreciate your help in advance. I might be stupid as a rock, but at least I'm consistent. I have tried on Windows and Linux (in both cases, php_fileinfo.dll is on). I placed it in the image field, like in the screenshot, but nothing happened. I've cleared the cache, etc. The debug mode is ON, and no error is logged.
  19. No, mate. PW (as you all know way better than me) doesn't have the option to change the default fields published and modified. Published is constant, and Modified is changing on every page save. It doesn't suit me, so I made my date field to set a date when publishing/changing so it reflects on the sitemap and tells search engines the page has been changed on that date. Not on every save.
  20. @wbmnfktrthanks mate!!! I count beers I owe you.... So for anyone looking at this here is the solution: $wire->addHookAfter("Pages::published(template=post)", function (HookEvent $event) { $pages = $event->object; $page = $event->arguments(0); $blog = wire('pages')->get('template=blog'); $blog->date_modified = $page->date_modified; $blog->save(); // wire()->log->save("debug", "page was published"); });
  21. Ehey, aloha everyone! I have two templates: post and blog. When publishing a first-time post, I must update the (same) field date_modified on its parent (a single) template blog. I am trying it via hook, but nothing happens. This checking for status unpublished is not working for some reason too. I appreciate any help! $wire->addHookAfter("Pages::saveReady(template=post)", function($event) { $page = $event->arguments(0); $pages = $event->object; // if ($page->isNew() && $page->status->unpublished != true) { if ($page->isNew()) { $blog = wire('pages')->get('template=blog'); $blog->date_modified = $page->date_modified; $blog->save($blog->date_modified); // $blog->save(); } });
  22. I logged into Google Search Console last night. For the umpteenth time, I received the message: "Fixes failed for Page indexing issues - Page with redirect." I am trying to get non-www URLs and use the default htaccess file (trying to keep up with the updates). Problem - Google scans the website URLs in this particular order, and chaining (which is The problem) via htaccess happens: http://www.example.com -> https://www.example.com -> https://example.com Fix: While I do not know how to write directives in the .htaccess, I spent hours to find a solution and finally succeeded. RewriteEngine On RewriteCond %{HTTPS} !on [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE] However, as I mentioned, I'm unfamiliar with the .htaccess file, and I am 100% sure that this could be written with a wild card. So, on this occasion, by default, can we have an option to avoid chain redirections of URLs?
      • 1
      • Like
  23. Silly me. I thought calculating width would be simple. Just tested, Google is truncating meta titles by 18px and meta descriptions by 13px. I need to take some time (busy ATM) to fix this in JavaScript, and will update again. It is updated.
  24. @cwsoftthanks for helping me! @adrian It's running on LiteSpeed, but I don't know what's underneath it. But hey, it is working like a charm.
×
×
  • Create New...