-
Posts
2,769 -
Joined
-
Last visited
-
Days Won
31
Everything posted by Martijn Geerts
-
@Richard, something like this: foreach ($page->table as $row_page) { echo $row_page->render(); }
-
Hi Horst, I've used weighten in a newsletter tool for company logo's and it working great. Thanks again for implementing it !
-
I was testing locally and behind a router so maybe that is part of the cause.
-
Hi Horst: When testing the connection and 'use SSL' is checked these 2 notices appear. (2.5.17 dev) Notice: Undefined property: smtp_class::$result_code in /Users/martijn/Sites/domains/newsletters/htdocs/site/modules/WireMailSmtp/smtp_classes/smtp.php on line 1032 Notice: Undefined offset: 0 in /Users/martijn/Sites/domains/newsletters/htdocs/site/modules/WireMailSmtp/smtp_classes/smtp.php on line 1042
-
I'm using dev all the time it's stable most of the time. Nevertheless when I find bugs i feel responsible to report them.
-
Sortable is not that difficult I guess. Raymond has explained it over here.
-
@mrkhan: There have been changes in ProcessPageEdit recently. The tabs need to be deleted manually. The code below works in 2.5.25 (dev). (don't know if thats the case for 2.5 and if so could you report this back) function removeSettings(HookEvent $event){ // check what role the user has, if not has editor role do nothing if(!wire("user")->hasRole("webmaster")) return; // $event->return being the inputfield wrapper $wrapper = $event->return; // set the inputfield wrapper to hidden $wrapper->collapsed = Inputfield::collapsedHidden; // Get the active Object (ProcessPageEdit) $process = $event->object; // Remove the Settings tab with the ID $process->removeTab('ProcessPageEditSettings'); // we're done }
-
not important, but oh so present in this community: its vs. it's
Martijn Geerts replied to rajo's topic in Pub
My intension is not to dislike your post, actually the opposite is true. This conversion is just an opening for me to tell people "don't let language be the factor not to post". Personally I'm not good with words and will never be, but the ProcessWire forum has learned me a lot. -
not important, but oh so present in this community: its vs. it's
Martijn Geerts replied to rajo's topic in Pub
I know a dutch forum where people correct spelling almost all the time. Those "you spelled this wrong" posts can take over whole threads, making the subject inferior to the tiny spelling mistakes. The place has become a childish playground for spelling purists in my opinion. Non-native English people participating here in the forum will upgrade their language skills, that's both code and language. What ever language boundaries there are, I hope people still post questions & answers. -
One possibility is to hook ProcessPageEdit::buildForm and build your wanted values from there. So no need for special fieldtype & Inputfield because it looks like overkill to me. Ps, the code here is not tested and written in the browser, it's more to give you an idea. <?php public function init() { $this->addHookAfter('ProcessPageEdit::buildForm', $this, 'afterPageEditBuildForm'); } public function afterPageEditBuildForm(HookEvent $event) { $form = $event->return; $page = $event->object->getPage(); $wantend_template = 'your-template'; // make this your template if (!$page->id) return; // return if wrong template $template = $page->template; $string = 'invoice_'; // for building your field value if ($template->name !== $wantend_template) return; // Skip if not wanted template $fieldnames = array( 'invoice_date', // Field named invoice_date 'customer', // Field named customer 'follow_up', // integer field. ); foreach ($fieldnames as $fieldname) { // Inputfield $obj = $form->getChildByName($fieldname); // Build field value if ($obj->type == 'FieldtypeDatetime') { $string .= strtotime('Y-m-d', $obj->value); } else if ($obj->type == 'FieldtypeInteger') { /** * Make some logic to find the follow_up number field value * */ $integer = '123456789'; // calculate it here $obj = $form->getChildByName($fieldname); if ($obj->value != $integer) { $obj->value = $integer; $obj->resetTrackChanges(); $obj->trackChange('value'); } $string .= $integer; } else if ($obj->type == 'FieldtypePage') { $string .= $obj->value->name; } } // We use the title for your invoice value $InputfieldTitle = $form->getChildByName('title'); $value = $InputfieldTitle->value; if ($string !== $value) { $InputfieldTitle->resetTrackChanges(); $InputfieldTitle->trackChange('value'); $InputfieldTitle->value = $string; } }
-
It is just a HTML5 placeholder attribute. It just shows text in a field until the field is focused. See it as a helper for editors (who are smart enough to use a modern browser) For the PHP part, an if statement like this will work. if ($page->price) { echo $page->price; } else { echo 'Please ask....'; }
-
how to implement the url like wordpress ?
Martijn Geerts replied to adrianmak's topic in General Support
Date archiver automatically archives pages based on a Datetime field (e.g. /news/2013/01/03/some-news-item/). -
Maybe you can with a lot of work. (not out of the box). Better to go with the flow then row against it.
-
@mrkhan: You should have the structure as LostKobrakai showed us.
-
@Michael, dealing with aspect ratio is in most cases more the task of CSS. Could you explain more in depth what you are after, then maybe we can help you with other possibilities.
-
image upload gettings stuck on 100%
Martijn Geerts replied to onjegolders's topic in General Support
What are your memory settings ? -
New to Hooks, trying to wrap my head around the syntax
Martijn Geerts replied to creativejay's topic in Getting Started
What I do often is taking the hooked method name and put before or after before that name. This way I don't have to think about a name (laziness) and I can see when or if the method derived from a hook. In this case I would have chosen afterSaveReady. -
Actually I build a Fieldtype & Inputfield that connects with MailChimp, creates a campaign, in the field you could select the lists and segments and a few other settings. After saving the page, all markup, settings and plain text is pushed to mailchimp. When I finished the field, the API was depricated, so the field has never been used in the wild. (bummer) As a response I build this simple field and this doesn't rely on those great PHP coders at MailChimp who code quicker then I can smoke my cigaret.
-
New to Hooks, trying to wrap my head around the syntax
Martijn Geerts replied to creativejay's topic in Getting Started
There's a lot not right in your renameBeforeSave method. Naming is also a little bit weird: You hook after, but you call the method with before in the name. $p->blog_categories == "Swatches" // If blog_categories is type of page it will not be a string. $p->createdUser // is a Page // you can't concatenate it like this. You can't call $sanitizer like this in module scope. (use $this->sanitizer) -
New to Hooks, trying to wrap my head around the syntax
Martijn Geerts replied to creativejay's topic in Getting Started
Damn you guys, I don't answer anything anymore..... -
New website for protective ventilation systems
Martijn Geerts replied to MadeMyDay's topic in Showcase
Great Site ! -
How to clear (sticky) Session errors manually?
Martijn Geerts replied to Martijn Geerts's topic in Module/Plugin Development
Not only your head, mine to -
How to clear (sticky) Session errors manually?
Martijn Geerts replied to Martijn Geerts's topic in Module/Plugin Development
ProcessInput Is the first method that get's called after a post. That method cleans the data from $input->post, the function compares the posted value with the value in DB. When different, change tracking is called to tell PW that the value has been changed and should be saved and make the data available. The errors I talk about are the errors I set manually the the Inputfield object. -
Having a problem with errors staying (1 page reload) to long in $session. On the Inputfield I call ->getErrors(true); to clear the errors for the Inputfield. Works Fine ! But the message in session (on top of the admin) stays 1 page save longer. And I don't know how to get rid of it. Initially I though to delete it from $session directly with: $key = $field->getErrorSessionKey(); // gets the session error key from Inputfield $session->remove($key) // No succes :-( Can somebody help me out here ? <?php public function init() { $this->addHookAfter('ProcessPageEdit::buildForm', $this, 'afterPageEditBuildForm'); } public function afterPageEditBuildForm(HookEvent $event) { $form = $event->return; $page = $event->object->getPage(); if (!$page->id) return; // return if wrong template $template = $page->template; if (strpos($template->name, 'element_') !== 0) return; // table field with defaults $rootParent = $page->rootParent; $table = $rootParent->settings; $allowed = array( 'FieldtypePageTitle', 'FieldtypeText', 'FieldtypeURL', ); foreach ($template->fields as $f) { // only allowed fields if (!in_array($f->type, $allowed)) continue; // Inputfield $obj = $form->getChildByName($f->name); if ($obj->value) { $obj->getErrors(true); continue; } // Find row in rootParent with default value $row = $table->get("template={$template->name}, field={$f->name}"); // Skip if no row is found if (!count($row) || !$row) continue; // clear errors & set trackChange $obj->getErrors(true); $obj->error($this->_('Standaard waarde toegevoed, nog niet opgeslagen.')); $obj->resetTrackChanges(); $obj->trackChange('value'); $obj->value = $row->value; } }
-
how to manage Delete Tab for user groups
Martijn Geerts replied to mrkhan's topic in General Support
Here a gues: It's weird that the name of the method is the same as the class. With the same name it will act as a constructor and thus has no HookEvent. (not sure it is as your classname is capitalized) Could you rename removeDeleteTab method to afterRemoveDeleteTab (or something you wish)