Jump to content

Rob

Members
  • Posts

    134
  • Joined

  • Last visited

Everything posted by Rob

  1. It should already be replacing the original page when you hit "publish", if it isn't, there's a bug! It was doing that fine in the original code before I made some changes based on Mindplay's suggestions. It now utilises a specific "preview" page to render unpublished pages where before the page just sat with its sibling (the original) and could be viewed like any other. It is essentially publishing a copy rather than overwriting so anything relating to existing page IDs will be corrupted (linked pages etc). I may revert the code back to it's original form and implement Ryan's "hidden" suggestion as it is a simpler and more elegant solution. Thanks for all the input, I'll get to work trying to sort all this out. Ryan - any pointers on overwriting the original page content rather than deleting original? Can I manually manipulate the ID? That way I could just copy but then update the ID to match the original, which seems like the fewest steps to the desired result.
  2. I've stuck the code on github, perhaps someone would care to give this a quick test before I publish it into the module repo here? https://github.com/robphilp/ProcessPageDraft
  3. That sounds plausible. I hadn't thought of having a specific page that handles the display of the drafts. It might well get round the problem of the published/unpublished state of the pages. I'll give it some thought - thanks!
  4. I've written a module that fulfils a small but hopefully useful need to provide clients with links to "live" but work-in-progress pages so they can be viewed by those that don't have a CMS login. The basic process is to add a "create draft" link to the page listing (after edit, new, move, delete etc). When clicked, this link creates a clone of the page and adds an MD5 hash of the current time to the URL so that a draft clone with an effectively "un-guessable" URL (name) is created that can be given out to clients to view the page. This clone has a "publish" link added to it in the page listing so this can then be copied over the original published page, and the draft deleted, with one click. The cloned pages also has "(DRAFT)" added to the title. Does this sound useful to anyone? The only problem is that, because the "draft" page is published it will show up in menu listings and anything else that is utilizing the site structure or API to grab live pages. If the "published" nature of the cloned pages makes this idea unworkable then I will go back to the drawing board! But if it has potential to be useful then I will at the very least publish the source on github or copy it in here so it can be tampered with by others. It occurs to me that it wouldn't be hard to filter out these pages with "(DRAFT)" at the end of the title so they don't show up in menu listings etc, but this would require extra effort on the part of the developer in every case where the fetching of pages is occurring.
  5. I live and work in London, so if I'm still about and I can afford this (or my employer!!) then I'll probably come along.
  6. Thanks Ryan. I've increased the session timeout and also disabled the session fingerprint and it works now. I tried it with just an increased session timeout and I had same problems, so it must be the dynamic IP issue you mentioned. I am on a consumer broadband provider at home so it may account for the issue. I don't have a huge understanding of these things, but I thought that the concept of dynamic IP meant that my home IP address will be allocated from a pool of addresses that the provider has. I didn't think it meant that the IP was shifting every few minutes or with every request, but I guess it must be if this is the cause of the session being lost. Thanks for the pointers.
  7. I've been giving the appfog.com service a spin and although, for the most part, it looks like a promising alternative to a traditional VPS or dedicated server, I'm having some weird behaviour with trying to login to my vanilla PW site that I've set up. Because, unless i'm mistaken, I can't do a regular install and have PW create the DB for me (the appfog architecture doesn't have a "root" DB user that has DB create priveliges), I basically created the entire site locally (in a linux VM with my dev tool in) then uploaded the code and synced the DB over to the DB service running on appfog. Now, I seem to sometimes be able to login to the site, and sometimes it rejects me and tells me to wait X number of seconds before I try again. A couple of days ago I couldn't log in at all, then today it let me in first go, but then a minute or two later it inexplicably logged me out again. Now I have similar sporadic behaviour. I log in eventually, then it randomluy logs me out again. The difficulty here is that, as is the case with a Saas, I don't know the full ins and outs of their system and how it's all setup, but their support tell me that file-based sessions ought to work and there aren't and unusal settings, file permissiosn etc. I can confirm that session fiels are being created within the filesystem of my app o ntheir servers, but for some reason it only sporadically seems to be able to access/use those session files or they are "timing out" in some way. I have checked the phpinfo() and nothing jumps out at me, file-based sessiosn are enabled with 180 second timeout, nothing unusual as far as I can tell. Does anyone else here use appfog? I have found threads here about phpfog but this is their newer, most likely quite different, system that can host a varierty of techologies, not just PHP. Any advice gratefully received!
  8. I'm using PW as a back-end but bootstrapping within a separate Silex site. So basically I have a totally separate site, I bootstrap the API by including the PW index.php then I use the API to grab my page data and do whatever I want with it. I'm trying to utilise Silex's session handling ability to store session in a DB for stuff like a shopping cart. Unfortunately it seems that's there's some sort of clash between the session handler registered by PW and the one registered by Silex. I've spent a lot of the afternoon reading around the subject and it seems like it's one of two outcomes; Either the two systems of session handling can be made self-contained from one another by each choosing a good time to call session_write_close() or it simply isn't possible to have two clashing sets of session handlers because the first "locks" the session data. I wonder if Ryan knows where it might be possible to add the session close code to make sure that PW only has it's handle on the session for the time it needs, or not at all when it's being accessed only via the API. I wonder if PW doesn't need to utilise any session handling at all if it's being used via bootstrapping, although I suppose that's probably a massive simplification of what is happening under the hood!! Any help gratefully received as I'm sure it should be possible to get these two nice platforms working together in sweet harmony. For anyone interested I'm trying to use PdoSessionHandler code as demonstrated here: http://silex.sensiol...on_storage.html
  9. Thanks Soma. Turns out it was the autoload status which had originally, by accident, been set to true and despite changing it back to false the code it was saved in the DB. I have changed it in the DB and now it seems to work.
  10. I am having a problem with my module code that seems to be loading my module JS code BEFORE the JQuery libraries and therefore I am getting a '$ is not defined' error. The weird thing is that I have used the exact same module code in a previous module and it loaded the module JS AFTER the JQuery so it worked fine, but in this case it is not working. public function init() { parent::init(); // add necessary admin page scripts // --------------------------------------------------------------------------------- $this->config->styles->append( $this->config->urls->ProcessTestSearch . "css/demo_table.css" ); $this->config->styles->append( $this->config->urls->ProcessTestSearch . "css/demo_table_jui.css" ); $this->config->scripts->append( $this->config->urls->ProcessTestSearch . "js/dataTables/jquery.dataTables.min.js"); //$this->config->scripts->append( $this->config->urls->ProcessTestSearch . "js/dataTables/dataTables.fnSetFilteringDelay.js" ); $this->config->scripts->append( $this->config->urls->ProcessTestSearch . "ProcessTestSearch.js" ); } Is there something I am doing wrong? Is there some way to control the order in which modules output the JS script links into the header? I presume this must be happening because, for some reason, the core JQuery module is being loaded after my module, and so therefore the scripts are being added after my module scripts.
  11. Thanks for all the help, my module is coming along nicely. The process of creating fields, templates and pages all on-the-fly makes me wonder if it's a good technique for creating blog-in-a-box type functionality. That is to say, being able to install a single module and have certain types of fields and pages immediately generated seems like a nice idea for beginners and less experienced users who are a bit intimidated by the "roll-your-own-schema" nature of Processwire. I understand that "site profiles" offer some of this, but to be able to one-click installation modules for common functionality that requires template types and custom fields might be easier than entire site installs or how-to tutorials that explain the manual steps. I might break this out into a separate thread for if it's worth discussion.
  12. Great, I'll try it, thanks! One more quick one while I know you're here!! I'm having trouble returning json data from an executeXYZ() fucntion in my process module. I originally had an ajax.php template handling the request but as mentioned in previous post, I have now tried having a code-created admin page with process attached to handle the request. Should I just be returning the json data from the executeXZY() method in my process module code? I use the following code to create page and attach the process to the page: $page = new Page(); $page->parent = $parent; $page->template = wire('templates')->get('admin'); $page->name = "imagerepo-handler"; $page->title = "Image Repo Request Handler"; $page->process = $this; $page->save(); I then have the following method to try to handle an ajax request and return some json: public function executeFetch() { switch($input->get->action) { case "fetchimages": $tags = $input->get->tags; $grabimages = wire('pages')->get('/processwire/page/imagerepo-handler/')->imagerepo->find("tags%=$tags"); break; } $data = array(); foreach($grabimages as $item) { $image = $item->data; $image['url'] = $item->url(); $data[] = $image; } return json_encode($data); } Any obvious problems with this code?
  13. Ryan - thanks for the pointers. The problem I'm having, however, is that I don't actually have a template php file, I'm creating a template, fieldset and fields and tying it all together within my module install() code. This all works fine so far, so I have a one-click module that installs some custom Inputfield modules, creates a template and then creates a page from that template. At this point I have a page under /processwire/pages/imagerepo that has a single images field that can be uploaded to etc. What I also want is for that page to be able to receive and process an ajax request. I added an executeXYZ() method but it is never being called because I can't work out how to trigger the ProcessController. I can't "attach" code to the (non-existent) template from within my module install method, so at present it seems like my only option is to create a second page that is of type admin and attach a process to that. This is no problem as such, it just seems to me that it would be cleaner to have a single page that handles all this as opposed to one page to hold the images and another to actually handle requests. This is all great module development practise so I'm not complaining!!
  14. Thanks. That seems sensible I suppose, but it just threw me because there is still a page for editing permissions for a superuser role. Perhaps it would be a good idea to change the interface to indicate the fact that individual permission control doesn't apply in that case.
  15. I've installed Ryan's page clone module, and it seems to work fine. However there is one thing confusing me. As far as I can tell, it creates 'page-clone' and 'page-clone-tree' permissions which my superuser role does NOT appear to have ticked in the roles management, and yet I can still copy pages as a superuser. Is this a bug? I ask not because it's a problem, but because I am developing more modules myself that tinker with the admin interface and add functionality (watch this space...) but I want to make sure I understand permissions/roles/access properly. I don't want to write code that is insecure or problematic because I don't understand the concepts properly. Thanks!
  16. Ryan - is it possible to create a page that has a Process attached but that also has fields as a normal page might? The context is that I want a page that has a couple of fields for storing data, but also a process attached so I can ping ajax requests and process them. I'm having trouble understanding if what I want to do is possible. It runs something like: 1. Create a module that install a bunch of other modules (fieldtype, inputfield, process), I know how to do this with "install" and "require" parts of module info. 2. Create a template (in module code) 3. Add a couple of fields to this template (in module code) 4. Create a page based on this template (in module code) 5. Attach process module to handle ajax requests (in module code) 6. save the page into the page tree (in module code) The idea behind all this is a one-click install of a system that creates a page that acts as an image repository (just a massive bunch of images with some extra metadata stored, tags etc), and install my custom field I have created that allows ajax filtering of the images stored on the repository page. I was hoping to develop this idea for the benefit of the community but I feel like it's no good if it involves many steps and lots of manual work! I am sure this must be possible one way or another, and I am determined to get it working. Soma has been a great help so far!
  17. I just had a look at that thread about dependencies. I knew it wouldn't be complicated, just had to get to the source! Cheers!
  18. Ah OK that makes sense in terms of assigning the process of a page to the module, but how do I get the module to install the process module? Or indeed get an InputField to install a FieldType, or vice versa? I guess it makes sense to create a page to handle the request, but I'd just like the process of installing all these related modules be a single step, rather than having to manually install multiple modules, and that's the bit I can't work out how to do.
  19. That's essentially what I'm already doing, and I think it's a bit messy, but I accept it's a slightly messy thing I'm trying to achieve! If I wanted to make the process a one-click install in a self-contained module, could I install the Fieldtype/Inputfield modules, the process module, create the admin page and attach the process module to that page all from a module code? I believe that modules can express dependencies on other modules, but can modules automatically install other modules? Thanks for the help!
  20. I was looking into this, and that's what had occurred to me. What I can't figure out is how to attach a process module to a page. On the pages underneath admin, there has been a "process" field attached to the template, but I don't have that field available on regular page templates. Am I missing something? (I know the answer is yes!)
  21. I've built a custom InputField module that consists of 2 combo boxes. When the value in the first is selected, it pings an ajax request to the server to fetch values for the second combo box. At present I have had to create a new page with the processing code in the template (and nothing else) to handle this request. It's not very self-contained (InputField and Fieldtype files including JS, plus totally separate request handling page created by hand) so I wondered if I can have a method in my InputField/Fieldtype code to handle the request if I post that request to the same page it is part of? i.e. post it to itself (the current page). Thanks in advance.
  22. Thanks chaps! I had tried that and thought it wasn't working, but in fact it was. What was happening was that I had pulled an entire page of data, then was trying to "overwrite" one part of it with the filtered version of itself. Trying to overwrite an object with an array = bad news!
  23. I have a repeater field where one of the constituent fields is a checkbox for whether the repeater item is "live" or not. What I want to do is fetch only those items from the repeater field where the "live" value is checked. Is this possible? Thanks.
  24. I'm sure this must have come up before in the forums but I couldn't find anything. It would be nice to have a history of page version and rollback / rollforward ability. If a user edits a page and wants to preview their changes before going "live", unless I am mistaken this isn't currently possible. You could mimic this behaviour but it wouldn't be a clean workflow. I was thinking about the repeater functionality and this essentially seems to re-utilise existing page behaviour. Perhaps it would be possible to utilise a similar approach by creating "mirror" copies of pages under some /admin/versions location in the page tree and use this as a storage for page versions. Theoretically it would then be possible to preview versions, rollback etc and still use core PW functionality that is already in place rather than having to write a whole mass of new code. I am happy to have a crack at this myself but I thought if I put the idea out there the community will likely have much more advanced module coders than me who may be interested in the idea. To recap: If we could have a save->preview->publish workflow by saving copies of pages under a "hidden" location in the page tree then it would create the ability for users to safely make edits, check them etc before going live, and also revert to old version if necessary. Any takers?!
  25. Apeisa - I actually agree with most of those points and even using PW as-is, without any extra flourish, it's still much easier and more flexible than 90% of other CMS I have used in 10+ years of web development, and would do fine "out of the box" for 90%+ of typical web agency situations. Regarding the use of Silex with PW, it's really very simple. Silex is a microframework that provides a very simple mechanism for mapping regex-based URLs to a methods (actually closures, so PHP 5.3+ only), where you can stick some code. Because it is based on Symfony2, it is built to a very robust standard with best practise in mind and can make easy use of many great Symfony2 components such as Request/Response objects (HTTP handling), Twig templates, DB access with Doctrine, Session handling and many other useful bits. In a nutshell - you map a URL to a method and in that method you use the PW API to grab data and inject into a Twig template. That's it. Your URL structures can be as simple or complex as you like with placeholders for dynamic parts e.g. canonical URL segment of blog post or the DB record ID etc (just the variable bits) and you can enforce regex rules on those parts to ensure they match a certan format. It might seem like a lot of fuss, but it isn't really and the Twig templates are a joy. They're clean, secure, you can extend with new tags, perform all sorts of processing and iterating of data, and templates can extend each other so you can have more generic templates that get extended with specific functionality as you need it. It measn that building a slight modification of an existing template can be done very easily and in a way that doesn't have to tamper with the original at all, just like a class hierarchy in OO code. http://silex.sensiolabs.org/ http://twig.sensiolabs.org/ I'm a bit of a Sensiolabs fanboy to be honest, and I think Fabien Potencier and the Sensiolabs team come across as being the cutting edge of PHP development. Symfony2 is a great framework, Twig is brilliant, Silex is very easy but powerful and everything they do seems to have a real sense of quality craftmanship. In combination with the excellent data modelling power (and excellent back-end interface) of Processwire, it's a good combo!
×
×
  • Create New...