Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

15 Good

About combicart

  • Rank
    Full Member

Recent Profile Visitors

1,685 profile views
  1. 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 });
  2. 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!
  3. Hi @dragan, thanks! I've just implemented the hook and it's working perfectly! Thanks for pointing me in the right direction!
  4. 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?
  5. Thanks @Autofahrn, adding it to $config worked perfectly!
  6. 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?
  7. Ah, totally overlooked this option. Setting this to false solved the problem! Thanks!
  8. 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: <h3 class="deprecated-h3">Description</h3> <p>Description</p>  Would it be possible to save the description field directly into the database (including it's HTML markup)?
  9. 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: <h3 class="deprecated-h3">Description</h3> <p>Description</p> Would it be possible to save the description field directly into the database (including it's HTML markup)?
  10. 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!
  11. 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.
  12. 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!
  13. Thanks BitPoet, will use this setup to fetch the page id. Also the sanitation is a good tip!
  14. Hello, I'm currently creating an Events website. I've setup an 'events' page with a date, start time and end time. I'm using the fields to print them out on the page. However, I would like to add the option that visitors can download an ICS file so that they can quickly add the event to their calendar. I've found https://github.com/markuspoerschke/iCal for the creation of het actual ICS files. I've created a new template file (download-ics) and used one of the examples (https://github.com/markuspoerschke/iCal/blob/master/examples/example7.php) for the template. When i'm browsing to the url with the (download-ics) template the ICS file is being downloaded correctly. However now there are only fixed values inside the ICS file. How can I pass the variables from the actual event into the newly created (download-ics) template file so that the actual date and times can be used?
  • Create New...