Jump to content

evan

Members
  • Posts

    94
  • Joined

  • Last visited

Everything posted by evan

  1. Probably the easiest way to add existing images and variations to PW pages would be via the API – take a look at the PageImage class docs: <?php namespace ProcessWire; // Bootstrap ProcessWire: https://processwire.com/docs/front-end/include/ include './index.php'; $results = $pages->find('id=1'); // Your page query $myImage = '/myImage.jpg'; // The image foreach ($results as $result) { // Add initial image $result->of(false); $result->imageField->add($myImage); $result->save(); // Retrieve added image, add description $lastImage = $result->imageField->last(); $lastImage->description = "My description"; // Create variation of last image $variation = $lastImage->size(500, 500); $result->imageField->add($variation); // Add additional variations here, and format conversion $result->save(); } You'll need to augment this code to accommodate an existing list of images, or multiple images per page, to match against the PW pages. WebP (or any image format conversions, it seems) are not natively supported by PW, but it looks like some folks have figured out some solutions (inline, and more integrated) :
  2. I figured this out, after running into this issue myself and digging into the FieldtypeTable class...definitely not intuitive though. Ideally a title or label property or method would just be exposed here. $field = $fields->get('table_field'); // Field $columnName = 'column'; // Column name in table $optionValue = 'my_option'; // Option value $optionTitle = $field->type->getSelectColumnOptions($field, $columnName)[$optionValue]; // Returns array of value => label echo $optionTitle;
  3. What's your reason for wanting to do this? The solution will depend on your desired outcome: You want the assets to be virtually served from a subdomain (files on the same server). You could accomplish this with a symlink, i.e. creating a virtual host entry and path for your subdomain, and placing a symlink to the your_primary_domain/site/assets/files/ there. You want the assets to be served from a subdomain on a different server. Not sure how this would be accomplished. If the ProCache module's CDN integration is any indication, I'm guessing you'd need to find a way to reliably mirror the file structure of /site/assets/files/ on the subdomain's server, and modify all your asset URL requests in the templates to point to that subdomain. As a side note, I wouldn't categorize PHP templates as assets, since they're processed server-side and not URL-accessible, unless you meant something else.
  4. Hey Sam, Welcome! It's definitely possible to build something like that. There's a few reasons why you didn't find an exact module for what you're trying to do. ProcessWire is more of a development framework and toolset than a plug-and-play CMS. It provides you easy access to a relational database, user and session management, querying, and front-end rendering through its API. As that's the case, much of what you want to do – create product records with categories and tagging, and query those records with those fields – can be done pretty easily with native PW functionality. A skeletal walk-through of how you might do this: Create a Product template in the admin. Create the fields you'd like for the Product – probably a Title, Body, Categories, and Tags. The last two could either be hard-coded (as a Select – more rigid) or relational (as a Page Reference/PageArray, using other Pages as data – more flexible). Create Pages with the Product template, and populate the data. Create a Product front-end template, /site/templates/Product.php (file shares the same name as your admin template name), with code like this: <h1><?=$page->title?></h1> <div class="body"> <?=$p->body?> </div> <div class="categories"> <?php foreach ($page->categories as $c): ?> <?=$c->value?> <!-- This is assuming your Categories are a simple Option fieldtype, without titles. --> <?php endforeach ?> </div> <div class="tags"> <?php foreach ($page->tags as $c): ?> <?=$c->title?> <!-- This is assuming your Tags are a Page Reference fieldtype. --> <?php endforeach ?> </div> Edit your front-end home template, /site/templates/home.php, and list some of your Products, maybe like this: <ul> <!-- List pages with Product template, limit results to 10 --> <?php foreach ($pages->find('template=Product, limit=10') as $p): ?> <li> <a href="<?=$p->url?>"> <?=$p->title?> </a> </li> <?php endforeach ?> </ul> That'll get you started with displaying and querying Pages. You might want to take a look at this article to better understand how Templates, Fields, and Pages relate to each other. E-commerce is one of the less well-represented areas of ProcessWire, but is 100% doable. The main bits that don't exist out-of-box are a shopping cart, order management, and the checkout process, but could definitely be built using PW. The module Padloper has both a cart and checkout process. You could get something mostly self-contained like Stripe or Snipcart running within a PW install in short order. Whatever the case, E-commerce in PW, and in fact most systems, will require some development and figuring out. Hope that helps!
  5. Super handy, thanks! I issued a pull request for more efficient query syntax, i.e. using prev() & next(). I have an install with 1700+ siblings and the admin clearly was getting bogged down. These changes fixed it.
  6. I've run into this issue a few times...extremely frustrating, until you figure it out, of course After some snooping I determined it has to do with mod_pagespeed's elide_attributes flag, which removes default values, i.e. <select multiple="multiple"> becomes just <select multiple>. Unfortunately, Inputfield asmSelect's JS hooks onto select[multiple="multiple"], and thus skips those elements when the value isn't explicitly set. Long story short, remove elide_attributes from ModPagespeedEnableFilters in pagespeed.conf, restart your web server, and it should work.
  7. Yep, you can. Again, Page Table fields return a normal PageArray, so you can manipulate them as such. You'd need to iterate over the Page Table field on the pages that have that field, i.e.: $query = "My string"; $results = $pages->find('template=page_with_content_block'); $content_block_results = new PageArray(); foreach ($page_results as $p) { // Find pages with content block field if ($p->page_table_test->find('body*="'.$query.'"')->count() > 0) { // Check if content blocks contain query $content_block_results->add($p); // Add to results } else continue; } // Render $content_block_results or combine with other results
  8. Your approach is slightly off – remember that the items in a Page Table field are actually pages. There's a few different ways you could do this, but here's how I've done it in the past, assuming the content blocks are children of the page: // Query normal pages $query = $sanitizer->text($input->get->query); $results = $pages->find('template!=content_block, title|body*="'.$query.'"'); // Query content blocks $content_blocks_query = [ 'template=content_block', // Template 'title|body*="'.$query.'"' // Fields ]; // Find parent pages of content blocks $content_block_results = new PageArray(); foreach ($pages->find( implode(', ', $content_blocks) ) as $p) { $content_block_results->add($p->parent); } // Combine results $results->import($content_block_results); // Render $results If you're talking about Page Table Extended's admin-side rendered HTML, it actually works independently of the normal templates. Take a look at the PageTable Render Layout Options, you can specify CSS and template files there.
  9. Sounds pretty similar to what someone else was asking. You can do something like this with Page Table or Page Table Extended:
  10. You can make content blocks with Page Table or Page Table Extended, to display on any page. Create a Page Table field. Create templates for each of your content blocks, assigning the necessary fields (PHP files not necessary for these). Configure your Page Table field to use those content block templates. Assign Page Table field to your front-end template (template.php). In template.php, iterate over the Page Table field, and use PHP switch() to display different HTML and field data based on the content block name. If you want to get fancy, configure Page Table Extended to display rendered HTML on the admin side (Display Output Options).
  11. You shouldn't need to touch index.php, unless you're doing something really unorthodox. Are you logged into the PW admin (assuming that resolves)? Verbose errors will be supressed if not. You also might check /site/assets/logs/ for an error log, or your server logs. Hope that helps! Welcome.
  12. Good idea, but 3.0.66 still produces the same error. Seems like this affects Page Table in particular, so I've moved the discussion to ProFields forum (protected content): https://processwire.com/talk/topic/14244-error-uncaught-error-class-languagespagefieldvalue-not-found-in-fieldtypetablefieldtypetablemodule1953/#comment-147372
  13. Hello, Has anyone else had issues with multi-lingual fields within Page Tables? I tried using a Text (Multi-Language) field, and it craps out on me on page save when trying to add an item: Error: Class 'LanguagesPageFieldValue' not found (line 1632 of [..]/site/modules/FieldtypeTable/FieldtypeTable.module) Running PW 3.0.62. Thanks!
  14. For some reason the script doesn't find anything for me when checking for the correct Fieldtype. $field->type instanceof FieldtypeImage and $field->type instanceof FieldtypeFile never returns true for any of my Image fields, but $field->type->name == "FieldtypeImage" does. My working validation loop looks like this: $valid = array(); foreach($page->template->fieldgroup as $field) { foreach($page->get($field->name) as $file) { $valid[] = $file->basename; if($field->type->name == "FieldtypeImage") { foreach($file->getVariations() as $f) { $valid[] = $f->basename; } } } } I'm running PW 3.0.42, PHP v5.5.27.
  15. I had the same issue in PW 2.7.2 and Lister 0.2.4. I tried swapping the Process of the Search page (/processwire/page/search/) , under Admin > Pages in the Tree to ProcessPageLister, and that seemed to fix it. You'll have to unlock the page to change the Process, and make sure the users' role has permission to use page-lister. Not sure why this happens. This is on an install that I've been upgrading since 2.5.3. It works without issue, and using ProcessPageSearch, on my newer, clean install of 3.0.42. Update: looks like it breaks the normal page search, so obviously not a good fix.
  16. Came across this issue today when trying to push a PW installation to an AWS server running PHP 5.6.29 on CentOS. File uploads weren't working with the same getConfigData() error, and front-end image sizing was delivering the same error. Turns out php-gd wasn't installed by default. Running sudo yum install php-56gd fixed it for me.
  17. Here's my solution for sorting pages by template, with a sort order: // Templates listed in sort order $templates = ['template1', 'template2', 'template3']; // Get pages with templates $results = $pages->find('field=value, template=' . implode('|', $templates)); // Sort results by template $resultsSorted = new \PageArray(); foreach ($templates as $t) { $resultsSorted->import($results->find('template=' . $t)); } // Reassign to $results $results = $resultsSorted;
  18. It's an error in my fix -- errant leading slash. You can pull down my branch until the pull request is accepted, or just correct it in your copy of your module. Replace line 55 in FieldtypeAdminCustomPagesSelect.php: 'path' => "/" . str_replace(wire('config')->paths->root, '', $file), // Make path relative with: 'path' => str_replace(wire('config')->paths->root, '', $file), // Make path relative Hopefully that works for you!
  19. I've encountered this bug a number of times when launching, finally got around to looking into it and submitted a pull request. Not the most elegant fix, but it seems to work. My fork is available here: https://github.com/deeplypixelating/pw-admin-custom-pages
  20. Seeing the same issue here in 2.6.0, MySQL version 5.5.42-37.1-log. Error is being generated by /wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module: if($createdVotesTable) try { $database->query("ALTER TABLE `$table` ADD `upvotes` $upvoteSchema"); $database->query("ALTER TABLE `$table` ADD `downvotes` $downvoteSchema"); $schemaVersion = 5; } catch(Exception $e) { $this->error($e->getMessage(), Notice::log); } Without any deep understanding of what's happening here, I assumed it just needs to check if the columns exist before adding them, so I added some logic based on some other column-checking code I found elsewhere in PW: $isUpvotes = $this->wire('database')->prepare("SHOW columns FROM `$table` LIKE 'upvotes'"); $isUpvotes->execute(); $isDownvotes = $this->wire('database')->prepare("SHOW columns FROM `$table` LIKE 'downvotes'"); $isDownvotes->execute(); if($createdVotesTable) try { if ($isUpvotes->rowCount() === 0) $database->query("ALTER TABLE `$table` ADD `upvotes` $upvoteSchema"); if ($isDownvotes->rowCount() === 0) $database->query("ALTER TABLE `$table` ADD `downvotes` $downvoteSchema"); $schemaVersion = 5; } catch(Exception $e) { $this->error($e->getMessage(), Notice::log); } This seemed to work, and it reported that the FieldtypeComments schema was updated from 0 to 5 -- not sure if this the desired outcome. The errors have stopped, although I have no clue if that's a good thing...! Also, just tried installing FieldtypeComments on my local machine running PW 2.6.0 and MySQL 5.5.39, and it seemed to work fine without this modification. My "fix" is probably not the right way about it, I'm guessing.
  21. The setColorspace() method doesn't exist on my server, as IM is too old (ImageMagick 6.5.4-7): Error: Call to undefined method Imagick::setColorspace() (line 16 of /path/to/public_html/site/modules/FieldtypePDF/PagePDF.php) When I use readFile(), I get the following error (not the real path, obviously): - Postscript delegate failed `/path/to/file.pdf': No such file or directory @ pdf.c/ReadPDFImage/611 From what I read this is common if you're using a pre-9.x version of GhostScript (server has 8.70). I haven't seen any visible quality issues with declaring the image with the Imagick object, but I also haven't been looking too carefully -- mostly glad to get it working at all.
  22. Not sure why this worked, but I had to modify the ImageMagick code in PagePDF.php a bit to get it working on GoDaddy shared hosting (I know, I know...): $imagick = new Imagick($this->filename . "[0]"); $imagick->setResolution(300, 300); $imagick->setOption('pdf:use-cropbox', 'true'); //$imagick->setColorspace(Imagick::COLORSPACE_RGB); //$imagick->readimage($this->filename . "[0]"); $imagick->setImageFormat('png'); $imagick->scaleImage($width, $height); $imagick->writeImage($filename); I believe it has to do with GoDaddy running old versions of IM and GhostScript, but I'm not certain.
  23. Sorry for the spaces -- it was written for clarity, not actual use, as you probably figured out. I was trying to hide and show checkboxes. A concat field is an interesting solution, I might try that. It would be neat if the selector could work for those fields, or if the field dependencies would allow an anonymous PHP or JS function that would return boolean. Not the biggest deal in my context, though. Thanks for the help!
  24. I'm actually trying to show or hide fields only if there's an image uploaded to the image field, not just collapse an empty image field, as you tried it. I'm not using a multi-language setup. I'm pretty sure it's not just a parse error, as other selectors also fail, such as: image_field != false image_field.count = 0
  25. Do field dependencies work on Image fields? I tried this selector, to show a field if there's an image: image_field.count > 0 ...and it didn't work. Any ideas? Thanks! -evan
×
×
  • Create New...