-
Posts
214 -
Joined
-
Last visited
Everything posted by SteveB
-
I love this module and it's perfect for generating reports and things for users. What I'd like to know is how I can get my pages2pdf template to also save a pdf file on the server, as well as sending it as a download to the user. Certain of these pdfs are of general interest and I'd like to keep a current copy sitting in a directory. Thanks.
-
Teppo, The undefined indexes thing was only a Notice (harmless) and only when I have debug true in my PW config file. Re. the filters, the filters form in /setup/changelog has a select returning numeric values. The first thing I did was to put this line in right after where you define $query in buildQuery. wire('log')->save('messages', 'changelog @' . __LINE__ . ' ' . $query); Here's results I got (line number will not be same as yours): No filters: changelog @518 SELECT process_changelog.* FROM process_changelog WHERE operation IN('added','moved','edited','trashed','renamed','deleted','restored','published','unpublished') ORDER BY timestamp DESC, id DESC LIMIT 0, 25 'Edited' filter: changelog @518 SELECT process_changelog.* FROM process_changelog WHERE operation = '3' ORDER BY timestamp DESC, id DESC LIMIT 0, 25 So I just used the $this->operations array to look up the string from the number the form supplied.
-
Downloaded this yesterday for a test drive (V 1.2.15). Like it very much. Reporting back with observations and mods. Disclaimer - I did make another change particular to my needs but I'm pretty certain it doesn't impact anything else. If the page had a RuntimeMarkup field (kind of a pseudo-field) it was always detected as changed. See ProcessChangelogHooks. foreach ($page->template->fields as $field) { //if ($page->isChanged($field->name)) { if (empty($field->runtimeFields) && $page->isChanged($field->name)) { //SB added condition - ignore RuntimeMarkup field $fields_edited[] = $field->name; } } Also undefined index notices as Adrian mentioned. See ProcessChangelog. switch ($operation) { case 'renamed': if(!empty($details["Previous $key"])) { //SB added if $target .= $details["Previous $key"] . " <strong>" . __("as") . "</strong> " // as // In context of a rename operation ("renamed old-page-name as new-page-name") . $details[ucfirst($key)]; break; } case 'trashed': if(! empty($details["Previous $key"])) { //SB added if $target .= $details["Previous $key"] . " <em>(" . $details[ucfirst($key)] . ")</em>"; break; } default: $target .= $details[ucfirst($key)]; } The ProcessChangelog buildQuery method was doing things like WHERE operation = '3' instead of using the name of the operation. That made the filter not work. case "operation": if (!in_array($value, array_flip($this->operations))) { unset($this->input->get->$key); break; } if($value) $value = $this->operations[$value - 1]; //SB fix - want word not number else break; //SB fix default: $where[] = "$key $operator '$value'"; } Thanks!
-
Okay, using flock now. I ended up making a class to manage locks on PW pages. The lock file goes in with the page's other file assets. Automatic unlock on destruct. Logging if you want it. That got me thinking about adding this support for locking to the Page class as described here but it's not really necessary.
-
Whoops. Reminds me why I used use mysql update for this kind of thing. Was trying to stick with pages etc. Will rethink. Thanks!
-
Sorry Horst, it's just 3 functions to make working with the page status attribute more convenient. I'd say these are work in progress but here's what they look like now. Edit: Skip ahead... These fns were the wrong approach. //with default args will wait up to 4s for locked page to unlock. Returns false or the page. function claimPage($page, $tries=5, $ms=100){ if($page->hasStatus(Page::statusLocked)) $page = waitForPage($page, $tries, $ms); if(! $page) return false; $page->addStatus(Page::statusLocked); $page->save(); return $page; } //if page is locked, wait and recheck. Returns false or the page. function waitForPage($page, $tries=5, $ms=100){ $t = 500; while($page->hasStatus(Page::statusLocked) && $tries--){ $t += $ms; usleep($ms); $this->pages->uncache($page); //so we get current status } if (! $tries && $page->hasStatus(Page::statusLocked)){ $this->releasePage($page); //we're expiring the lock afer a decent wait... return false; //but honoring the lock } return $page; } //unlock and save function releasePage($page){ $page->removeStatus(Page::statusLocked); $page->save(); return $page; }
-
Conditionally disable Template Cache in Template Context
SteveB replied to hettiger's topic in General Support
Based on this maybe try... $page->template->cache_time = 0; // disable the cache -
Mostly about managing a queue and locking data while it's being updated. I'm wondering if anyone has a different idea about this or feels uncomfortable about employing Page, Template, etc. instead of a module. I like it this way because it's so adaptable but maybe someone has a more appealing way. Scenario: The site uses lots of page fields and most of its pages are indexed by ElasticSearch. When a page is indexed, page fields are (usually) represented in the index by the title field of the referenced page. ElasticSearch automatically re-indexes a page whenever it is saved. That's great but if A points to B and we save B after renaming it, B is re-indexed but A still has the old title in its search index. Solution: To handle that I have code hooked after Pages::saveReady make a PageArray of pages we'd like to re-index. Usually just a few but in rare instances a few thousand. Some care is taken with the querying in case we have a lot. To queue that work I'm using a page with a page field to represent the queue. You use a urlSegment to pass it a command (similar to a process page). Setting aside some details about access, the hooked code adds pages to the page array. Cron calls the queue page periodically, code in the template file does the first N pages, removes them from the page field and updates the page. So far so good and it has worked very nicely but two things are asynchronously fetching and updating that page field without any locking. They're quick but if we're not lucky updates will be missed or repeated. So I wrote some little functions to add, remove and test Page::statusLocked on the queue page. Docs say it's not enforced by the core (but is checked by Process modules). Both the hooked code and the queue code will respect the lock, wait and retry for a few seconds. After updating the page they release the lock. To avoid problems with stuck locks, the function that waits and retries will only wait so long before unlocking the page. It waits longer than we'd ever need to keep something locked in normal operation. Thanks. Details on request, trying not to bury the main points.
-
Yes, that did it. The Spex layout is working, all the JS & CSS loads, etc. Must have been good coffee. I ended up adding a line to set a variable so I can know in a template file that a preview is being rendered. $this->addHookBefore('ProcessVersionControl::executePreview', function(HookEvent $event) { wire('modules')->get('Spex')->setActivePage(null); wire('modules')->get('Spex')->addTemplateVar('vcpvw', 1); }); For this particular project where many of the pages being edited have lots of fields (24), I'm not entirely sure a visual preview is best but I've only just gotten it working so too soon to say. This next observation may or may not have to do with the fact that I have not turned on Version Control for any of the image fields (I have a different kind of image archive for that) and I'm using PageImageAssistant (a.k.a. Pia). I noticed that in the template where I'd normally show a thumbnail from a page chosen in a page field, The value for $page->myField->image in the preview is not the full data. Kind of makes sense, this is for a page that is not currently selected but was selected at the time the preview is representing. I get the image basename and I can work with that. As I'm testing now I had a weird thing happen where I changed a page field (multiple values, checkboxes) and the change showed up in previews for earlier revisions. In fairness, this is a test page in my local dev server. I'll make some brand new content and try again. (a misunderstanding) I made a minor change (@619) so that in the editor clock icon only shows up on fields with more than one version. Otherwise, there's nothing to look at. protected function renderHTML(array $data) { $markup = ""; foreach ($data as $field => $field_data) { $diff = " diff"; if ($this->diff_disabled) $diff = ""; if ($diff && wire('fields')->get($field)->type instanceof FieldtypeFile) $diff = ""; $revision = count($field_data) ? " data-revision='{$field_data[0]['revision']}'" : ""; $markup .= "<div class='field-revisions$diff' data-field='$field'$revision>"; //if (count($field_data)) { if (count($field_data) > 1) { $markup .= "<ul class='ui-widget-content'>"; Thanks for taking an interest and solving my Spex problem.
-
I agree it's not a VersionControl problem exactly but I'd like to find a way to use both of these useful modules. Putting that code in Iinit.php made no difference. Putting it in the template file seemed a step in the right direction but then I found that apparently _init.php wasn't loaded at all. At least, calls to functions in a file I include from there failed (does not exist). Including _init.php from the template file gets us a bit closer but Spex does not appear to be fully working in this mashup and the layout is very incomplete. The field based way of looking at changes (clock icon) is not working well with PageListSelectMultiple and I use a lot of those. Thinking about a plan B. Thanks
-
Anybody using this with Spex in their templates? When I click to preview revision in the history tab listings it accesses a url like... /processwire/setup/version-control/preview/?pages_id=38172&revision=333 That causes... Fatal error: Call to a member function setLayout() on null in... Just asking in case it's come up before. Thanks.
-
My main issue with any of the themes is usually colors. I'm using classic now and do some inspecting and CSS search and replace if it changes. Used Reno for a while but classic is always in sync with the latest features. If it was just for me I'd tone down the shocking pink and use a more natural green but currently I'm only making the selected tab's edges 10% darker and field separation lines 3% darker. With the default colors one client, new to Processwire, did not perceive the page editor tabs (content, children...) as tabs.
-
Is there a trick to making it crawl when PW is installed in a subdirectory?
-
production site: all admin view links showing to localhost...
SteveB replied to gunter's topic in General Support
Bumping this old thread to shine some light on an obscure fact about that whitelist for domain names. Here's my story: Moved site from development server to real server. Some users (not all) reported View links sending them to the development server. Never happened to other users. Clearing browser cache did not help. Dumping DB and searching text for the development server domain name did not turn up anything. The only place I could find the development server domain name was in the config file in the array defining $config->httpHosts. Documentation calls $config->httpHosts a whitelist so I assumed I could put both the dev and real domain names in the list and maintain a single config file to use in both places. It's not just a whitelist!! The source code of ProcessWire.php explains that If you have not explicitly set $config->httpHost (note: no "s" on end) and the PHP vars for $_SERVER['SERVER_NAME'] and $_SERVER['HTTP_HOST'] don't match anything in $config->httpHosts (with "s") the getHttpHost function defaults to... "no valid host found, default to first in whitelist" The server's environment variables had the domain with www on it but the server accepts URLs with or without the www and people use either one. My dev site was the first one in the list. -
I've just tried this out using 3.0.20 and have some observations. In the setup I selected one template and several fields but left defaults for everything else. I did not select any image or file fields. It created tables, including one in which I found information about images. In the edit page for the template I enabled in setup just about every field has little clock icon on it, many of them no selected in setup. edit: Many of these don't have any changes yet but still show an icon (distracting for users) The fields I did select seem to work as intended and the others do not record changes, they just have the icons. Any ideas about how to record changes made to a PageTableExtended field (pages saved as children, different template)? Another question, when it installed and populated tables I wondered if that process is timeout proof (batching of some kind to handle thousands of pages). Thanks.
-
I went down the Elasticsearch rabbit hole and found that there is quite a learning curve. The PW module by Jonathan Dart is a great starting point but think of it as a Hello World demo. To really make effective use of Elasticsearch you need to learn about "mapping" info and indexing your data and you need to get a feel for the way the query language works. It's a big weird tool but it's worth it to get things like stemming.
-
I was hoping for something more like Lister (rows, columns, sorting) but with thumbnails. It just seems like information is being obscured in order to have a more front-end kind of design. Casting my vote for... A way to see all the image filenames clearly, not truncated and supered over an image. A way to see how they are tagged & described without having to drill into each one. Thumbnails with same aspect ratio as the original image (cropped to square is the visual equivalent of all caps)
-
You should look at the TextAreas in the ProFields ($) package. The catch is that all the grouped fields are the same type but datetime is one of the 20 or so types available. Very handy.
-
Sorry about the delay. If I pick a different branch I don't get repetition. Thought maybe it's some conflict with something I've done but the only thing I'm doing with permissions is in a modified ProcessPageAdd where I changed ___executeNavJSON() and ___execute() so I can allow certain roles to add pages in certain places. It can override allowed parent and allowed template for a page add request but that's the extent of it. What would make whatever builds the Page tree cycle through twice? Edit... Further tests: Works fine if I specify the name of a child of the branch that repeats. Tested without my modified ProcessPageAdd and it made no difference.
-
FYI, just tried this in 3.0.10 using PHP to say what the branch is: return ($user->hasRole('editor')) ? '/data/' : ''; Edit: I see it wants a name, not a path. Made that change but no difference, still repeats. The odd thing is that the page tree now shows up like this (note repetition): Data Alpha Bravo Charlie Alpha Bravo Charlie
-
How do I manage ProcessPageList permission? Preferably by role. I have a frontend form using PageListSelect fields. Works fine for users with edit permissions but not for those who can only view. Edit: I figured out what I needed in this case by trial and error but it didn't make much sense to me. Is there a write up somewhere that my searches don't find?
-
Look at /site/assets/cache/Page. I think all you have to do is empty that folder. Maybe try renaming it first to see if you get the desired effect. Better yet, knock out just one of the folders inside (w page id for name) and check that the system provides a new folder etc.
-
As a followup, here's the README.md file. Please comment on the Implementation Issue. It's working but could probably be packaged better. ## HookAfterPageAdd ## IMPLEMENTATION ISSUE Original plan was to accomplish this with hooks. For reasons unknown the hooks were not being setup. As a temporary workaround, a modified copy of ProcessPageAdd was created with code added to init the module and use its methods. In the end doing it this way is not so bad and simplifies certain tasks since we can jump in anywhere rather just at hookable function calls. Four changes to ProcessPageAdd are required. What should this module be called? ## Introduction Ordinarily one step page add requires specifying only one valid child template on the template settings of parent page's template. That leads to many near-duplicate templates which leads to extra work keeping their other settings matched. ## Purpose This module provides a way to specify everything we need to add the page in one step. * The template is determined from config info and parent's path. * Permission to add the new page to the parent is granted accoding to config info and template name. * If no name format is set this module sets one. ## Path Configuration Comma separated, starting with template name. See examples. Okay to have more than one per template. First matching line is used. ### Example 1 `````` artist, /data/artists/ `````` * Specify name of template to use for the new page: artist * Specify path to new page's parent: /data/artists/ ### Example 2 `````` publication, /data/bibliography/a/, /data/bibliography/[a-z]/ `````` Like above but with optional 3rd part using regular expression syntax. Consider this case... * We have 26 folders named 'A' though 'Z' under /data/bibliography/ * We want to allow any of them to accept an Add request to add a new publication * We setup another module, hooked after Pages::saveReady, to reassign the page to the correct folder. That's in case the user goofs or the page gets renamed. The third part is used in a regular expression pattern (PHP preg_match). It will match the path of any of the 26 folders. Easier than adding 26 rules. In this example, the user can start an add request at any of the A-Z folders and the new unpublished page opened in the editor will always be in the A folder. ## Role Configuration Again it's comma separated, starting with template name. After that add as many role names as you like. Do not put in more than one line for the same template. * Example 1 `````` artist, editor, manager Thanks.
-
Hah! That's very cool. Though I must say I don't like waiting for stuff to play out. If that was the actual navigation I'd just go away. Better for some kind of slideshow I think. Thanks for the example. Maybe we should have a contest and see what people do with it.
-
@Martin, Will do. As soon as I get it worked into the demo for my client. This morning I gave the module quick-add power! No more manipulated step1 form, goes straight to the full page editor.