Jump to content

abdus

Members
  • Posts

    743
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by abdus

  1. Shit, my bad, sent another PR https://github.com/horst-n/WireMailSmtp/pull/10
  2. This is one of my scripts that I use to quickly regenerate caches when I flush them. It wont work for dynamically generated urls (i.e. urlSegments), obviously <?php use ProcessWire\ProcessWire; require_once 'vendor/autoload.php'; $wire = new Processwire(); // get urls for all public accessable pages $urls = []; foreach($wire->pages('id>0, check_access=1') as $p) $urls[] = $p->httpUrl; header("Content-Type: text/plain"); // visit all urls foreach($urls as $url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); if(! curl_errno($ch)) { $info = curl_getinfo($ch); curl_close($ch); echo 'URL: ' . $url . "\n" . 'Status: ' . $info['http_code'] . "\n"; sleep(0.5); } else { echo 'ERROR: ' . $url . "\n"; } } Save this in the same directory as index.php, such as cache.php then access it from mydomain.com/cache.php. It might take a while before anything to appear until output buffer is flushed to the browser.
  3. It could be. You'd normally get an error/warning saying function is already defined, though.
  4. Hmm, on second look, I don't have your issue, it works fine in my setup. Compiled file doesn't have the namespace prefix. You problem might be caused by something else.
  5. You can add pages using page objects or page ids, but can only remove them using page objects. A bit inconsistent, to be honest. So you need to do $u->projectmanagers->remove($pages->get(1044)); From the core: // PageArray.php public function add($page) { // ... } else if(ctype_digit("$page")) { $page = $this->wire('pages')->get("id=$page"); if($page->id) { parent::add($page); $this->numTotal++; } } return $this; } public function remove($key) { // if a Page object has been passed, determine its key if($this->isValidItem($key)) { $key = $this->getItemKey($key); } if($this->has($key)) { parent::remove($key); $this->numTotal--; } return $this; } Edit: I created a feature request
  6. Hmm, I think FileCompiler is confused with case-insensitivity of some PHP keywords. It shouldn't try to prefix that. I'll create an issue report and post it here. Edit: Which version of PW are you using?
  7. It sounds like an issue with FileCompiler; it's adding/failing to add namespace prefixes to where it shouldn't. But, I don't see anything on line #678 that could be prefixed. What do you have there in compiled (site/assets/cache/FileCompiler/site/modules/WireMailSmtp) and noncompiled (site/modules/WireMailSmtp) versions?
  8. Checking for empty value is usually enough $emptyPages = $pages->find("myField=''") // note the empty string with single quotes $filledPages = $pages->find("myField!=''")
  9. You'd have to represent each reaction (e.g. seen, read) using a Page with a user (Page Reference) and a timestamp field (using `created` may suffice) and relate it to an action (e.g. X posted a new picture). Using simple image fields for storing images probably wouldn't be enough. Because images now have to hold a lot more data than they were designed for (when was this image posted, who reacted to it, what was the reaction). You'd need a more complex data structure (using Pages and fields, or custom fieldtypes) to represent all actions, reactions and events. In short: it's not trivial. Or I'm making this complicated in my head.
  10. Send AJAX requests to poll the server for updates. Easy to implement but puts strain on the server. Use long polling (reply to a request only when there's an update on the server). A bit more difficult, but fewer unnecessary requests. Use websockets (Socket.io, Pushy for push notifications) or SSR (server sent events). Ideal, but a bit more involved to implement.
  11. https://modules.processwire.com/modules/textformatter-pagination/
  12. Yes. Try exporting in portions. Or better yet, export your database, import to production, copy over files, modify config.php and you're done.
  13. Hmm. I thought you had a <select> that visitors used to filter pages by templates. For pages, $pages->find('id>0')->sort(['template.label', 'template.name']) this one sorts by label, and sorts unlabelled templates by name, but unlabelled templates come after the labelled ones.
  14. This one seems to work fine for me $sorted = $templates->find('id>0') ->sort('label') // sort by label ->explode(['label', 'name']); which gives array (51) 44 => array (2) label => "Blog" (4) name => "blog" (4) 76 => array (2) label => "Blog Section" (12) name => "section-blog" (12) 49 => array (2) label => "Categories" (10) name => "categories" (10) 57 => array (2) label => "Contact" (7) name => "contact" (7) 73 => array (2) label => "Hero Section" (12) name => "section-hero" (12)
  15. Find gives you multiple pages (actually a PageArray with zero or more pages) , and respects page status, whether it's hidden and access settings, while get gives you the page (a Page/NullPage object) disregarding access preferences. To find pages created by a particular user, you need $myUser = $users->get('admin'); $myPages = $pages->find("created_users_id=$myUser");
  16. I'm trying to wrap my head around your page structure, is it something like this? Can you post a screenshot? $page | +--t3Cities_list +--t3Cities_list | +--tags_template | | | +--tag | +--tag | +--tags_template | +--tag +--tag I've cleanup your code, and what does $getCities do? Are you listing`t3Cities_list` pages and their tags (depending on checkboxes) <?php namespace ProcessWire; /** @var $page Page */ $getCities = $page->find("template=t3Cities_list"); ?> <?php foreach ($getCities as $city): ?> <?php foreach ($city->tags as $get): ?> <?php $getTags = $page->get("template=tags_template, include=hidden")->children("sort=title, tag_code={$get->title}"); ?> <div class="grid-masonry"> <div class="grid-sizer"> <?php foreach ($getTags as $tag): ?> <div class="grid-item"> <a href="<?= $tag->url ?>" class="img-hovered"> <div class="overlay"><span><?= $tag->title ?></span></div> <img src="<?= $tag->categorythumb->url . $tag->categoryThumb ?>" alt="" class="img-responsive"> </a> </div> <?php endforeach; ?> </div> </div> <?php endforeach; ?> <?php endforeach; ?>
  17. I'm thinking you dont actually get $product using $pages->get('id=' . $product). Do you have Tracy Debugger installed? What does var_dump($product) give you, before and after you override it? <?php foreach($order->order_products as $product): ?> <?php $product = $pages->get("id=" . $product); ?> <tr> <td><?php echo $product->title; ?>test</td> </tr> <?php endforeach; ?>
  18. Check out Video Fieldtype Keep in mind that it requires ffmpeg installed on your server, so that might not be ideal.
  19. 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.
  20. 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.
  21. Check out this tutorial by @kongondo, under Simple Multiple Categories
  22. 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:
  23. 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/
  24. 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; }
×
×
  • Create New...