-
Posts
5,039 -
Joined
-
Days Won
340
Everything posted by Robin S
-
As it happens I was just last night tinkering around with a module for this: info here.
- 1 reply
-
- 4
-
-
GitHub: https://github.com/Toutouwai/TemplatesChildPages For any page, allows the restricting of templates that may be used for child pages. Usage Install the TemplatesChildPages module. The module adds an AsmSelect inputfield "Template restrictions for children" on the Children tab of Page Edit. Use the inputfield to select from existing templates and any child pages added subsequently will be limited to those selected templates. Note that any template restrictions added via this module are in addition to any "Family" restrictions set for the child and parent templates. In other words, if template Family restrictions prevent a template being selected for a given page you can't override this simply by including the template in the parent's "Template restrictions for children" field. Why use this module? The module allows you to add child page template restrictions without having to create new or duplicate templates for the parent page. This forum post explains the situation well. Similarly, it makes it possible to use the "Add New" page feature without an unnecessary proliferation of templates. If you specify a single template as restriction for child pages you can add a Page Add Bookmark for that parent page that allows site editors to easily add a new page using the right template for the location.
- 10 replies
-
- 11
-
-
Related pages: How to enforce uniqueness and minimum/maximum count?
Robin S replied to wet's topic in API & Templates
Adapting Soma's code from here, in /site/ready.php: $this->addHookAfter('InputfieldPage::processInput', function($event) { $field = $event->object; if($field->name == "featured_products"){ $count = count($field->value); if( $count < 4 || $count > 6 ) { $page = $this->modules->ProcessPageEdit->getPage(); $old_value = $page->get($field->name); $field->value = $old_value; $field->error("You must select more than 4 and less than 7 products"); } } }); -
For PW 2.x it's difficult to avoid caching problems for your linked CKEditor JS and CSS files. One solution, albeit tedious, is to append a cachebusting query string to your URLs and update it every time you change the files. So in your field settings something like: /site/modules/InputfieldCKEditor/contents.css?2 This has been fixed in one of the PW 3.x releases.
-
I also hate empty paragraphs so gave this a try. Works well for me. This is an interesting one. There is a setting, but it doesn't work as intended. With the help of Tracy Debugger I did a bit of investigating as to why but haven't got to the bottom of it yet. The line intended to replace empty paragraphs in InputfieldCKEditor is this: $value = str_replace(array('<p><br /></p>', '<p> </p>', '<p></p>', '<p> </p>'), '', $value); But it doesn't match the empty paragraphs because $value has already passed through HTML Purifier where gets replaced with some mystery space character. So neither 'nbsp;' nor ' ' match the space character between the paragraph tags. I haven't been able to work out what this space character is because it's rendered like a normal space in the variable dump. --- Update: the mystery character is a UTF-8 encoded non-breaking space character. So the code above should instead be: $value = str_replace(array('<p><br /></p>', '<p> </p>', "<p>\xc2\xa0</p>", '<p></p>', '<p> </p>'), '', $value); Double quotes are needed around the string with the UTF-8 non-breaking space. I'll submit a pull request for this fix.
-
Here is a start for how you could create your search. It needs to be fleshed out for usage as global site search. For search input "rest home 1"... $addresses = $pages->find("template=address, title=rest home 1"); $categories = new PageArray(); foreach ($addresses as $address) { $categories->add($address->categories); } $categories = $categories->unique(); // not strictly necessary $results = $pages->find("template!=address, categories=$categories"); As an aside, because you are using Javascript pagination for your address list you could consider populating the filter field from a get variable for search results. To make it easier for visitors to see the address they have searched for if that address appears on page 3 or whatever. Nice looking site, BTW.
-
Further to what LostKobrakai said regarding storing your references to other pages in a Page field... So you have these pages somewhere in your site: social insurance rest home 1 rest home 2 And then you have a page "old age" that stores references to the pages above using a Page field called "addresses". You should be able to match "rest home 1" to page "old age" with a search selector like: $pages->find("addresses=rest home 1");
-
...accidentally overwrote my post, whoops. Anyway, continued below...
-
How to add column in user page list in admin
Robin S replied to adrianmak's topic in General Support
Modules > Core > ProcessUser > What fields should be displayed in the page listing? -
Right you are, I didn't read carefully enough. AdminCustomFiles sounds like a good solution.
-
The whole module should be in /site/modules/ to begin with. You don't install modules into /wire/modules/ - that is only for the core modules.
-
Thank you, adrian. That fixes it. Just adding the curly braces around $fM['type'] was enough to avoid the error message. Before I read your reply I was doing $function = $fM['type']; $fields->add( self::$function($f, $fM['label'], $data[$f], $fM['desc']) ); which also worked.
-
When used with PHP7 I get this fatal error: Uncaught Error: Access to undeclared static property: MaintenanceMode::$fM in /home/mysite/web/test/site/modules/MaintenanceMode/MaintenanceMode.module:94 Is there an easy fix for this?
-
A couple of questions about the ProcessWire Form Builder
Robin S replied to Neo's topic in General Support
@Neo, I might be misunderstanding the flow of events but if you don't want people who haven't paid to submit the form you only render the form after payment. This wouldn't require any special Form Builder feature, just normal template logic. So it would go like this: User submits payment to MercadoPago from a payment page on your website. You check the response from MercadoPago to see if payment is successful. There must be some method in the MercadoPago API for this. If the payment was successful you render the form, maybe populating a hidden field from a get variable if you want to match the form submission to a payment. User submits the form for moderation. -
@creativejay, my guess is that this is caused by mod_security. Try disabling mod_security (or ask your host to disable it) and see if that resolves it.
- 5 replies
-
- Permission
- Options field
-
(and 1 more)
Tagged with:
-
Session Handler Database: times out by two hours
Robin S replied to Robin S's topic in General Support
Thanks, I think you're right. However on a shared server I don't think it's possible to change the MySQL timezone. I found the following suggestion for adjusting the MySQL timezone via PHP: mysql_query("SET time_zone = '-6:00'"); Is there a better way to execute this using one of PW's $database methods? And where would be the right place to put this? In /site/init.php? It would be nice if the Session Handler Database module saved timestamps with PHP's timezone so this wasn't necessary. GitHub issue -
I installed the core Session Handler Database module but the times shown are out by two hours. That is, the time for a new login is shown in Session Handler Database as "2 hours ago". Probably a timezone issue, but what setting do I need to adjust to correct this? The timezone in my config is correct.
-
I'm not sure what would cause the error you're getting, but something you could try is migrating without using the Export Site Profile module. My normal procedure is: Export the database using PhpMyAdmin on the old host ZIP all the files on the old host, download ZIP Create a new empty database on the new host and import the database export from step 1 Upload and extract the ZIP on the new host Edit config.php to change database name/password if necessary
-
I'm striking the same problem. I'm using Ryan's findRecentComments function (which in turn uses FieldtypeComments::findComments). This works well if you want the latest comments from any page. But I want to limit the list of latest comments to pages with a particular property. I think the only way to do this is to use the pages_id value of a comment, which stores the ID of the page the comment is on. First I was hopeful that pages_id would support sub-selectors but no joy there. So then I figured I'll build a PageArray of pages I want to limit my latest comments list to and give that to pages_id in the selector, but that doesn't work either. Even manually entering a set of bar-separated page IDs doesn't work. Is there some trick to getting pages_id to accept anything apart from a single page id? Edit: This line explains why the problem exists. I have submitted a GitHub issue / feature request.
-
My project allows paying users access to protected front-end content and my client is concerned about users sharing their login details among a group rather than each purchasing an individual account. Of course there is only so much you can do to protect against this and there will always be loopholes, but I'm wondering if I can provide some basic protection against this. My idea is a maximum of two IP addresses may be simultaneously logged in to any user account, but I'm not sure where to start with implementing this. Is there an existing module or snippet that would give me a starting point for limiting simultaneous logins? I'm also interested in hearing any other ideas for tackling this issue. Thanks.
-
Hi @Hardoman, welcome to the forum. There are two ways you can achieve this. 1. If all the pages you want to link to with target="_blank" have the same template you can use the 'xtemplates' option. Example: $nav = $modules->get('MarkupSimpleNavigation'); $nav_options = array( 'xtemplates' => 'my_template', 'xitem_tpl' => '<a target="_blank" href="{url}">{title}</a>' ); echo $nav->render($nav_options); Now all links to pages using my_template will have target="_blank". 2. If you need to use a different or more specific selector than just template you can use a hook. function menuSpecialLinks(HookEvent $event) { $child = $event->arguments('page'); // current rendered child page // any logic with $child possible here if($child->name == 'my-page-name') { // set the return value of this hook to a custom string $event->return = "<a target='_blank' href='{$child->url}'>{$child->title}</a>"; } } $nav = $modules->get('MarkupSimpleNavigation'); $nav->addHookAfter('getItemString', null, 'menuSpecialLinks'); echo $nav->render();
-
Okay, replace filter() with find(): $tagless_images = $page->images->find("tags=''");
-
Yes, I probably will do a normal cron, but I'd like to get my head around Lazy Cron just so I understand how it works. And I must be thick because I'm still not getting it. I think I understand about how it depends on the timestamp in LazyCron.cache, but when is the first timestamp set. Because doesn't everything depend on that? Presumably before any Lazy Cron hooks are added there is no timestamp at all. Then I add my first hook, and it's an "everyDay" hook. Does this set the timestamp... a) On the next page load immediately after I save the hook (let's say it's 2pm when I happen to save this hook). Then my hook will forever fire at approximately 2pm every day, give or take depending on page loads. b) It has nothing to do with when I save the hook, but rather it's fixed to some standard time such as midnight. So I save my hook at 2pm, but it first fires at midnight (same day? following day?) and then will forever fire at approximately midnight every day, give or take depending on page loads. Edit: I also understand that by nature a lazy cron will drift in time because the variations in page loads accumulate with every execution, but I'm still interested in when that first execution takes place. Thanks for your patience.
-
Thanks. Still not quite clear on when the first execution will fire. Let's leave aside the issue of page views and assume my site continuously gets page views every second. If I create a new hook for "everyDay" and happen to save this hook in my ready.php at 2pm, does 24 hours elapse before the first execution, and then the hook fires again 24 hours after that, at 2pm every day? If that is so, how can I arrange for an everyDay hook to fire at a given time (approximately)? Say 1am. Because even if I follow the suggestion in the lazy cron docs and set a normal cron job to load a page at 1am, if 24 hours has not yet elapsed it's not going to trigger my lazy cron. That's just going to keep on firing at 2pm isn't it?
-
Trouble with CK editor and Textarea field in PW Admin
Robin S replied to EyeDentify's topic in General Support
I don't think the "B" and the "I" icons are meant to represent <b> and <i> HTML tags - they are likely carry-overs from the icons used in word processors. As far as I know pretty much all WYSIWYG editors insert <strong> and <em> tags for these buttons. The CKEditor docs confirm the Format dropdown is only for block-level elements so that's what's probably crashing it.