abdus
Members-
Posts
743 -
Joined
-
Last visited
-
Days Won
42
Everything posted by abdus
-
PW3 include&bootstrap: undefined function wire()
abdus replied to mav_medved's topic in General Support
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 replies
-
- 5
-
- wire function
- include&bootstrap
-
(and 1 more)
Tagged with:
-
[WIP] ProcessMailer - A module for managing and sending newsletters
abdus replied to abdus's topic in Modules/Plugins
Not yet, I'll update the post once I get the alpha version ready. -
Ideas and best practices to secure a member registration system
abdus replied to modifiedcontent's topic in Security
There's invisible recaptcha that only shows up in case of suspected bot activity https://developers.google.com/recaptcha/docs/invisible- 10 replies
-
- 3
-
- no subscription detected
- not recognized
-
(and 4 more)
Tagged with:
-
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
-
[WIP] ProcessMailer - A module for managing and sending newsletters
abdus replied to abdus's topic in Modules/Plugins
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) -
Hook: Check field data and prevent page from being saved
abdus replied to Susticle's topic in API & Templates
Hook into Pages::saveReady instead and throw error inside checkMethod() -
Module: AIOM+ (All In One Minify) for CSS, LESS, JS and HTML
abdus replied to David Karich's topic in Modules/Plugins
Enable debug mode in site/config.php. You're probably getting an error that's preventing PW to complete page render. -
Keep it simple. There are dozens of JS libraries out there that generate table of contents for you. Google "jquery toc"
- 14 replies
-
- 2
-
- table of content
- anchor
-
(and 1 more)
Tagged with:
-
If you can find a .edu email, you can use it for free.
-
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.
-
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(); } ?>
-
Possible to add an "select" text option to a template select at the top?
abdus replied to Juergen's topic in General Support
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); }); -
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) { // ...
-
Displaying the most recent blog posts using different layouts for each
abdus replied to mike62's topic in Getting Started
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 -
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";
-
You don't have to delete it, but if you're not using composer, there's no reason to keep it.
- 1 reply
-
- 2
-
Unless that's a typo you shouldn't have that dollar sign there.
-
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; ?>
-
Possible to add an "select" text option to a template select at the top?
abdus replied to Juergen's topic in General Support
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); }); -
I think the solution to your problem is rather simple: Set up your hooks after you check for unwanted urls.
-
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.
-
max file size validation for file/image fields
abdus replied to chrizz's topic in Wishlist & Roadmap
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/ -
-
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