-
Posts
4,928 -
Joined
-
Days Won
321
Everything posted by Robin S
-
Definitely a useful module, thanks @Rudy! A couple of things... When using a single SCSS file I get a PHP warning notice: And it would be good if the module only recompiled the CSS if one of the source SCSS files changes rather than recompiling on every page load. A while ago I wrote a simple function for compiling SCSS to CSS using ScssPhp, only when needed. Perhaps you might find something useful in there: require_once TEMPLATES . '/stylesheets/scssphp/scss.inc.php'; use Leafo\ScssPhp\Compiler; function compileCSS(){ // get timestamp of most recently modified SCSS file $files = glob( TEMPLATES . 'stylesheets/scss/*.scss' ); $times = array_map('filemtime', $files); arsort($times); $scss_time = current($times); // get timestamp of CSS file $css_file = TEMPLATES . 'stylesheets/site.css'; if (file_exists($css_file)) { $css_time = filemtime($css_file); } // if no CSS file or SCSS newer than CSS file... if( !isset($css_time) || $scss_time > $css_time ) { // ...compile a new CSS file... $scss = new Compiler(); $scss->setFormatter('Leafo\ScssPhp\Formatter\Compressed'); $scss->addImportPath( TEMPLATES . '/stylesheets/scss/' ); $scssIn = file_get_contents( TEMPLATES . '/stylesheets/scss/site.scss' ); $cssOut = $scss->compile($scssIn); file_put_contents( TEMPLATES . '/stylesheets/site.css', $cssOut ); // ...and return the path with the SCSS timestamp... return '/site/templates/stylesheets/site.' . $scss_time . '.css'; } else { // ...else return the path with the existing CSS timestamp return '/site/templates/stylesheets/site.' . $css_time . '.css'; } } FYI... "TEMPLATES" is a constant I defined elsewhere that holds the path to the PW templates folder. I use a single SCSS file "site.scss" that imports the other SCSS files. The compiled file is saved as "site.css", but for cachebusting purposes I include the modified time as part of the file basename in the returned URL, then use a rewrite rule in htaccess to resolve the URL to the actual filename. An alternative would be to append a query string with the file modified time, e.g. "site.css?1472438137"
-
I think there might be still better places to ask. Table is a Pro field with it's own dedicated support sub-forum. And the feature you are describing is not a feature of Hanna Code but rather a feature of the Hanna Code Helper module.
-
Strange that it isn't working for you. Line breaks work fine in CKEditor for me, even with ACF and HTML Purifier on and without having to add "br" to Extra Allowed Content. Can you test on another PW installation to see if line breaks are working there? Also, are you entering line breaks in CKEditor using Shift+Enter or are you pasting in source code?
-
Hi there fellow kiwi Check out the Page List Show Page Id module - it's very simple so it's easy to modify to include whatever information you want in the page label. You can add some custom CSS to hide/style the added info: public function init() { if($this->user->isSuperuser()){ $this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageIdLabel'); // add stylesheet $this->config->styles->add($this->config->urls->PageListShowPageId . "PageListShowPageId.css"); } }
-
@kixe The name of the repeater page doesn't come into the code I posted. This line... $pid = filter_var($this->name, FILTER_SANITIZE_NUMBER_INT); // get repeater page id from inputfield name ...gets the ID of the repeater page from the inputfield name - in the context of "Custom PHP code to find selectable pages " $this is the Page inputfield. The inputfield name includes the repeater page ID due to this: https://github.com/ryancramerdesign/ProcessWire/blob/devns/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module#L219 But thinking some more, the base inputfield name itself could include integers so this would be better: $pid = filter_var(strrchr($this->name, "_"), FILTER_SANITIZE_NUMBER_INT); // get repeater page id from inputfield name The whole idea is pretty hacky, but just trying to work around what is available in "Custom PHP code to find selectable pages".
-
ProcessPageSearch is mentioned in the stack trace. Maybe take a look at the module config settings and see if anything is out of the ordinary. Screenshot of what I believe are the defaults:
-
I had a crack at this and it seems the answer is "yes". Here is example code you could use in the ""Custom PHP code to find selectable pages" for Page field 2: $pid = filter_var($this->name, FILTER_SANITIZE_NUMBER_INT); // get repeater page id from inputfield name $p = $pages->get($pid); // get repeater page if($p->id) { $parent = $p->page_field_1; // get value of first page field if($parent->id) { return $parent->children(); // return children of selected page } } But the bad news is that dependent Page fields only auto-refresh when using "Custom selector to find selectable pages" and not when using "Custom PHP code to find selectable pages". So you would need to save the page after selecting a value in Page field 1, which kinda sucks.
-
Off topic: @Pete, can you please check your private messages. Thanks.
-
While we're imagining how this group field might work, my two cents is that I don't think a limited repeater is the way to go. One likely use case for a group field is for SEO fields that would be added to nearly every template, so using a repeater-based group field would effectively double the number of pages in your site. I know that pages are designed to scale up nearly indefinitely but adding all these extra pages just seems unnecessary when there will only be one group field per page. The way I would like to see it is that the individual fields within the group are added directly to the template like normal fields are, but they would have a property that identifies them as belonging to a group. Having such a property would allow: The group field to appear in the template field list as a single item, so it's easy to move the grouped fields as one. Likewise it could be added to / removed from a template like a single field via the API. The group field settings would allow adding/removing/sorting fields to the group "pseudo-template" - as per a Repeater field, but a normal PW template would not be involved. This would require core changes of course, so would only happen if @ryan can see the value in having a group field in PW.
-
Forgot password code results in page timeout
Robin S replied to OrganizedFellow's topic in General Support
The minimum requirements feature was introduced in 3.0.22 and is configurable for the field: https://processwire.com/blog/posts/upgrades-optimizations-pw-3.0.22/#major-enhancements-to-our-password-field -
Forgot password code results in page timeout
Robin S replied to OrganizedFellow's topic in General Support
Maybe your new password does not meet the minimum security requirements for the field? Not sure if that could cause a timeout - you'd think there would be some error notice. -
That kind of syntax works fine for me. Try the same selector outside of Paginator to isolate where the problem lies.
-
Each item in the paginator array is a separate selector for a $pages->find() operation - the results are concatenated together for pagination. So just include or exclude templates for any selector in the array like you would normally for $pages->find($selector). So for your example: $result = $paginator(array( "headline~=$q, template!=profile", "introtext~=$q, template!=profile", "body|whatever~=$q, template!=profile" ), $input->pageNum, 25);
-
CMS Critic Powered by ProcessWire (again) + Case Study
Robin S replied to ryan's topic in News & Announcements
@Jonathan Lahijani Really great post, thanks. Sounds like you put in quite a bit of work in this upgrade - is it okay to ask the approximate number of hours the project took? -
@Juergen: At the cost of a couple of extra DB queries, you can use my new favourite tool Paginator: (thanks @LostKobrakai) include 'src/Paginator.php'; include 'src/PagesPaginator.php'; $paginator = new PagesPaginator(); $result = $paginator(array( "headline~=$q", "introtext~=$q", "body|whatever~=$q" ), $input->pageNum, 25);
-
You can use a hook to append a formatted created date to the end of the page list label. In /site/ready.php... $this->addHookAfter('ProcessPageListRender::getPageLabel', function($event) { $page = $event->arguments('page'); $created = date('d/m/y', $page->created); $event->return .= " $created"; });
-
The error in the logs could be a symptom rather than the cause of the problem. When it comes to out-of-the-blue errors like this the usual suspect for me is mod_security - it would be worth disabling this to see if it resolves the issue. You may be able to disable mod_security via cPanel or htaccess, but if you're not sure ask your host.
- 5 replies
-
- 2
-
- processwire\wiredata
- 500
-
(and 2 more)
Tagged with:
-
Yeah, I don't worry about that. No different to Repeater items in that respect. If you're concerned about orphaned pages you can set PageTable pages to be trashed or deleted if their parent page is deleted.
-
@Galo, I think the step you are missing is adding the plugin button to the CKEditor toolbar. The toolbar buttons are set in the field settings, on the Input tab. Edit: and you also need to activate the plugin for the field...
-
I'm not 100% clear on what you mean, but you could create a datetime field "sort_date" and use a save hook to copy the event date to it if one exists, otherwise copy the published date. Then sort by sort_date in your selector.
-
I'm not sure what you mean. It's just as @MadeMyDay explained - the order is stored as part of the field. You just need to get the "block" pages via the field rather than as children of a parent. Instead of... $blocks = $page->children('sort=sort'); ...do... $blocks = $page->my_pagetable_field;
-
Searching for numbers throws Exception: Operator '~=' is not implemented
Robin S replied to joe_ma's topic in General Support
The reason you are seeing pages from the trash is because you are using $pages->get() which returns a page regardless of access or status. Besides Adrian's suggestion you could use $pages->findOne() instead of $pages->get(). But I think the way you are adding a match to your $pages->find() result is going to cause a problem with your pagination - the additional match will appear on every page of results. The only way I can think of getting around this is to make the child page titles a property of the parent page so that parent page can be matched directly in your selector. Unfortunately there isn't a "has_child" feature similar to "has_parent". So perhaps make a page field in your event template and automatically add and remove child pages from it with hooks. Or use a PageTable or Repeater field for your event_date pages and only add event dates via this field. -
I think the issue lies with the autoload condition: If this is changed to... 'autoload' => true, ...then it works for me. If you change this, do a refresh in Modules to clear the cache.