Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by statestreet

  1. I have some functionality on an intranet site that uses Lazy Cron to query an external API and then update a bunch of pages based on the API response. A problem I've noticed is that this breaks our author / editor tracking – whenever a user triggers the Lazy Cron job, the page metadata for `$page->modified` and `$page->modifiedUser` is (naturally) updated, so it now looks like that user edited the page at that moment in time, even if the content of the page was edited months ago by someone else. It seems like the ideal solution here would be to somehow exempt certain fields (the ones that get updated by this external API) from triggering a timestamp update... Any ideas on how I'd go about hooking into that?
  2. Weird. I can't think of any reason another page would be rendered (no iframes, no additional render() calls). I threw an echo into the background sync function, and indeed, it shows up at the end of the page.
  3. I have a slow background sync function that has to hit a web service a bunch of times (unfortunately there appears to be no way to consolidate the API requests) that I've bound to a Lazy Cron hook. However, it appears that I've somehow caused Lazy Cron to run before `ProcessPageView::finished()` as opposed to after. Every time the Lazy Cron is scheduled to fire, it takes 30 seconds to render the page. Any ideas what I might be doing wrong?
  4. This is just what I was looking for! I have a question, though: How might I go about changing one of the custom fields to a textarea, or even enabling CKEditor?
  5. This seems like a great feature to add after page versioning.
  6. Thanks Adrian! (And thanks for the ProtectedMode module, too.) I just used the config settings referenced in a couple of those threads: $config->pagefileSecure = true; $config->pagefileSecurePathPrefix = '-'; And made sure the "guest" permission was disabled for the templates that have image attachments. For some reason, it seems to have taken about an hour to propagate (some links were still showing up unauthenticated), but everything appears to be locked down now.
  7. We have an internal company site that we use to document specifications for software development. Currently, we use Adrian's ProtectedMode module to restrict the site to logged-in users, but one of the engineers just noted that uploaded files are (naturally, given the scope of the module) visible without authentication. While this isn't a huge risk (you have to know the URL to view an uploaded file), it is technically a security issue since we have lots of proprietary things attached to pages on the site. Any ideas on how I could lock down these files so you have to be logged in to view them?
  8. Thanks Horst, that's a great idea. Is a module the best place to do this, hooking the upload?
  9. On the site for a game development collective I'm part of, I've been trying to add the ability for our developers to attach game builds from Unity (a 3D game engine and development environment) to blog posts. Unity cranks out an HTML file with everything ready to go for static hosting, so I've simply added a file field in the blog post template that accepts the four files Unity exports, one of which is jquery.min.js. Obviously, this is highly redundant, having the content author upload another copy of jQuery with each build, but it's actually a more streamlined workflow than the alternative of building a standard Unity player template, which would then require the author to create an additional page in ProcessWire each time to attach the Unity file. So I've gone with this redundant but easy approach. However, I've run into a technical snag: Even after explicitly allowing "min.js" files for the field, the file uploader always renames the jQuery file to "jquery_min.js", which is then not found by the HTML file looking for the original name. Is there a way to disable this behavior?
  10. $pages->get("/stories/")->find("external_status!=accepted"); This selector works as expected, excluding all the story pages that have "accepted" in the external_status field, but it also excludes stories with no external_status defined (field is empty). How can I make sure those pages are included?
  11. Saving the fields instead of the page did the trick. Thanks!
  12. Craig, you make it look so easy! I think I almost have it, but I neglected to mention my checkbox is in a repeater. This seems to work (the echoes spit out what I expect) but the save doesn't seem to take: <?php $entries = wire('pages')->find("template=story"); foreach ($entries as $entry) { $entry->of(false); echo "<br>Checking checkbox on {$entry->title}...<br>"; foreach ($entry->tests as $test) { if ($test->old_check == 1) { $test->new_check = 1; echo "Converted {$test->scenario}<br>"; } } $entry->save(); }
  13. I have a checkbox field that I need to split into two checkboxes. Currently, the single checkbox determines whether a badge appears next to an entry on the front end, but now that badge should only appear if both checkboxes are checked. So when I add the second checkbox, I'll need all the old pages that were created when there was only one checkbox to now have both checkboxes checked so that the badge appears based on the new template logic. Any suggestions that would be more efficient than manually going through and editing all the old pages by hand?
  14. Thanks Adrian! I decided to just tack ProcessWire's page ID on the end if the story ID is a duplicate: public function changeName($event) { $page = $event->arguments[0]; if ($page->template=='story' && $page->story_id!="") { if (count($this->pages->find("story_id=" . $page->story_id))) { // uh-oh, we found another page with this story ID $page->name = $page->story_id . "-" . $page->id; } else { $page->name = $page->story_id; } } }
  15. I had no idea modules were so easy! Once I understood the basics of what was going on, I was able to quickly adapt the PageTree thumbnails module: public function addPageListLabelItems($event) { $page = $event->arguments('page'); if(count($page->story_id)) { $event->return = $page->story_id . " - " . $event->return; } } Then for the story ID URLs, I added a hook before save: public function init() { $this->pages->addHookBefore('save', $this, 'changeName'); } public function changeName($event) { $page = $event->arguments[0]; if ($page->template=='story' && $page->story_id!="") { $page->name = $page->story_id; } } However, this does still leave the edge case of someone entering an existing story ID and then having a name collision. What I want to do is check if the story ID already exists, and then increment this page's URL (the second instance of OP100 becomes OP100-2). However, my attempt at page search within a module is clearly not the right way: if (count($pages->find("story_id=" . $page->story_id))) { // this doesn't work
  16. One of my developer co-workers just gave me a few pointers and I've got it working now! $page_id = (int) wire('input')->get->pageid; $whichindex = (int) wire('input')->get->fieldindex; $whichfield = (string) wire('input')->get->fieldid; $p = wire('pages')->get($page_id); $p->of(false); $p->acceptance_tests->eq($whichindex)->set($whichfield, 1); $p->save("acceptance_tests"); Using set() instead of an '=' operator was all I needed to get around the return value / write context issue, and then I realized I should probably just save the entire repeater field instead of trying to save a part of it. Now, however, I come back to another issue that I was having earlier, for which I've only managed a hacky workaround: When checkbox_functions.php is in /templates/, I always get a 403 Forbidden when I try to access it via AJAX. If I just put it in the root, however, it works. I could just leave it this way, but I'd rather follow best practices and keep everything in /site/.
  17. So, here's what I have currently: $page_id = (int) wire('input')->get->pageid; $whichindex = (int) wire('input')->get->fieldindex; $whichfield = (string) wire('input')->get->fieldid; $p = wire('pages')->get($page_id); $p->of(false); $p->acceptance_tests->eq($whichindex)->get($whichfield) = 1; $whattosave = (string) $p->acceptance_tests->eq($whichindex)->get($whichfield); $p->save($whattosave); I've added two other arguments to the URL string that the AJAX calls, first to get first to the matching index of the repeater field on the page, then to one of two checkboxes in that repeater element. However, I get an error on line 11 about using a method return value in a write context. So apparently I can't use eq() or get() to specify the path to the field to update... but I'm not sure how I should be doing that instead.
  18. I've just been testing this module out and it's exactly what I need for this internal site I'm working on. I'd been getting some concerns from co-workers that the PW admin was a lot "heavier" than just writing in Google Docs, and Inline Editor will obliterate that concern. However, it looks like saving isn't working in ProcessWire 2.5: I click off a field, it says it saved, but no save actually took place (reloading the page reverts to the old version). Any ideas on where to look first?
  19. Wow thanks, that looks much simpler than I thought it would be! The jQuery part makes sense (AJAX call to a new PHP file that makes the PW request) but I'd love to get a better idea of what's going on in those five lines of PHP. I understand wire() just calls PW APIs when bootstrapped, but I'm not clear on what happens after that.
  20. As part of the Agile user story system that I'm in the process of building, each story has a list of acceptance tests that go with it. I have this list put together with a repeater, and I've added a checkbox to each test so that developers can mark it off as complete. What I really want to do, however, is not require developers to edit the page to check things off. They aren't writing the stories, only reading them, so I really want to find a way to give them a checkbox on the rendered page itself that can update the state of the checkbox field when they click it. The users viewing the page are already logged in (I'm using Adrian's Protected Mode module to lock down the whole site), so It seems like then first step will be to find the right Process API call to save a change to the page. The second step is probably harder, though, making all this happen from Javascript.
  21. Thanks, everyone. Adrian's solution should take care of my main problem, simply having a short permalink that doesn't have an old version of the title stuck in it. I'll see if I can find a URL scheme that includes the story ID that's also not too confusing, but it's not critical. Horst, I will look into that link on customizing the PageTree view.
  22. I'm in the process of building an internal tool using ProcessWire for my team to write and manage Agile user stories. (It actually started out as a quick prototype, but you know how things go with ProcessWire, I kept going for a few hours and suddenly had a pretty full-featured system. ) The way we do user stories, we have a story ID, such as "OP100", and then a title, such as "As an admin, I want to upload a PDF to attach to a user's account." I have these as separate fields, with the latter being the actual page title. These titles can get somewhat long, however, and can change throughout the lifecycle of a user story, breaking links from Pivotal Tracker. Ideally, I'd like to just use the story ID as the name / URL, so instead of "/as-an-admin-i-want-to-upload-a-pdf-to-attach-to-a-users-account/", the page would just be "/op100/". Further complicating this is that the story ID is optional (since a story can start out as just a concept that turns into an actual story later). So my ideal workflow would actually be one where the title creates the URL initially, but once there is a story ID, the URL changes to that (or even better, aliases to that). One more related thing I'm hoping to do is to concatenate the story ID and title in the admin. Any ideas on how to do this?
  23. I finally figured this one out. I had just about given up, when I thought to look in config.php, and lo and behold, there at the bottom was $config->httpHosts, which only contained the domains that were working. I added the other domains, and now the multisite module is working excellently.
  24. Looks like I have a different problem now with Multisite 0.2. The original site is continuing to work fine, but we just tried launching the second site, and it displays the first site at the second site's domain. I double-checked that both lines in the module's settings screen match the titles of the top-level pages, but it still only shows the first site's content at both domains.
  • Create New...