double
Members-
Posts
12 -
Joined
-
Last visited
Everything posted by double
-
I am building a website with a structure like this: Category1 (template compare) Page 1 (template compare) Page 2 (template compare) Page 3 (template compare) Category2 Page 4 Page 5 I want to create a comparison feature where, when visiting /category1/page1/, it will display the details of page1. But when navigating to /category1/page1/page2/, it will show both pages side by side for comparison. I have added 404 error when the URL segment is incorrect, and also implemented redirection based on page IDs to prevent duplicates. Is this a good approach for building the comparison template? Should I change the URL structure to /category/page1-vs-page2/? What are the best practices for handling this kind of comparison feature in ProcessWire? Here’s my code: <?php $segment = $input->urlSegment1; // Comparison output if (!empty($segment)) { echo "Segment has data: " . $segment; $page2 = $pages->getByPath('/category1/' . $segment); if (!$page2->id) { wire404(); } if ($page2->id > $page->id) { $session->redirect('/category1/' . $page2->name . '/' . $page->name . '/'); exit; } echo $page2; } //Category1 output if ($page->id == 1041) { echo "Category1"; } // /category1/page/ output else { echo "Category1 child"; } And here's -vs- comparison: <?php $segment = $input->urlSegment1; if (!empty($segment)) { // Split the segment by '-vs-' $pagesToCompare = explode('-vs-', $segment); // Two pages to compare if (count($pagesToCompare) != 2 || empty($pagesToCompare[0]) || empty($pagesToCompare[1])) { wire404(); } // The first and second page $page1 = $pages->getByPath('/category1/' . $pagesToCompare[0]); $page2 = $pages->getByPath('/category1/' . $pagesToCompare[1]); // If both pages exist if (!$page1->id || !$page2->id || $page1->id == 1041 || $page2->id == 1041) { wire404(); } if ($page2->id > $page1->id) { $session->redirect('/category1/' . $page2->name . '-vs-' . $page1->name . '/'); exit; } // Comparison here echo "<h1>Comparison of " . $page1->title . " vs " . $page2->title . "</h1>"; return; } if ($page->id == 1041) { echo "Category1"; } else { echo "Category1 child"; } ?>
-
AJAX Voting: You can now submit ratings without refreshing the page. Cookie Checking: It checks if a user has already voted by using cookies. Hover Effect: A hover effect has been added. If a user has already voted, the hover effect will be disabled for them. It needs some work b efore it’s ready for use on sites. Update: I've updated the code to store the average rating, vote count and rating sum in a separate table. Now it retrieves the data directly from this table instead of recalculating each time StarRating.module.php StarRating.module.php
-
I'm creating a star rating system for PW. I haven't found one. I would greatly appreciate your feedback. Star Rating Current Features: IP Checking: Prevents multiple votes from the same user. Displaying Stars and Rating Form: The star ratings are displayed on the pages with shortcode. Average Rating Calculation and Vote Counting: Calculates the average rating based on the votes. Known Bug: Currently the stars are not highlighted when a user hovers over them. Plans: Improved Styling: Enhance the visual appeal and user interface. AJAX Support and Feedback: Implement AJAX functionality to allow submiting ratings without page reload. Add a feature to provide users with immediate feedback after submitting their rating Structured Data Schema Support: The ratings are picked up by search engines for rich snippets, enhancing SEO and visibility. Cookie Checking: To further prevent multiple votes. Usage: The database table star_ratings is created during the installation. When you uninstall it drops the table. Add the following shortcode to the desired location within your template: <!--StarRatingForm--> StarRating.module.php
-
Comments fields Uncaught Error function render()
double replied to double's topic in Getting Started
Yes, I haven't added the field to template. Thank you! -
I followed this guide to add comments <?php echo $page->comments->render(); And I get this error Fatal Error: Uncaught Error: Call to a member function render() on null renderAll and renderForm same Can you help me solve this error please?
-
Works perfectly! Thanks a lot!
-
What's the best way to return 5 next and 5 previous pages? If there're no 5 pages return what's remaining Should I use nextUntil() and prevUntil()?
-
I'm looking for a book module alternative for creating structured documents. If you don't know about Book module of Drupal, follow this link: http://drupal.org/documentation/modules/book Also I'm looking for a module like html2book, which allows you to create multi-page books by splitting the body text of a book page node into multiple nodes upon save (split points are html tags)
-
I've added 1.5 million pages. It works faster than Wordpress, but server response time is still high - 0,8-2 s. I have 4 Cores, 4 GB RAM and SSD disk, Mysql 8 and PHP 7 I'll keep you updated
-
After installing Dataset module I get this error: Module reported error during install (DataSet): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'label' cannot be null When I click an Import link nothing happens. Tasks page is empty I tried to do a simple import for testing using this config Any ideas? Where can I see error log? JSON{ "name": "Testing the import", "input": { "type": "csv", "delimiter": ",", "header": 1, "limit": 10 }, "fieldmappings": { "title": 1 }, "pages": { "template": "basic-page", "selector": "title=@title" } }
-
How fast will be site after importing 8 million posts? I tried to use Wordpress but it requires serious hardware to handle 8 million posts I have a VDS 4 Cores 4 GB memory and NVMe storage
-
Can I import 8 million posts? Is it possible? Hardware requirements? I have 300 XML files (30k posts per file) SEO title Meta description H1 title Category Post content What is the fastest way to import?