Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by abdus

  1. Change this line to <?php namespace ProcessWire; With v3.0, all global functions are now under ProcessWire namespace, so you need to either declare namespace at the top or prefix function calls (\ProcessWire\wire() for instance)
  2. Not yet, I'll update the post once I get the alpha version ready.
  3. There's invisible recaptcha that only shows up in case of suspected bot activity https://developers.google.com/recaptcha/docs/invisible
  4. Use $e->object->hasPage property // Inputfield.php * @property null|bool|Fieldtype $hasFieldtype The Fieldtype using this Inputfield, or boolean false when known not to have a Fieldtype, or null when not known. #pw-group-other * @property null|Field $hasField The Field object associated with this Inputfield, or null when not applicable or not known. #pw-group-other * @property null|Page $hasPage The Page object associated with this Inputfield, or null when not applicable or not known. #pw-group-other
  5. That would be up to 3rd party services (almost all services support some type of tracking) or developer (by creating trackable links, 1x1px tracking gifs etc)
  6. Hook into Pages::saveReady instead and throw error inside checkMethod()
  7. Enable debug mode in site/config.php. You're probably getting an error that's preventing PW to complete page render.
  8. Keep it simple. There are dozens of JS libraries out there that generate table of contents for you. Google "jquery toc"
  9. If you can find a .edu email, you can use it for free.
  10. I'm not sure if your editor highlights variables inside strings, but PhpStorm, for instance, makes it really easy to spot the difference. Check your editor/highlighting settings, there might be an option to enable it. And yeah, tunnel vision is definitely real.
  11. I may be wrong but the problem is most likely due to this line. With single quotes, $evName is interpreted literally, so you get errors trying to create the same page again, and don't notice it because you probably have the debug mode off as @Robin S pointed out. Also, <?php namespace ProcessWire; foreach ($events as $event) { // you don't have to manually clean up strings to create page names, just use $sanitizer $evName = $sanitizer->pageName($event['name']); $p = $pages->get("/events/$evName/"); if (!$p->id) { $p = new Page(); $p->template = 'basic-page'; $p->parent = '/events/'; // $p->name = '$evName'; // single quotes -> interpreted as literal string $p->name = $evName; } $p->of(false); $p->title = $event['name']; $p->save(); } ?>
  12. Ok, so if I understand it right, you want to force user to pick a template. I'm not sure if this fits your needs but with a bit of JS and hooks you can remove default value and set the template select required (with `required` html attribute), such that you cant get to the next step without deliberately picking a template wire()->addHookAfter('ProcessPageAdd::buildForm', function (HookEvent $e) { /** @var InputfieldForm $form */ $form = $e->return; $form->add([ 'type' => 'markup', 'value' => '<script>document.querySelector("[name=template]").selectedIndex = -1;</script>' ]); $template = $form->getChildByName('template'); if ($template) $template->attr('required', 1); });
  13. Check out field rendering https://processwire.com/blog/posts/processwire-3.0.7-expands-field-rendering-page-path-history-and-more/#field-rendering-with-template-files
  14. abdus

    Hanna Code

    Assuming _func.php is under templates folder, you need to include _func.php in your hanna code like this: <?php include_once $config->paths->templates . '_func.php'; echo "<div class=\"grid_xs-1\">"; foreach ($pages->find("template=property") as $properties) { // ...
  15. https://processwire.com/talk/topic/6196-easy-search-on-pw-forums-with-google/?tab=comments#comment-60632 https://processwire.com/talk/topic/6196-easy-search-on-pw-forums-with-google/?do=findComment&comment=153343
  16. Turn them into links. Make sure to have no spaces in the phone number (inside href) <a href="tel:05345345345">Call Us!</a> To remove the spaces from a given phone number you can use: $spaced = ' 345 345 234 '; $clean = preg_replace('!\s+!', '', $spaced); $telUrl = "tel:$clean";
  17. You don't have to delete it, but if you're not using composer, there's no reason to keep it.
  18. Unless that's a typo you shouldn't have that dollar sign there.
  19. You can iterate over matches pages and group them in an array: <?php $matches = $pages->find('title~=' . $q . ', template=speech-archive-detail|training-detail, sort=template'); $grouped = []; foreach ($matches as $m) { // you can use template->label, too $grouped[$m->template->name] = isset($grouped[$m->template->name]) ? $grouped[$m->template->name] : []; $grouped[$m->template->name][] = $m; } // sort by template name ksort($grouped); ?> <?php foreach ($grouped as $templateName => $matches): ?> <?= $templateName ?>: <br> <?php foreach ($matches as $match): ?> <?= $match->title ?> <?php endforeach; ?> <?php endforeach; ?>
  20. I had a tutorial about this here. Using the hook below you can move template select into content tab before the title. Keep in mind your editors should be able to change templates for your event templates. wire()->addHookAfter('ProcessPageEdit::buildForm', function (HookEvent $e) { // make sure we're editing a page and not a user if ($e->process != 'ProcessPageEdit') return; $page = $e->object->getPage(); // does page template start with event_? if (strpos($page->template, 'event_') !== 0) return; $form = $e->return; $contentTab = $form->children->get('id=ProcessPageEditContent'); $settingsTab = $form->children->get('id=ProcessPageEditSettings'); if (!$settingsTab) return; $template = $settingsTab->get('template'); if (!$template) return; $settingsTab->remove('template'); $contentTab->prepend($template); });
  21. I think the solution to your problem is rather simple: Set up your hooks after you check for unwanted urls.
  22. Never considered Tracy as a she . But yeah, its a girl's name isn't it. I'm gonna call Tracy a `she` from now on.
  23. Another alternative to enforce arbitrary filesize limitation is using File API. This has the advantage of preventing file uploads before even they hit to the server, saving bandwidth and resources. Given a form like this <form> <p data-maxsize-message>Files larger than {MAX_SIZE} aren't allowed</p> <input type="file" name="uploadables" multiple><br> <div data-error-wrapper></div> <button type="submit" name="submit" value="submit">Submit</button> </form> You can check file sizes, show and error and prevent file uploads using something like this: const MAX_SIZE = 0.2e6; // bytes => ~0.2MB const MAX_SIZE_STR = '0.2MB'; const form = document.querySelector('form'); const fileInputs = form.querySelectorAll('[type=file]', form); const errorWrapper = form.querySelector('[data-error-wrapper]'); const submitButton = form.querySelector('[type=submit]'); const maxSizeMessage = form.querySelector('[data-maxsize-message]'); // Display max allowable file size maxSizeMessage.innerText = maxSizeMessage.innerText .replace('{MAX_SIZE}', MAX_SIZE_STR); // listen to all file inputs for new files [].slice.call(fileInputs) .forEach(inp => inp.addEventListener('change', handleFile)); function handleFile(e) { let files = [].slice.call(this.files); let largeFiles = files.filter(({size}) => size > MAX_SIZE); // if there are large files, show a message and prevent upload if (largeFiles.length) { let errors = largeFiles.map(({name, size}) => { return `${name} is larger than ${MAX_SIZE_STR}`; }); errorWrapper.innerText = errors.join('\n'); submitButton.disabled = true; // prevent upload by removing input name (restored with valid input) this.dataset.name = this.name; this.name = ''; } else { errorWrapper.innerText = ''; submitButton.removeAttribute('disabled'); // restore input names this.name = this.dataset.name; } } And here's a demo http://output.jsbin.com/lulopi/
  24. Also, you can add code blocks using this button to get a nicely output code block :)
  25. Just so you know, this one appends homepage title to all pages (except homepage, of course), so you get `My Page Title - MySite` <title><?php if($page->id > 1) { echo $page->title .' - '; } echo $home->title ?></title> This one changes it into just `My Page Title` (without the suffix) <title><?= $page->get("windowTitle|headingSubtitle"); ?></title> and yes it should work without any issues I wasn't really following the previous discussion. See @SamC's comment below
  • Create New...