Jump to content

abdus

Members
  • Posts

    743
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by abdus

  1. You can group pages depending on a field and output them like this. I used `country` field, instead of `zipcode` but it doesnt change anything <?php namespace ProcessWire; $persons = $pages->find('template=person'); $grouped = []; foreach ($persons as $person) { $country = $person->country; if (isset($grouped[$country])) { $grouped[$country][] = $person; } else { $grouped[$country] = [$person]; } } ?> <?php foreach ($grouped as $country => $people): ?> <h2><?= $country ?></h2> <?php foreach ($people as $p): ?> <p><?= $p->title ?></p> <?php endforeach; ?> <?php endforeach; ?> Which outputs something like this
  2. He means the initial setup & configuration. Even before you set up your database. Like this one https://processwire.com/docs/tutorials/installation-moving-and-troubleshooting/page4
  3. I strongly suggest creating a template for the child pages as well. You might not have an issue at the moment, but a month from now, a year from now, when you need to change something, it won't be where you expect it to be. It'll be harder to maintain. I had to do a number of complete rewrites in the past because I was only complicating things for myself for no reason.
  4. abdus

    email

    Go to backend and edit home page
  5. abdus

    email

    Get it from the browser. On the contact page. Press CTRL + U to view page source
  6. abdus

    email

    What does contact page look like, can you copy paste HTML source, or check where its <form action=""> attribute points to? (Assuming it doesnt submit using JS) Maybe the form is in an iframe and mail operations are handled by a 3rd party service? Can you copy paste templates/log.php here?
  7. You're welcome. I'm glad your problem got solved. You're right, thanks for pointing that. I was reading the source for urlSegments just today. Gotta love @ryan's humor // ProcessPageView.module /** * Get the requested page and populate it with identified urlSegments or page numbers * * @return Page|null * */ protected function getPage() { $config = $this->wire('config'); $shit = isset($_GET['it']) ? trim($_GET['it']) : "/"; // dirty $it = preg_replace('{[^-_./a-zA-Z0-9]}', '', $shit); // clean unset($_GET['it']); if($shit !== $it && $config->pageNameCharset == 'UTF8') { $it = $this->wire('sanitizer')->pagePathNameUTF8($shit); } // ... while((!$page || !$page->id) && $cnt < $maxSegments) { $it = rtrim($it, '/'); $pos = strrpos($it, '/')+1; $urlSegment = substr($it, $pos); $urlSegments[$cnt] = $urlSegment; $it = substr($it, 0, $pos); // $it no longer includes the urlSegment $selector = "path=" . $this->wire('sanitizer')->selectorValue($it, 2048) . ", status<" . Page::statusMax; $page = $this->pages->get($selector); $cnt++; } // ... }
  8. abdus

    email

    Seach for `mail(` & `send(` inside the /site/templates/ folder
  9. abdus

    email

    Download the whole database and search for the email
  10. I'm not getting that behavior. I tired to replicate your setup. This is what I have ended up with (I use jobs instead of categories but it shouldnt matter) <?php namespace ProcessWire; // categories.routes.php if (input()->urlSegment2) throw new Wire404Exception(); if (input()->urlSegment1) { /** @var Pages $pages */ $name = sanitizer()->pageName(input()->urlSegment1); $match = $pages->findOne("template=profession, name=$name"); if (!$match->id) throw new Wire404Exception(); echo $match->render(); return $this->halt(); } This is my _init.php. It gets included to every template (after its routes, if exists) <?php namespace ProcessWire; require_once '_func.php'; $testPages = $pages->find('template=profession, limit=5'); And I use it inside actual page template that renders `category` page <?php namespace ProcessWire; ?> This is: <?= $page->title ?> <p>Other Pages:</p> <?php foreach ($testPages as $p): ?> <?= $p->title ?><br> <?php endforeach; ?> And both pages render correctly So, to me the only thing that seems missing is echo statement before $p->render() and return $this->halt(); after that EDIT: This is the backend structure, I am guessing you have a similar one. You get categories from another parent
  11. abdus

    email

    Do you know the exact email address that should have been getting those emails?
  12. abdus

    email

    start with field_email field and click select data If you cant find it, try other fields
  13. abdus

    email

    there's https://www.adminer.org/#download Put it in your root directory and access it from mysite.com/adminer.php You can find database credentials in /site/config.php
  14. abdus

    email

    There shouldnt be too many of it. (Unless the developer annotated everything with PHPDocs)
  15. abdus

    email

    Hmm that looks quite outdated. My suggestions may not even exists in your version. Also the module list seem to include only core modules. Since you have the sources, can you download /site/templates and /site/modules folders and search all files for @ symbol?
  16. abdus

    email

    It might be specified in a module's settings. Seach for one with wiremail / contact or a similar name Check Setup > Fields, any fields with names related to email? If there is one, from top menu go to Pages > Find and pick that field and fill your email to value field Also, do you have access to source files?
  17. URLs are generated from page names by default. What I'm trying to show is that you dont have to use IDs for page names, otherwise when generating URLs you'd get /codes/123 instead of /codes/wall-mounted-light. Below is a sample template that should work in your case <?php namespace ProcessWire; /** @var Pages $pages */ /** @var Sanitizer $sanitizer */ /** @var Page $child */ $child = null; if ($input->urlSegment1) { $codeChildName = "code--{$input->urlSegment1}"; $codeChildName = $sanitizer->pageName($codeChildName); $child = $pages("parent=$page, name=$codeChildName"); if (!$child->id) throw new Wire404Exception(); } ?> <div class="code-page"> <?php if ($child): ?> <!-- RENDER CHILD PAGE --> <h1>Child: <?= $child->title ?></h1> <?= $child->body ?> <?php else: ?> <!-- RENDER CODE PAGE WITH CHILDREN --> <h1><?= $page->title ?></h1> <?= $page->body ?> <h2>List of children:</h2> <ul class="chilren"> <?php foreach ($page->children as $c): ?> <?php $childUrl = "./$c->name"; // generate urls for the child ?> <li class="child"> <a href="<?= $childUrl ?>"><?= $c->title ?></a> </li> <?php endforeach; ?> </ul> <?php endif; ?> </div> I also concur with @bernhard. If you're modifying the core behavior and rendering child page at the url that matches the child's, then I'd say you should reconsider your approach. You're only complicating it for yourself. Also, thanks, I'm doing what I can. These questions are like quizzes that I enjoy solving, and get to practice coding with PW.
  18. If pages are not public, then you wouldnt need to worry about SEO. Page name format works for pages created in the future, but for the current pages you can do: $codes = wire()->pages('template=code'); foreach ($codes as $c) { // wall-mount-mini-split becomes code--wall-mount-mini-split $replacement = "code--{$c->name}"; $c->of(false); $c->setName($replacement); $c->save(); } And in your template, where you check urlSegments: if($input->urlSegment1) { if ($input->urlSegment2) throw new Wire404Exception(); $codeName = "code--{$input->urlSegment1}"; $codeName = $sanitizer->pageName($codeName); $code = $pages("template=code, name=$codeName"); if(!$code->id) throw new Wire404Exception(); // do sth with the code page }
  19. You can 'namespace' children pages from the family settings of the parent template i.e. prefix all pages with a certain phrase etc. to eliminate false positives http://processwire.com/api/modules/process-template/
  20. What you need to do is basically: Get a list of pages with limit for pagination $pages->find('template=post, limit=10, sort=-published'); Render a list of items Render the pagination at the bottom of the page Using JS listen to scroll event, and trigger AJAX request Get the response, filter the list of elements, replace the container that holds the old items Repeat As a different approach, you can implement barba.js for PJAX (ajax with history support) (and limit it to only pagination links, if you prefer), and trigger click() on the next pagination link when it gets closer to viewport. For that you can use scrollMonitor.js. Total weight of these two scripts are under 15KB, they don't add much load on the page. One bonus is that you can enable barba.js on all (internal) links (it's enabled by default) to make transitions between pages feel more responsive.
  21. During boot, inside /site/config.php $page is not yet determined, so I am limited in determining what to prepend/append. For this reason I disable $config->prependTemplateFile (& append) and use a 'controller' hook like this. wire()->addHookBefore('TemplateFile::render', function (HookEvent $event) { // skip if AJAX if ($event->config->ajax) return; /** @var TemplateFile $templateFile */ $templateFile = $event->object; // Skip admin pages if (strpos($event->input->url, $event->config->urls->admin) === 0) return; // check if this is a partial template, if so, stop $fileDir = pathinfo($templateFile->get('filename'), PATHINFO_DIRNAME); $templatesPath = $event->config->paths->templates; if (realpath($fileDir) !== realpath($templatesPath)) return; $templateName = $templateFile->page->template->name; $prepends = [ 'routes' => $templatesPath . "{$templateName}.routes.php", 'before' => $templatesPath . "_before.php" // like your _init.php ]; // then comes the actual template file $appends = [ 'view' => $templatesPath . "views/{$templateName}.php", 'after' => $templatesPath . "_after.php", 'layout' => $templatesPath . "layouts/main.php" ]; foreach ($prepends as $name => $file) { if (file_exists($file)) $templateFile->setPrependFilename($file); } foreach ($appends as $name => $file) { if (file_exists($file)) $templateFile->setAppendFilename($file); } }); So to adapt this to your setup, you can define your urlSegments inside template.routes.php, and stop further appends with return $this->halt(). This way only template.routes.php is loaded and remaining appends are skipped while still allowing PW to complete its shutdown.
  22. @cjx2240, I'm not sure if this is the best way, but hey it works. Put this in your /site/ready.php wire()->addHookBefore('Page::render', function (HookEvent $e) { // requested page (not the one being rendered) $page = $e->page; // skip admin pages if (strpos($e->input->url, $e->config->urls->admin) === 0) return; // force redirect to homepage if ($page->id != 1) { $e->session->redirect('/'); } }); And in your home template, put this at the beginning <?php namespace ProcessWire; $splashPage = $pages->get(1353); echo $splashPage->render(); return $this->halt();
  23. You can use a selector like this to seach among children and siblings: (use has_parent=$page to search in deeper children) $myPages = $pages->find("(parent=$page->parent, template=X), (parent=$page, template=X)"); https://processwire.com/api/selectors/#or-groups
  24. $page->closest() method works only on parents (including $page). If $page doesn't have a parent with template X, youll get a NullPage. From the docs: /** * Find the closest parent page matching your selector * * This is like `$page->parent()` but includes the current Page in the possible pages that can be matched, * and the $selector argument is required. * * #pw-group-traversal * * @param string|array $selector Selector string to match. * @return Page|NullPage $selector Returns the current Page or closest parent matching the selector. Returns NullPage when no match. * */ public function closest($selector) { if(empty($selector) || $this->matches($selector)) return $this; return $this->parent($selector); }
  25. Enable $config->debug = true to load non-minified version of ProcessPageList.js, maybe it can give you more clues
×
×
  • Create New...