Jump to content

combicart

Members
  • Posts

    78
  • Joined

  • Last visited

Everything posted by combicart

  1. @MoritzLost I installed this module today and I'm wondering if it's compatible with PHP 8.3 and Processwire 3.0.229? When I add the field to a FormBuilder form and try to open the form on the website I get the following errors at the top of the form: Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /wire/core/Inputfield.php on line 1395 Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /wire/core/Inputfield.php on line 1395 Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /wire/core/Inputfield.php on line 1395
  2. @Jan Romero and @da², thanks for your help! I just tried it again with the selector from Jan and it gives the correct results. I didn't correctly understand the query from the original post for my situation but this helped a lot. Thanks!
  3. Thanks @da², I tried to solve it with an additional foreach loop but unfortunately that didn't work.
  4. Hello, I'm currently building an events website where one event can be in different locations. Each location can have it's own date. I therefore have added a repeater field called `event_locations` to an event where we can add more information about the location. The `event_locations` repeater contains the following fields: location (page reference) event_date (datetime field) event_price (text field) event_link (url field) On the event detail page I would like to show the different locations and sort them by date and city. Events in the past can be removed from the page. I normally check the date with `event_date>=today` which works whenever I loop through all pages and filter by template. However in this case I would like to filter through the repeater field which doesn't give the same results for some reason. This works (but displays all future event_locations): $pages->find('event_date>=today, sort=event_date, sort=location.location_city') This doesn't work (this give no results at all): $page->event_locations->find('event_date>=today, sort=event_date, sort=location.location_city') Can't the event_date be used in this case? Or is there a different way to get only events in the future for this specific event?
  5. @Mirox and @BrendonKoz, thanks for the help. That was exactly what I was looking for ?
  6. @BrendonKoz Thanks! I've added the change and now it works like expected. One other question. I would like to make the checkbox 'checked' when one or more filters are enabled. I tried doing this with the checked() method and with in_array but so far I'm not able to get the results that I want. Is there a way to add the `checked` option to a checkbox when it's active in the filter?
  7. I'm currently working on a page which shows an overview of Events. I would like to add a filter so that users can view the Events that are in their neighbourhood or that belong to a specific category. I'm using the following code for the form: <form action="." method="get" id="events_filter"> <?php foreach ($pages->get(1104)->children() as $category) : ?> <div class="flex items-center"> <input id="<?= $category->id; ?>" name="category" value="<?= $category->id; ?>" type="checkbox" class="text-gold-600 h-4 w-4 rounded border-brown-300 focus:ring-gold-500"/> <label for="<?= $category->id; ?>" class="ml-3 text-brown-800"><?= $category->title; ?></label> </div> <?php endforeach; ?> <?php foreach ($pages->find("template=location") as $location) : ?> <div class="flex items-center"> <input id="<?= $location->id; ?>" name="location" value="<?= $sanitizer->kebabCase($location->title); ?>" type="checkbox" class="text-gold-600 h-4 w-4 rounded border-brown-300 focus:ring-gold-500" /> <label for="<?= $location->id; ?>" class="ml-3 text-brown-800"><?= $location->title; ?></label> </div> <?php endforeach; ?> <button type="submit" id="events_filter" class="text-md flex w-full justify-center rounded bg-orange-500 px-8 py-3 font-semibold text-white transition hover:bg-orange-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-orange-200">Filter</button> </form> On the page itself I've added the following code to get the categories and locations: //Default selector to get ALL events $selector = "template=event"; // Get cateogry and location variables and sanitize $category = $sanitizer->selectorValue($input->get->category); $location = $sanitizer->selectorValue($input->get->location); if ($category) { $selector = $selector .= ",event_categories=$category"; } if ($location) { // See how this uses greater than or equal to $selector = $selector .= ",event_locations.title=$location"; } $events = $pages->find($selector); There is only one thing that I can't get to work. When a user currently selects multiple checkboxes, only the last checkbox will be used inside the filter. Ideally when a user selects multiple checkboxes they all will be used inside the filter. Is there someone that could point me into the right direction on how to achieve that?
  8. @Robin S That's really great! Will use the combined setup with getPaginationString() and MarkupPagerNav to achieve the pagination markup. Thanks, for pointing me in the right direction!
  9. Hey, i'm currently building a website with a news section. On the overview page I would like to add a pagination so that users can easily switch from page to page. I already included the MarkupPagerNav setup. However I would like to adjust the output of the module and I'm not really sure how to adjust it to my needs. I would e.g. like to output the current page and the total number of pages. See example below of what I would like to achieve: Could someone point me in the right direction on how to output the correct variables? Thanks!
  10. Hi there, I would like to start the navigation on the 2nd level / depth instead of the 1st. I've tried to set this up with the `$rootPage` variable, bit I can't seem to find the correct flow for what i'm trying to achieve. Ideally I want to use the following setup: - Home -- Location A --- Page 1 --- Page 2 -- Location B --- Page 3 --- Page 4 When you're on the Homepage the menu should show: Home - Location A - Location B When you're on the Location A page, the menu shows: Home (which is the Location A page) - Page 1 - Page 2 Is there a way to achieve this with the MarkupSimpleNavigation module? Or could somebody point me in the right direct to implement this menu? Thanks!
  11. Thanks for pointing me in the right direction. I've add a hook to the ready.php file. If someone is interested, below i've added a snippet of what i'm using: wire()->addHookAfter('Pages::saveReady', function(HookEvent $event) { $page = $event->arguments(0); foreach ($page->body_extended as $item) { // $body_extended is the name of the matrix field if ($item->type == 'text') { // Looking for a 'text' matrix field $seo_description = substr(strip_tags($item->body), 0, 255); // Find the body text and strip/trim the html tags break; } } $page->seo_description = $seo_description; // Save the body inside the seo_description field on the page });
  12. In my current setup I've added a matrix field called 'body_extended'. Inside this field one of the matrix types is a 'text' block. Inside this block I have two fields: 'title' and 'body'. The body field is a CKEditor text area field. I would like to copy the content of the 'body' field that is inside the first 'text' block that is available on the page inside a different field (called 'seo_description') on the same page (just a regular field, not a matrix field) however I'm struggling to find the best approach. I've started looking into hooks but I'm not sure if and which hook is suitable for this situation. Has somebody faced a similar situation before or could someone point me in the right direction? I've attached a screenshot of what I'm trying to accomplish. Thanks!
  13. Hi @dragan, thanks! I've just implemented the hook and it's working perfectly! Thanks for pointing me in the right direction!
  14. Is it possible to show additional markup for a specific menu item? I would like to show the number of subpages (with it's own markup) for one specific main menu item. The page is a regular page with the same template as other pages in the menu. Would this be possible?
  15. Thanks @Autofahrn, adding it to $config worked perfectly!
  16. I'm currently building a website where I inline some SVG icons directly into the template. I'm using https://github.com/oscarotero/inline-svg for inlining the icons. I've added the code below to my _init.php file to set where all the icons are stored: $icons = Collection::fromPath('path/to/svg/files'); Inlining an actual SVG icon can be done with the code below. In the example below we are adding an SVG icon with the name 'edit': echo $icons->get('edit'); So far everything is working as it should. For bigger parts of the template i'm using delayed output and i'm passing the 'icons' variable into the separate template files, like below: $content = wireRenderFile('partials/homeFacilities', ['icons' => $icons]); This outputs the icons inside the partials. For setting up details of a page i'm using the ProFields Repeater Matrix module and this is where i'm getting an error. I have to pass the 'icons' variable into the Repeater Matrix template files, however I can't seem to set it correctly so that the template files have access to this variable. The Repeater Matrix fields is setup like below: foreach ($value as $item) { echo $item->render(); } Is there a way to pass the 'icons' variable into the Repeater Matrix template files? Or would it e.g. be beter to make this variable accessible globally?
  17. Ah, totally overlooked this option. Setting this to false solved the problem! Thanks!
  18. I'm currently using the RSS Feed Loader module (https://modules.processwire.com/modules/rss-feed-loader/) to import an RSS feed. In the feed there is an 'description' field that has html markup inside. By default the html markup is stripped out by the module Therefore i've used the option below to render the description including markup: $rss->stripTags = false; After adding this option, the values in the database are still escaped, e.g. like: &lt;h3 class=&quot;deprecated-h3&quot;&gt;Description&lt;/h3&gt; &lt;p&gt;Description&lt;/p&gt;  Would it be possible to save the description field directly into the database (including it's HTML markup)?
  19. I would like to import a description field including it's HTML markup. In the RSS feed the markup is included, however by default the markup is stripped by the RSS feed module. Therefore i've used the option below to render the description including markup: $rss->stripTags = false; After adding this option, the values in the database are still escaped, e.g. like: &lt;h3 class=&quot;deprecated-h3&quot;&gt;Description&lt;/h3&gt; &lt;p&gt;Description&lt;/p&gt; Would it be possible to save the description field directly into the database (including it's HTML markup)?
  20. I'm currently working on a website where I would like to fetch data from an RSS feed and save them as actual pages inside ProcessWire. Ideally ProcessWire is an exact copy of the RSS feed. When a new page is added to the RSS feed, the new page would also be added in ProcessWire. Or when a page got removed from the RSS feed, the page should also be delete from within ProcessWire. I'm using the following setup: 1. Fetch the RSS feed with $rss = $modules->get('MarkupLoadRSS'); $rss->load('http://www.domain.com/rss'); 2. Compage the RSS feed with the pages that are currently save in Processwire foreach ($rss as $item) { ... } 3. If page is in RSS feed, but not in ProcessWire, save page 4. If page is in RSS feed and in ProcessWire, update values with data from the RSS feed 5. If page is not in RSS feed, but in ProcessWire, delete page To get all the pages from the RSS feed, check if it exists and create the page from the API if it doesn't exist, i'm using the code below: <?php include './index.php'; // bootstrap PW $rss = $modules->get('MarkupLoadRSS'); $rss->load('http://www.domain.com/rss'); foreach ($rss as $item) { $p = $pages->get("job_id=$item->id"); // get the ide of the job if (!$p->id) { $p = new Page(); // create new page object $p->template = 'job-offer'; // set template $p->parent = wire('pages')->get('/vacatures/'); // set the parent $p->name = slugify($item->title); // give it a name used in the url for the page $p->title = $item->title; // set page title (not neccessary but recommended) // added by Ryan: save page in preparation for adding files (#1) $p->save(); // populate fields $p->job_id = $item->id; $p->save(); // testing echo 'id: ' . $p->id . '<br/>'; echo 'path: ' . $p->path; } } So far everything works and the pages got created ? However I'm having trouble with the logic for points 4 and 5. - When a page is in the RSS feed and is already add to ProcessWire. Is there a way to find a page and update it's content through the API? - When a page is not in the RSS feed anymore. Is there a way to delete all pages that are not in the RSS feed? Thanks!
  21. Thanks @FrancisChung and @adrian! Will check out both SimpleXML and the CSV parser to see which approach fits best for the XML feed. About the 1300 pages, yeah I've already checked about ways to speed up the import process. Unfortunately they only provide 1 large XML feed which contains both the old and updated pages. They provide a date and UUID field inside the XML feed which I could use to check if there is something updated or not. Totally agree with you that ideally only the changes are being processed instead of the complete file again and again.
  22. I'm currently in the process of setting up a new website. Most pages on the website will be imported from an XML feed. The feed itself is located on an URL and will be updated daily. The pages should basically be an copy of the XML feed. So it might be possible that based on the import pages could be created, updated or deleted. As far as I understand, there are a couple of ways ProcessWire could import the feed: - Through one of the importer modules (https://modules.processwire.com/modules/import-pages-xml/) - With the new JSON import function that is available from version 3.0.64 (https://processwire.com/blog/posts/a-look-at-upcoming-page-export-import-functions/) - Use the API (https://processwire.com/talk/topic/352-creating-pages-via-api/ The feed itself is around 16Mb and contains about 1300 pages. Each page has around 10 images of 1Mb per page (13Gb in total). Does anybody have worked with this kind of setup or has some advise on what the best way is to start? Thanks!
  23. Thanks BitPoet, will use this setup to fetch the page id. Also the sanitation is a good tip!
×
×
  • Create New...