Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/23/2021 in all areas

  1. Pleased it worked ? Whether you set output formatting inside or outside the loop shouldn't affect the issue – though inside would waste a few processor cycles! I've done some tests, and the issue is a result of page->save() not working for custom image fields. Saving the image field (inside or outside the loop) is necessary to save the content of the image custom fields. Saving the page (inside or outside the loop) does nothing for the image custom fields. It seems to me that saving the page should work as it does with other fields, and I have reported this as an issue https://github.com/processwire/processwire-issues/issues/1334 However, there may be a good reason for it behaving as it does, and it has been pointed out on the issue page that the Table Profield behaves in the same way.
    2 points
  2. @BillH Man, you saved my live. I had a nightmare last night, seeing myself migrating dozens of entries manually but your code came to the rescue. It works! Here is my code: page()->of(false); foreach (page()->images as $image) { $image->artist_name = $page->title; if($image->description): $image->title = $image->description; $image->image_caption = $image->description; endif; // first save inside loop saves the field value $page->save('images'); } // saves the page $page->save(); Yesterday I had the output formatting statement inside the loop and I assume this was the mistake. Thanks for helping me!
    2 points
  3. Hi, I have this working line to find a specific image. $banniere = $pages->get(1)->images->findTag('banniere')->getTag($user->language->name); But now, I want to add getRandom(). I tried different versions $pages->get(1)->images->findTag('banniere')->getTag($user->language->name)->getRandom() $pages->get(1)->images->getRandom()->findTag('banniere')->getTag($user->language->name) but always received this error : Method Pageimage::getRandom does not exist or is not callable in this context. Is it compatible? How I can do that? Thanks! Mel EDIT : solved by myself. Error I commonly do, mixing up get() and find()... Sorry for the disturbance. $banniere = $pages->get(1)->images->findTag('banniere')->findTag($user->language->name)->getRandom();
    2 points
  4. From the recent discussion about the roadmap & wishlist for 2021 and some other posts by @ryan, it comes to my mind that developing and coordinating the whole project for one person is becoming harder and harder and leads nearly to the reverse of expanding the ProcessWire ecoysystem. This is not against Ryan, i think everyone here knows how engaged he is about ProcessWire, but he has only 24/7 (sometimes i think he's got far more than that...). We as the community could support the project (financially) to relieve Ryan and could take over some tasks from him. This could be, but is not limited, to: Building a Foundation/Association/Company to ensure the persistence of the project and to fund the work put in ProcessWire of Ryan (and others). Nearly every other CMSs i checked has something like this (Drupal Association, Typo3 Association, Joomla Foundation, Wordpress Foundation, Contao Association, ...). This also puts more trust in the project, if someone new will check on his engagement in ProcessWire. Assigning persons/teams to work on things: Extending the core (when necessary) Developing and maintaining major modules (e.g. page builder, admin themes, internationalization, marketing, ecommerce system, ...) Testing and inspection of modules developed by others Making translations of modules (translation of the core is mostly covered, i think) Working on PRs & issues submitted on github Working on the homepage Coordinating the community efforts I know, some resorts are already covered by others (e.g. @Pete for the forum, @horst for images, ... ), but there are many other areas where this ist not the case. By joined efforts by the ProcessWire community this hopefully will also attract new developers to the system and by a growing number of users this assists in the things above in a circular process. What do you think?
    1 point
  5. Of course - that works perfectly, thank you!
    1 point
  6. If you're using non-core inputfields beyond those described in the module readme it will be a case of "your mileage may vary" and I can't really offer support for those kinds of cases. I suggest just using a normal InputfieldSelect and setting the options from files in Files field(s) on the page, or via $files->find()/DirectoryIterator/glob.
    1 point
  7. @Ben Sayers: Hey Ben, that's what I meant - simply including _uikit.php won't do the job. The whole templates are built using UIKit CSS framework. You'll need to write your own templates for product overview and product-details. If you have a look at the two sample templates which are installed by SnipWire installer, you will see how it works. Please have a look at the comments in the php files. I currently don't have the time to write sample code based on your rendering method. But if you are familiar with ProcessWire development this should be an easy job. Having a look at the snipcart-shop template, all in all, that's all you need: (please note this is a quick composition of the required code and might not fully work. And you need to use your own CSS classes based on your framework) <!-- The content element holds your products catalogue. --> <div id="content"> <?php $products = page()->children('limit=9'); echo productOverview($products); ?> </div> <?php /** * Render a shop product overview * * @param PageArray $products * @return string * */ function productOverview(PageArray $products) { if (!$products->count) return ''; $out = '<div class="product>'; foreach ($products as $product) { // We use the first image in snipcart_item_image field for demo $imageMedia = ''; if ($image = $product->snipcart_item_image->first()) { $productImageMedium = $image->size(600, 0, array('quality' => 70)); $imageDesc = $productImageMedium->description ? $productImageMedium->description : $product->title; $imageMedia = '<img src="' . $productImageMedium->url . '" alt="' . $imageDesc . '">'; } else { $imageMedia = '<div title="' . __('No product image available') . '">' . ukIcon('image', array('ratio' => 3)) . // you need to use your own image output function here because ukIcon is based on UIKit CSS '</div>'; } // This is the part where we render the Snipcart anchor (buy button) // with all data-item-* attributes required by Snipcart. // The anchor method is provided by MarkupSnipWire module and can be called // via custom API variable: $snipwire->anchor() $options = array( 'label' => ukIcon('cart'), // use your own image output function 'class' => 'button button-primary', 'attr' => array('aria-label' => __('Add item to cart')), ); $anchor = wire('snipwire')->anchor($product, $options); // Get the formatted product price. // The getProductPriceFormatted method is provided by MarkupSnipWire module and can be called // via custom API variable: $snipwire->getProductPriceFormatted() $priceFormatted = wire('snipwire')->getProductPriceFormatted($product); $out .= '<a href="' . $product->url . '">' . '<div class="product-detail">' . '<div class="media-top">' . $imageMedia . '</div>' . '<div class="card-body">' . '<h3 class="card-title">' . $product->title . '</h3>' . '<p>' . $product->snipcart_item_description . '</p>' . '</div>' . '<div class="card-footer">' . $anchor . '<span class="align-right text-primary">' . $priceFormatted . '</span>' . '</div>' . '</div>' . '</a>'; } $out .= '</div>'; return $out; } ?>
    1 point
  8. This thread isn’t my place at all, but Gadgetto’s post you quoted tells me you need to copy the file _uikit.php from the regular site profile and somewhere at the top of your own template call include_once('./_uikit.php');. Should be a safe fix for that specific error.
    1 point
  9. Hi Adrian thanks for your quick reply. I will check that and let you know. You are right, why ever this was active. Thanks again!
    1 point
  10. Hi @bbeer - sounds like you have duplicate entries for sqlite3.so in your php.ini file.
    1 point
  11. I did this a few weeks ago and I got it to work. I seem to remember I had a certain amount of trouble saving the record, but I can't remember what exactly. However, the following code worked (I've simplified getting the text to add to the image fields). Note that I've done something a bit weird and saved both the field and then the page. This might have been an error (I was running a one-off process), or I might have found it was necessary for some reason I don't understand. It may just be that saving the field is what does the trick. Also, for reasons of my own, I used $record as a page variable, but I don't see why this would matter. Otherwise, I can't see any difference between this and your code. foreach($selectedRecords as $record) { if(count($record->article_images)) { $record->of(false); foreach($record->article_images as $image) { $image->photo_caption = "Some caption text"; $image->photo_credit = "Some credit text"; // First save $record->save('article_images'); } // Second save! $record->save(); } } Hope this helps, and I'd be interested if you find this works and can figure out what actually fixes the problem.
    1 point
  12. I'm pretty sure that aforementioned issue is now fixed in all the branches — but yes, you're correct, 2.0 branch is deprecated and the ones that are maintained — sort of — are dev (2.x) and master (1.x) ?
    1 point
  13. If done correctly I think that could be a great plus for ProcessWire! And I'd be happy to be part of such an association ?
    1 point
  14. I'm using ProcessWire all the time for Backend-only applications. Sometimes I also feel like I'm using it in a "wrong" way... But sometimes it seems that there are more people using PW for database applications. I think it is a great tool for such scenarios - I have to admit though that I did not try any others. What's really missing is a way to present tabular lists. That's why I created RockGrid/RockTabulator/RockFinder. RockFinder3 is a great product, while RockGrid/RockTabulator is better than nothing but I'm working on a better solution ? I don't get your problem though... What's wrong with a list like this? id | forename | surname | address | name 1 | john | doe | exroad123 | 1 2 | john | doe | exroad234 | 2 3 | maria | müller | musterweg | 3 I tend to use the title field for a representation of the page that can be used easily on page lists etc: id | title | forename | surname | address | name 1 | john doe (exroad123) | john | doe | exroad123 | 1 2 | john doe (exroad234) | john | doe | exroad234 | 2 3 | maria müller (musterweg) | maria | müller | musterweg | 3 That's a simple saveReady hook. I'd recommend using custom page classes a lot for such setups. It keeps the code clean and a lot easier to maintain. You'll also get the benefit of code completion in your IDE and your hooks will get a lot cleaner, easier and better maintainable as well: // in site/init.php or an autoload module $contact = new Contact(); $contact->init(); // in site/classes/Contact.php <?php namespace ProcessWire; class Contact extends Page { public function init() { $this->addHookAfter("Pages::saveReady", $this, "setTitle"); } /** * Get page title based on other fields * @return string */ public function getTitle() { return $this->forename." ".$this->surname." ({$this->address})"; } public function setTitle(HookEvent $event) { $page = $event->arguments(0); if(!$page instanceof self) return; $title = $page->getTitle(); $exists = $event->pages->get([ 'template' => $page->template, 'title' => $title, 'id!=' => $page->id, ]); if($exists->id) { // page exists, show error message and do whatever is necessary } else { $page->title = $title; } } } Code completion will help you a LOT when the project grows... Combine that with RockMigrations and you feel like you got superpowers. At least I do ?
    1 point
  15. Hey, I found two vinyl albums of the group Tuxedomoon from the early eighties. If someone knows them and like to get them, please drop me a note. (for the shipping cost) 1) TUXEDOMOON - "Half Mute / Scream With a View", (1980) 2) TUXEDOMOON - "A thousand lives by pictures", (1983) 25 years back, I moved from Vinyls to CDs. Over the years I gave away all vinyls, only kept a number of around 50 pieces that I initially wanted to digitize. But I do not hear this music any more and never missed it. Also there were some more or less rare vinyls I really digitized, maybe 10 albums, but for all others it definetly is to much work. ?
    1 point
  16. If you need redirecting to the final domain name, you may have a look to this snippet. But you have to add it manually somewhere in the top of your root .htaccess file. ################################################################################ # Domain-Namen erzwingen # <IfModule mod_rewrite.c> RewriteEngine On AddDefaultCharset UTF-8 RewriteCond %{HTTP_HOST} ^example\.com [OR] RewriteCond %{HTTP_HOST} ^example-variation\.com [OR] RewriteCond %{HTTP_HOST} ^www\.example-variation\.com RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] RewriteCond %{HTTPS} !=on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </IfModule> # ################################################################################
    1 point
×
×
  • Create New...