Jump to content

onjegolders

Members
  • Posts

    1,147
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by onjegolders

  1. Update, thanks Reno, I've got it working now, not sure entirely what wasn't working before but now it's doing the job Below the code in case it helps someone at a later date <?php class BlogRedirect extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Redirects back to front end journal', 'version' => 101, 'summary' => 'Redirects back to front end journal page.', 'singular' => true, 'autoload' => true, ); } public function init() { $this->pages->addHookAfter('save', $this, 'redirect'); $this->pages->addHookAfter('trash', $this, 'redirect'); $this->pages->addHookAfter('trashed', $this, 'redirect'); } public function redirect($event){ $page = $event->arguments(0); $errors = false; // check notices for errors before redirecting foreach(wire('notices') as $notice){ if($notice instanceof NoticeError) $errors = true; } // if errors if ($errors) { return; } // if no created date is set it means just generated so don't redirect if ($page->created == 0) { return; } // set return URL $goto = wire("pages")->get("template=journal")->url; // if it's one of the chosen templates, redirect if ($page->template == "blog_post" || $page->template == "gallery_post"){ wire("session")->redirect($goto); } } }
  2. Thanks Reno, don't worry if you didn't read it that closely, it was pretty long Probably could have asked in a couple of lines! Do your pages manage to save correctly before they redirect? Cheers.
  3. Hi Horst thanks for your reply but I think it is "pages" i get a system error when i try with "page".
  4. I'm trying to create a simple module that on pages of a certain template, when they are saved, redirect to the front-end. The thinking here is that I have created simple front end buttons on a blog to add either a "gallery post" or a "blog post" (different template same parent). I don't really want to handle the uploading of images part in the front-end and so would like to use the admin for the post creation but I would like the user to return instantly to the front end when they have added their new post. When they click the relevant front-end button, the relevant page gets created with the required template. They get sent to the newly created admin page where they can add their content. Front end bit: <?php if ($user->isSuperuser() && $input->get->type == "blog") { $new_post = new Page(); $new_post->of(false); $new_post->parent = $page; $new_post->template = "blog_post"; $new_post->title = "New Blog Post"; $new_post->save(); $session->redirect($config->urls->admin . "page/edit/?id=" . $new_post->id . "&new=1"); } if ($user->isSuperuser() && $input->get->type == "gallery") { $new_post = new Page(); $new_post->of(false); $new_post->parent = $page; $new_post->template = "gallery_post"; $new_post->title = "New Gallery Post"; $new_post->save(); $session->redirect($config->urls->admin . "page/edit/?id=" . $new_post->id . "&new=1"); } ?> <?php if ($page->template == "journal" && $user->isLoggedin()) { ?> <a href="<?php echo $page->url . '?type=blog'; ?>">Add Blog Post</a> <a href="<?php echo $page->url . '?type=gallery'; ?>">Add Gallery Post</a> <?php } ?> This works fine, creates the page with the right template and redirects to the correct admin form page. Now when they have added their content, I would like them to be redirected to the front-end to see the immediate effects of their new post. I've created the module but I'm having trouble finding the right combination of hook and before/after. So far I can either seem to manage the redirect without the changes or save the changes but the redirect doesn't take effect. This is the basic module I have so far but obviously the hooks/processes are incorrect. Does anyone have any experience of getting this working? Thanks <?php class BlogRedirect extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Redirects back to front end journal', 'version' => 101, 'summary' => 'Redirects back to front end journal page.', 'singular' => true, 'autoload' => true, ); } public function init() { $this->pages->addHookBefore('save', $this, 'redirectToBlog'); } public function redirectToBlog($event) { $page = $event->arguments[0]; $session = wire("session"); // make sure that the initial create page doesn't redirect if ($page->parent->template == "journal" && $page->id) { $session->redirect("http://localhost/route66_pw/journal"); } } }
  5. Just installed the Default version of 2.5 and wanted to say what a nice job has been done of the front end default styling. Not sure who's responsible as I've been somewhat out the loop but I think it's a nice first "Welcome to PW', with a very modern and minimal feel. Less opinionated than the classic in my opinion. Good job
  6. This looks like a fantastic piece of work, great job! But like Pete, I hadn't even noticed PageTable field yet , I got it from Reno's tweet!
  7. Ryan, a huge thank you for all the recent changes. The speed of the development at the moment is very exciting. I also think you have a "knack" of prioritising what's important and I very much trust your vision for the future. I think the drafts module is a nice idea but perhaps something that can be a funded, 3rd party module rather than part of the core. I wanted to point out on the version I'm testing (2.4.15), when you choose whether a template can have children/new pages, the fields below stay visible, whereas they used to collapse as appropriate, not sure if this is intentional (it's certainly not a big deal )
  8. Would they display as you are logged in as superuser?
  9. Thanks Adrian, you nailed it! I guess I wasn't getting the right combination to the full path. $file->filename works perfectly
  10. Hey guys, I'm creating a form via the API where a user can create a page and click to "create and duplicate". The idea is that this reloads the form with a GET variable to the page just created, takes the image from that page and also adds it to the new duplicate page. Essentially there may be 4 pages created but they should all share the same file. Would it be necessary to create a new WireUpload on every page creation or is there some way to do the following (or some variation): $duplicate_page->file->add($just_created_page->file); OR $duplicate_page->file->add($just_created_page->file->url); I don't seem to be able to pull this off but perhaps it's because the WireUpload needs to take place on every page creation.. Anyone had any experience with this? Thanks
  11. Thanks Antti, I wasn't setting the template access in the admin properly. Working nicely now
  12. Hi guys, Hope you're all doing well. I haven't ever really considered secure files before on a PW installation but am currently trying to convert an unsecure system (the folders and files already exist) to a secure one. I've updated config.php to enable secure files and left the default "-" as the prefix but am a bit confused as to what is supposed to happen now. Are the folders supposed to be renamed automatically (doesn't seem to be the case at present) or is this something that only applies to new files? EDIT: Doesn't appear to be adding the prefix for new files either. Can someone tell me what the default behaviour is supposed to be here as I'm unsure whether this is the issue before I get any further. Thanks.
  13. Did Joomla! make some sort of incredible change of direction and become a great tool or is this plain ridiculous?
  14. I think 4 or 5 should be pretty simple to implement. It's fair to say there's no plug-and-play way of making this happening but then that isn't really what PW is about. You will be surprised the first time you build something like this yourself from scratch will be a big "Aha!" moment. It was for me and I think for many others too. It's almost always simpler than you think, and it has the advantage of being exactly how you want it. You could for instance create a "messages" and "message" template, each new "message" would have a sender and recipient (both "page" fields), perhaps also a send time. When someone fills in a message, it uses the $user variable for the sender. Essentially each new message could be a new page.
  15. Valan, I think PW's great independent success owes a lot to it not being like other CMS. It is a strong tool for building websites. It is not trying to be a new Wordpress, there is little to be gained (as far as I see it) from trying to bridge the gap between the two. Rather to keep working on what makes it special and flexible ( a great example of this are the new pro tools) Give us more power but not more bloat
  16. Hi Alec, I would imagine that probably the easiest way to go here would be using GET parameters through $input->get https://processwire.com/api/variables/input/
  17. Hi Pravin, That would simply be a case of including a different bit of code for each template. So it could be: home.php // Main content here <?php include("./sidebar.inc"); ?> special.php // Main content here <?php include("./alternate_sidebar.inc"); ?> That's if I'm understanding your question correctly?
  18. Hi Nikola, Thanks for all your work on this. Ergo was by far my favourite admin theme so far (although I removed the sidebar on my installations) Something much more clean and modern than the classic rounded corners and multi colours of other themes (though I appreciate that is probably a personal preference). I'm also excited to see the start of configuration options for admin themes. Early days but there may come a time when we can take greater control of the backend layout. Also, I'm in awe of anyone taming jQuery UI CSS - I'm currently trying to create a theme and it's an ABSOLUTE PIG
  19. Are you adding Videos as URls (from Youtube etc) or as an actual video file? OK you solved it
  20. (Also answered on FB) Christian, I'm thinking it's just a question of reformulating the CSS. The admin theme is just a combination of HTML, PHP, JS and CSS
  21. It sounds like ProcessWire will be a perfect fit for you. It does genuinely do what you are looking for. It is a tool you can use how you see fit. It does not dictate how you should work. In terms of organising fields. If you click on the "advanced" tab on a field page you can apply a tag. This tag will help organize the fields. (Also applies for templates)
  22. Hi Soulsliver, welcome to PW! Could this have something to do with the "!" in your folder name? Can you reach the homepage of your new site?
×
×
  • Create New...