-
Posts
4,632 -
Joined
-
Last visited
-
Days Won
55
Everything posted by apeisa
-
Great to hear this! UPDATE: Ryan did release this Page Link Abstractor -module (I am editing this reply from the future): http://processwire.com/talk/index.php/topic,280.0.html
-
Good catch and great solution. I committed your changes (git & github is great!). I started thinking if something similar could be done with normal links (in tinymce) when using page picker? It's always bad solution if you change urls, but clients do that all the time and forget redirects... If pw could somehow keep track of page id, then it would be great! It might even remove links if you delete page that have incoming links (and warn user about this).
-
I like it too, great job! Also interested to hear more about how you are using this. Sometimes would be nice to have small css-snippets per page, without adding body.page-2323 hooks to normal css, or external files per page, if chance is very small. if($page->css) { echo "<style> /* Some css just for this page */"; echo $page->css; echo "</style>"; }
-
Have you tried $users->delete($user)? Where $user is actual $user object (not username). So probably something like this: $u = $users->get('username'); $users->delete($u); Documentation for $users is missing and probably will be until Ryan finishes his work building the new user management.
-
Just pushed a new version to github: Ability to paste comma separated list of urls like this: redirect_from,redirect_to Counter for # of redirects made (hits) Page picker Css problems fixed Module needs to be uninstalled & re-installed or manually add 'counter' field to database table. Uninstall drops whole table, so be careful.
-
Ryan: page picker works nicely. I also submitted this to github, so future downloads from here: https://github.com/apeisa/ProcessRedirects/archives/master
-
Just started first plans how we will manage our pw-sites and I am really looking clean git based solution here. It is a bit challenge since I am pretty much learning git at the same process (coming from svn camp). As git doesn't offer ability to clone subdirectories, it is little bit messy to clone whole processwire-project and default site. As pw is so modular, I think those (wire & default site) are pretty much different projects. Here is similar situation and discussion about that: http://stackoverflow.com/questions/600079/is-there-any-way-to-clone-a-git-repositorys-sub-directory-only
-
Ryan, any help on how to implement this page picker?
-
Heh, I didn't see those since I have alternative admin theme where these don't occur. I probably should use normal theme when developing modules Counter is simple and nice idea, I will implement that soon. About csv-import: not in my needs, but this is also pretty simple, so I might implement that soon too Of course, if someone else wants to add that (or any other) functionality, you are welcome. Maybe I push this one to GitHub also..
-
Just when going to sleep I came up with simplest solution for "importing a bunch of urls". So now there is textarea where each line behaves like different input. So you can easily import 40 urls and initially set those all redirect to /products/ page, and after that edit those to add more accurate redirects if you need to.
-
I updated the download to allow urls like: /page.html, /products/product.php?id=123
-
Thanks for the feedback. Both are valid points. When thinking of scope of this project (quickly to get some tool to manage redirects without polluting page tree) I am more than pleased how this turned out. Only in two days fully functional tool that works well. This said, this is very much work in progress and all the input and help is welcome. What comes to ability to redirect urls like .html or .php that can be done and I'll fix the script a little bit to allow that. Ability to import larger number of pages: db table is very simple, so simple sql is what I would do. But I kinda like your idea of easy importing and then also giving page selection to "Redirect to" field is nice (not only on imported urls, but always).
-
I think we are ready here: http://processwire.com/talk/index.php/topic,171.0.html
-
This module adds page to Admin -> Setup -> Redirects where you can add 301 redirects (inside your site or to other domains). Screencast: http://www.screencast.com/users/apeisa/folders/Jing/media/e29abcca-5ef0-44dd-ac9a-2cc70f53d2c6 (I have Chrome with Instant on so it previews pages before hitting enter.. but I'm too laze to record another screencast. Also there is sneak preview to my upcoming admin theme...) Download & Installation: https://github.com/apeisa/ProcessRedirects/archives/master, unzip all the files to /site/modules/ProcessRedirects/ folder, check new modules from bottom of the modules page and hit install on ProcessRedirects. More information and "tutorial" how this was done can be found from here: http://processwire.com/talk/index.php/topic,167.msg1071.html (and like you can see, most of the code came from Ryan's hands, I just wrapped it all together). Hope you guys find this useful. Not tested yet on many servers, so all the feedback is more than welcome. ProcessRedirects5.zip
-
Thank you Ryan! As always, this was super helpful. Just filling the blank spots and fixing few typos and that's it We have now CRUD ready. There is few questions at the source, but it is pretty much working now. I also moved it under setup, so Redirects won't pollute the main menu at the admin. Few little issues and after that only grabbing the new hook to make actual redirects. <?php class ProcessRedirects extends Process { public static function getModuleInfo() { return array( 'title' => 'Redirects', 'summary' => 'Manage url redirects', 'href' => 'http://processwire.com/talk/index.php/topic,167.0.html', 'version' => 100, 'permanent' => false, 'autoload' => true, 'singular' => true, ); } public function init() { } public function ___execute() { $this->setFuel('processHeadline', 'Redirects'); $table = $this->modules->get("MarkupAdminDataTable"); $table->headerRow(array('Redirect From', 'Redirect To', 'Delete')); $result = $this->db->query("SELECT * FROM {$this->className}"); while($row = $result->fetch_assoc()) { // output in table rows with edit link and delete checkbox? $table->row(array( $row['redirect_from'] => "edit/?id=$row[id]", $row['redirect_to'] => "edit/?id=$row[id]", //This actually doesn't work, row 40 at MarkupAdminDataTable class encodes this //Should I build custom table or should we extend AdminDataTable? "<input type='checkbox' name='delete[]' value='$row[id]' />" )); } $button = $this->modules->get("InputfieldButton"); $button->type = 'submit'; $button->value = 'Remove selected redirects'; $table->action(array('Add Redirect' => 'edit/?id=0')); // Is there clean way to add button to right side? return "<form action='./delete/' method='post'>" .$table->render() . "<span style='float: right'>".$button->render() ."</span>" . "</form>"; } /** * Edit/Add Redirect - Called when the URL is: ./edit/ * */ public function ___executeEdit() { $this->fuel->breadcrumbs->add(new Breadcrumb('../', 'Redirects')); $id = (int) $this->input->get->id; if($id > 0) { // edit existing record $result = $this->db->query("SELECT id, redirect_from, redirect_to FROM {$this->className} WHERE id=$id"); list($id, $from, $to) = $result->fetch_array(); $this->setFuel('processHeadline', "Edit Redirect"); } else { // add new record $id = 0; $from = ''; $to = ''; $this->setFuel('processHeadline', "Add Redirect"); } $form = $this->modules->get("InputfieldForm"); $form->method = 'post'; $form->action = '../save/'; $field = $this->modules->get("InputfieldHidden"); $field->name = 'id'; $field->value = $id; $form->add($field); $field = $this->modules->get("InputfieldURL"); $field->label = 'Redirect from'; $field->description = 'Enter relative url with slashes, like: /summer/'; $field->name = 'redirect_from'; $field->value = $from; $form->add($field); $field = $this->modules->get("InputfieldURL"); $field->label = 'Redirect to'; $field->description = 'Enter a valid URL, i.e. www.otherdomain.com/dir/ or relative url like /season/summer/'; $field->name = 'redirect_to'; $field->value = $to; $form->add($field); $field = $this->modules->get("InputfieldButton"); $field->type = 'submit'; if($id > 0 ) { $field->value = 'Update Redirect'; } else { $field->value = 'Add New Redirect'; } $form->add($field); return $form->render(); } /** * Save Redirect - Called when the URL is ./save/ * */ public function ___executeSave() { $from = $this->sanitizer->url($this->input->post->redirect_from); $to = $this->sanitizer->url($this->input->post->redirect_to); $id = (int) $this->input->get->id; // perform save of existing record if id>0, or add new if id=0 if ($id > 0) { $sql = "UPDATE {$this->className} SET redirect_from = '$from', redirect_to = '$to' WHERE id = $id"; } else { $sql = "INSERT INTO {$this->className} SET redirect_from = '$from', redirect_to = '$to';"; } $this->db->query($sql); $this->message("Saved redirect from \"$from\" to \"$to\""); $this->session->redirect("../"); // back to list } public function ___executeDelete() { if(!is_array($this->input->post->delete) || empty($this->input->post->delete)) { $this->message("Nothing to delete"); $this->session->redirect("../"); // back to list } foreach($this->input->post->delete as $id) { $id = (int) $id; $this->db->query("DELETE FROM {$this->className} WHERE id=$id"); $count++; } $this->message("Deleted " . $count . " redirect(s)"); $this->session->redirect("../"); // back to list } public function ___install() { parent::___install(); $p = new Page(); $p->template = $this->templates->get("admin"); $p->parent = $this->pages->get("template=admin, name=setup"); $p->title = 'Redirects'; $p->name = 'redirects'; $p->process = $this; $p->save(); $sql = <<< _END CREATE TABLE {$this->className} ( id int unsigned NOT NULL auto_increment, redirect_from varchar(255) NOT NULL DEFAULT '', redirect_to varchar(255) NOT NULL DEFAULT '', PRIMARY KEY(id), UNIQUE KEY(redirect_from) ) ENGINE = MYISAM; _END; $this->db->query($sql); } public function ___uninstall() { $p = $this->pages->get('template=admin, name=redirects'); $p->delete(); $this->db->query("DROP TABLE {$this->className}"); } }
-
What is the best way to add blogging to my site?
apeisa replied to srbobc's topic in Getting Started
Hi and welcome to the forums srbobc! If your clients blogging needs are relatively simple, you could easily create new template like "blogentry" and add it fields like "title", "datetime", "body", "images", "comments" (http://processwire.com/talk/index.php/topic,76.msg405.html#msg405) and maybe "categories" (page) and stuff like this. Then it would be probably wise to add also template "blogfront" where you could render latest blog posts that are children of that page, with pagination of course (and if you are using categories, then allow url segments and render posts from those categories also). This might sound much more complicated than it is, but simple news listing, product list, blog etc is very straightforward to setup after you do it once. Customizing it exactly for your needs is where pw is at it's best: you have full control of every aspect of the output. If you need a lot more features, and maybe not so much control, then your best bet would probably be blogger, wordpress or something like that. Of course one possibility is to run self hosted wp and pw (wp & pw, hehe) side by side. Anyone done that yet? -
I started working on this, and I have a good start already. As last time when developing a module I find pw codebase very fun and easy to work with. Usually when looking for other coders work I don't have clue what is happening, but this stuff actually makes sense for me Here is what I have so far: <?php class ProcessRedirects extends Process { public static function getModuleInfo() { return array( 'title' => 'Redirects', 'summary' => 'Manage url redirects', 'href' => 'http://processwire.com/talk/index.php/topic,167.0.html', 'version' => 100, 'permanent' => false, 'autoload' => true, 'singular' => true, ); } public function init() { } public function ___execute() { $out = "Hello world! Here we will have CRUD for redirects."; return $out; } public function ___install() { parent::___install(); $p = new Page(); $p->template = $this->templates->get("admin"); $p->parent = $this->pages->get($this->config->adminRootPageID); $p->title = 'Redirects'; $p->name = 'redirects'; $p->process = $this; $p->save(); // I want different permission to view and to add/edit/remove redirects $this->installPermission('Edit'); } public function ___uninstall() { $p = $this->pages->get('template=admin, name=redirects'); $p->delete(); } } What classes should I use for creating simple crud for this? Table will be super simple with only two datafields (pw_path & redirect_href), so this would be easy to create in custom way, but I would like to this using pw classes as much as possible.
-
Thanks for great answer. I have upcoming site with about 60 urls that need 301 redirect and I actually don't like doing this on .htaccess file since those old urls are also clean ones. So there is nothing like products.cfm?id=3232 that I could map. These are all custom ones so it might add lot's of confusion later on if these are "hidden" .htaccess file. I think this would be cleanest solution here. If there is a page, no redirect can be done (unless done at template level like described above). What I was thinking about would be new admin page: Redirects and also new permission "ProcessRedirects". Small custom table for permissions, which only holds two fields: pw_path and redirect_href, which take values like: /summer/ & http://www.domain.com/products/summer-special/ I'll start diving into this right away. I hope to get something released soon enough. Ryan, I probably need some help with permissions, but otherwise I have pretty good clue how this works (well, we'll see ).
-
Is there any tool for managing 301 redirects? These can be configured on code or server level, but it is often needed to offer possibility to clients to add new redirects (or at least see what redirects there is). This is very important when making redesign and if url schema changes. It is easy to create this at template level, so any page could be redirect to another page, but this is good for short urls (ie. www.domain.com/campaign/ => www.domain.com/products/offers/super-offer/) and should be 302 redirect. In larger usage it pollutes page tree. So what I would like to see is somekind of tool for adding/editing/removing permanent redirects. Is there something like that? If I would build that as a module, what would be best route?
-
Glad that I could help. I don't know if there is better off the shelf solution for your problem. If I understood correctly you need something similar like images field, but for video with few variables + image. This is probably something that was discussed here: http://processwire.com/talk/index.php/topic,53.0.html (repeatable elements, matrix). So for now you would need to create custom fieldtype or use what you have now (template and subpages). Of course my knowledge is limited on this issue so someone might know better answer for this.
-
This can be done with "Page" field. Here is quick guide how to do it: Create page "Categories". Under that page create all the categories you need to appear in dropdown (select field). I usually set up template called "pagereference" that has only title-field for this use, but actually any template is ok here. Then on page where you need this category variable you set new field called "Category" and set it as "Page" type. Then on "Parent of selectable page(s)" setting choose page "Categories". That's it. It may sound weird at first to use pages like this, but it is actually pretty brilliant and possibilities are endless. Of course in simple usage (like this) something more simpler (field type) could be nice and if I remember correctly there was some talks about "tag type" or something like this. But when you start building more complicated sites with more relations, then it is nice to have same logic everywhere. But this is how you can do it now and this is pw-style of doing this. It is also common practice (well, heard from Ryan and I like to use it too ) to set page like "Tools" and put page "Categories" under that page. This way your page tree will stay clean and organised.
-
Using tinymce it is pretty easy to create <a>empty links like this</a>. I you forget to click select on page you want (so that "Link to url" is empty), then empty url is created. After you edit page again, it cleans the empty links away. Not a big issue, but I'm pretty sure that some editors will make this mistake.
-
I see it as a valid and possible scenario that client uploads file with similar name. This was also very quick to test and this was result: I uploaded file "hyatt_interior9.0x100.jpg" to page 1 of demosite (which already had that file) and result was: "hyatt_interior9.0x1001.jpg". So it adds running number on filename.
-
I installed this on localhost. Very subtle but nice chances. Good work!
-
Thanks for this, now I understand how roles work.