• Content count

  • Joined

  • Last visited

  • Days Won


abdus last won the day on October 16

abdus had the most liked content!

Community Reputation

1,003 Excellent


About abdus

  • Rank
    Hero Member

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    Istanbul, Turkey
  • Interests
    Web development, gymnastics, photography

Recent Profile Visitors

1,639 profile views
  1. Check out Video Fieldtype Keep in mind that it requires ffmpeg installed on your server, so that might not be ideal.
  2. Storing it as text is fine if you're not performing numeric operations on DB, But you can copy /wire/modules/Fieldtype/FieldtypeInteger.module to /site/modules and open up the file, find and change getDatabaseSchema() from public function getDatabaseSchema(Field $field) { $schema = parent::getDatabaseSchema($field); $schema['data'] = 'int NOT NULL'; return $schema; } to public function getDatabaseSchema(Field $field) { $schema = parent::getDatabaseSchema($field); $schema['data'] = 'BIGINT NOT NULL'; return $schema; } Once you refresh module list from Modules > Refresh, it'll ask you which version to use, pick the one under /site/modules Then create a new integer field, it will be set up as BIGINT in DB.
  3. Why not store them under admin? It will be out of your sight and users without superuser permission will not be able to see the pages under admin. Thats how PW stores repeater items, too.
  4. Check out this tutorial by @kongondo, under Simple Multiple Categories
  5. A simpler way could be passing a second parameter to $pages->count() method like this $count = $pages->count('id>0', ['getTotalType' => 'calc']); // default, slower, fetches everything then counts $count = $pages->count('id>0', ['getTotalType' => 'count']); // uses SQL query, faster From the core: Results:
  6. You need to get regular PHP arrays (from any WireArray descending object, i.e. all PW collections) using $arr->getArray() if (in_array("1", $user->trader_type->getArray())) { echo "found!"; } https://processwire.com/api/ref/wire-array/get-array/
  7. Once PW fetches pages from DB, it saves them to memory, meaning subsequent find() operations with the same selector don't really have an effect, so it's essentially one DB operation. // PagesLoaderCache.php * Cache the given selector string and options with the given PageArray * * @param string $selector * @param array $options * @param PageArray $pages * @return bool True if pages were cached, false if not * */ public function selectorCache($selector, array $options, PageArray $pages) { // get the string that will be used for caching $selector = $this->getSelectorCache($selector, $options, true); // optimization: don't cache single pages that have an unpublished status or higher if(count($pages) && !empty($options['findOne']) && $pages->first()->status >= Page::statusUnpublished) return false; $this->pageSelectorCache[$selector] = clone $pages; return true; }
  8. It should've worked. $images->count is 1 when there's a single image, so --$page->randomIndex >= 0 returns true. But when there are multiple images but none matches 'inline-body' tag, then $images->count is 0 and --$page->randomIndex >= 0 returns false. Edit: If you use >= -1, the last image may be shown twice. Because when randomIndex reaches 0 (i.e. all images have been shown), it will return true with --$page->randomIndex >= -1 at the next hanna tag.
  9. I'm guessing for image fields with single image, where $page->images returns Pageimage instead of Pageimages? Then you can use getUnformatted() method: <?php // Hanna Code template if (!$page->randomImages) { $images = $page->getUnformatted('images'); // always returns PageImages array if ($images->count > 1) $images = $images->findTag('inline-body')->shuffle(); $page->randomImages = $images; $page->randomIndex = $images->count; } if (--$page->randomIndex >= 0) { // as per @Robin S's suggestion: // $img = $page->randomImages[$page->randomIndex]; $img = $page->randomImages->eq($page->randomIndex); echo "<img src='$img->url'/>"; }
  10. So far I haven't considered subscribing new users by creating a native user. I've integrated 4 services (MailChimp, Mailgun, Sendgrid, SparkPost) that allows subscription lists (recipient list/contacts/mailing lists,,, each with its own set of terminology, ugh) and a new subscriber is added to these lists. I think using these services in conjunction with @justb3a's could be better, in that I can hook into NewsletterSubscribe module and add the new user with `newsletter` roles to an one of the lists. Or simply, I could add an option to monitor user creation and add/remove when that user to a list if the user matches a certain selector. However, though very unlikely, there could be some issues with networking / API reliability and sending a request to add/remove the subscriber may fail. Not sure how I can deal with syncing issues, except maybe retrying it LazyCron etc. Mailer services are individual modules extending a base module so that I can combine all under ProcessMailer. But, they all can be used in isolation (with public methods, hooks etc). As for each being WireMail modules, I realized yesterday that to send emails via these services, service modules have to extend WireMail to some degree, so that's what I'll go with. But it would also mean I'd have degrade my base module into an interface and duplicate a good chunk of code. This would remove majority of the coupling between ProcessMailer and its services to the degree that I could release them one by one, rather than all packed under ProcessMailer. But it will postpone the release by at least a few weeks. Another option is that I could allow injection of a WireMail object as a parameter into one of the methods and modify the objects to suit service APIs, instead of converting them into individual WireMail modules. <?php namespace ProcessWire; public function ___sendEmail(WireMail $mail) { // modify $mail or extract relevant info and post it to mailer service $to = $mail->to(); $from = $mail->from(); // ... $this->send($apiEndpoint, $data); } // =========== $mail = new WireMail(); $mail->to(...) ->from(...) ->subject(...) ->bodyHTML(...); $list = 'newsletter@example.com'; $modules->MailerServiceMailgun->sendEmailToList($mail, $list);
  11. @DaveP's module can be useful for this. It can be extended for other verbs and providers too.
  12. The last ipsum you'll ever need: http://meettheipsums.com/
  13. Hmm. looking at your selector, you seem to be using `blog-entries` template for category pages. The exact solution will depend on how you configured your tagging system, but assuming you've used a Page Reference field called `category` limited to categories with `blog-entries` template, then you can use: // inside category template file // $page will point to a page with category template $categorized = $pages->find("template=blog-post, category=$page"); // ^ this will give you all pages with template blog-post whose category field include current page, (current category) // i.e. all posts under current category foreach($categorized as $post) { echo $post->title . '<br>'; } There's a tutorial by @kongondo which covers multiple scenarios and strategies for categorization, it's a must read for beginners.
  14. Where you put the rule matters. Let's try it differently. Remove the previous line and find 15. Access Restrictions section, and change its end from this # Block all http access to the default/uninstalled site-default directory RewriteCond %{REQUEST_URI} (^|/)site-default/ # Block all requests to WP specific files starting with wp- RewriteRule ^.*$ - [F,L] into this # Block all http access to the default/uninstalled site-default directory RewriteCond %{REQUEST_URI} (^|/)site-default/ [OR] # <------- REMEMBER TO ADD [OR] FLAG # Block all requests to WP specific files starting with wp- RewriteCond %{REQUEST_URI} (^|/)wp-.*\.php$ # If any conditions above match, issue a 403 forbidden RewriteRule ^.*$ - [F,L] This one blocks all requests ending with wp-xxxx.php and works great on my setup. (Previous method works, too)
  15. Filecompiler should have taken care of that Add namespace to the first line: <?php namespace ProcessWire;