Leaderboard
Popular Content
Showing content with the highest reputation on 12/20/2016 in all areas
-
This is how i do it: function getComments($comments, $page, $parentID = 0, $reply = true, $child = null) { $out = ""; foreach($comments as $comment) { if($comment->parent_id == $parentID) { $reply = ($reply == true) ? "<a class='CommentActionReply comment-reply-link' data-comment-id='{$comment->id}' href='#Comment{$comment->id}'>Reply</a>" : ""; if($comment->status < 1) continue; $cite = htmlentities($comment->cite); $text = htmlentities($comment->text); $userID = $comment->created_users_id; $u = wire("pages")->get($userID); $name = ($u->displayName) ? $u->displayName : $u->name; $date = date('m/d/y g:ia', $comment->created); $out .= " <div class='{$child}'> <article id='comment-{$comment->id}' class='comment-body single-comment'> <header class='comment-meta'> <img src='{$u->avatar->size(75,75)->url}'> <strong>{$name}</strong> <a href='{$page->httpUrl}#comment-{$comment->id}' title='Link to comment' class='comment-link'><time datetime='comment_date'>{$date}</time></a> </header> <div class='comment-content'>{$text}</div> {$reply}"; $out .= "</article>"; $out .= getComments($comments, $page, $comment->id, false, "child-comment"); $out .= "</div>"; } } return $out; } // and use in the template file echo getComments($page->comments, $page); If you have trouble understanding let me know and i'll explain, going to sleep now.4 points
-
3 points
-
Yes, it's still true today (that's PW 3.x). If you can though, I'd urge you to migrate to PDO3 points
-
$articles = $pages->find("parent=/archive/, limit=10, id!=[parent=/archive/, start=0, limit=10]"); I'm not sure if subselectors support limits, so maybe you need to run it as it's own $pages->find() before this line.3 points
-
Depending on whether the last row needs to have a complete set of elements (not sure if bootstrap's css requires that), you could also use PHP's builtin array_chunk function to make the logic clearer. $out = ""; foreach(array_chunk($page->children->getArray(), 3) as $row) { $out .= "<div class='col-xs-4'>"; foreach($row as $p) { $out .= "<img src='{$p->images->first->url}' class='img-responsive'>"; $out .= $p->title; } $out .= "</div>"; }3 points
-
New version now supports running actions via the API. Here's an example of copying content of a field from one page to another. Simply load the module, and call the action class name as a method while passing the required options as an array: $options = array( 'field' => 99, 'sourcePage' => 1131, 'destinationPage' => 1132 ); $modules->get("ProcessAdminActions")->CopyFieldContentToOtherPage($options); Hopefully you'll find a use for this in your hooks or template files.2 points
-
Hi @AndZyk it is not only that the Quality is affected, it results in higher filesizes too, sometimes. Im on mobile now. I May post a link later on, where you can see a comparison.2 points
-
Are you adding to a repeater field or a normal field? My code was for a normal field. If copying from REPEATER to REPEATER...then check out this thread2 points
-
Indeed there is In fact, the button I want to style has almost the same class, so I suppose I could use javascript as mentioned by @BitPoet and match the body class with the element in the topnav and act accordingly. Good suggestion! So here's what I came up with, a working example: ready.php if ($page->template == "admin" && $page->name == "settings-appearance") { $input->get->id = $pages->get("/settings-appearance/")->id; $config->scripts->append($config->urls->templates."scripts/admin.topnav.js"); // Give nav button active state. } admin.topnav.js $(function() { /* Make the topnav navigation button active that points to the current page that was added to the topnav manually. Search for a class on the body element that starts with 'id-' and add the 'on' class to the button if the button has a similar class. */ var bodyClasses = $('body').attr('class'); var pageClass = bodyClasses.split(" ").filter(getPageClass); function getPageClass(value) { return value.indexOf("id-") === 0; } // The navigation button in the topnav element should have a class name like 'page-id-1058-'. var btnClass = '.page-' + pageClass + '-'; $('#topnav').find(btnClass).attr('class', 'on'); }); The javascript should work for any page you add to the top navigation bar since it matches page ID's from the body element's class attribute to the page ID in the navigation button's class attribute. So you don't have to set any page ID's manually in the javascript. Note that this only applies to the default admin theme. On Reno theme it is not necessary.2 points
-
In recent PW3 versions you can prepend "http" and get absolute urls like this: $config->urls->httpTemplates2 points
-
According your markup you could also use CSS to format the list, eg using n:th-child or column-count.2 points
-
Hi, I recommend doing some basic system design to sort out the relationships you will be dealing with. Here is a good article from @clsource on this: https://medium.com/@clsource/understanding-processwire-templates-fields-and-pages-201aecd0a1a4#.m9yquavll Next, decide what sort of Inputfields you will utilize in the admin in order to realize the relationships (look for 3rd party Inputfield modules too, but check PW 3 compatibility before you start using them). Start with the Page Tree, and decide what you want to present there, and other relationships can be represented by the selected Inputfields. You can start by working on both the frontend and the backend at the same time. If you are a solo developer, you will not be able to separate the two anyway. Thinking of "fields -> pages -> templates" isperfectly fine, but you can implement them in any order you see fit. "Is the product page that the "normal" user see in the front-end, the same that the vendors have access in the back-end?" It cannot practically be the "same", except if YOU for some reason implement it this way. You can give normal users (customers) limited access to the admin, but it all depends on your needs. Probably you only want to give partial access to the backend for vendors only. Normal frontend users (customers) will likely be better off with your own custom implemented frontend UI access. Hope this helps2 points
-
...And there was the problem! I got an ad-blocker installed causing this issue on chrome. Unfortunately nowadays a lot of people have them turned on. I'm going to investigate for a workaround, but It is kind of a remarkable issue for my project In the meantime thanks for your support.1 point
-
Getting a little OT here, but @Juergen - if this is incorporated into Admin Actions, you could call it via the API like this: $options = array( 'field' => 99, 'sourcePage' => 1131, 'destinationPage' => 1132 ); $modules->get("ProcessAdminActions")->CopyFieldContentToOtherPage($options); Yes, that action should be improved to also handle field names (not just IDs), but you get the idea.1 point
-
@workdreamer There is a way to override core modules, but it is certainly not the best way to handle the situation here in my opinion. But still an option. And welcome to the forums, man! You've found a thing to work on you could only dream of!1 point
-
@3fingers So, all the resources are loading - and there are no errors - and there is no output? Ok - is this on a local development box or on a server I can take a look at? Edited to add: I have seen a correctly set-up map fail to load if a browser is blocking scripts using an extension like noscript/umatrix/ublock-origin etc.1 point
-
@adrian....was just thinking about that1 point
-
This sounds like a handy AdminAction Not specifically from the parent to child page, but a general one for copying/moving from one page to another. Not sure if it would be best as a new action, or incorporated into the logic of the "Copy Field Content To Other Page" action which currently only handles basic text based fields. I would like to extend this to support all field types.1 point
-
Thanks again everything is working fine. I'm just fine tuning the form output. I'm pasting my code so someone with same problems can quickly view how to customize it based on your initial answer I had to add $childFinish since my child output was in UL tag: <?php function getComments($comments, $page, $parentID = 0, $reply = true, $child = null, $childFinish = null) { $out = ""; foreach($comments as $comment) { if($comment->parent_id == $parentID) { $reply = ($reply == true) ? "<a class='comment__reply js-comment-reply CommentActionReply comment-reply-link' data-comment-id='{$comment->id}' href='#Comment{$comment->id}'>Reply</a>" : ""; if($comment->status < 1) continue; $cite = htmlentities($comment->cite); $text = htmlentities($comment->text); $userID = $comment->created_users_id; $u = wire("pages")->get($userID); $name = ($u->displayName) ? $u->displayName : $u->name; $date = date('m/d/y g:ia', $comment->created); $out .= $child . " <li class='comment__item'> <div class='comment__item-body js-comment-item'> <div class='comment__avatar'><img src=" . wire('config')->urls->templates . "rs-template/assets/media-demo/avatars/01.jpg alt=''></div> <div class='comment__item-right'> <button class='comment__item-btn'>Edit</button> <button class='comment__item-btn'>Delete</button> </div> <div class='comment__info'><span class='comment__author'>" . $cite . "</span><span class='comment__date'>" . $date . "</span> <div class='comment__content'> <p>" . $text ."</p> </div> " . $reply ."</div> </div> <!-- end of block .comment__item-body--> "; $out .= "</li>" . $childFinish; $out .= getComments($comments, $page, $comment->id, false, "<ul class='comment__children'>", "</ul>"); } } return $out; } echo getComments($page->blog_comments, $page); ?>1 point
-
My bad...The child page has to be deleted first: $page = $this->wire('pages')->get(1234); $pages = $this->wire('pages'); $repeaterID = $this->wire('fields')->get('eventpricerepeater')->id; // this is the 'repeater_field_name' page $repeaterPage = $pages->get("parent.name=repeaters, name=for-field-$repeaterID"); foreach ($page->children("include=all") as $child) { $id = $child->id; // first delete the child page $child->delete(); // this is the 'name_of_page_with_repeater' $childRepeaterPage = $repeaterPage->child("name=for-page-$id"); // will also delete the repeate item pages, e.g. the '1234567890' if($childRepeaterPage->id) $pages->delete($childRepeaterPage, true); }1 point
-
Hi @workdreamer. Welcome to ProcessWire and the forums . You are right. Very bad practice to add/remove from the core . To override any core methods you use Hooks (as long as the method you want to override is hookable). There is an example here regarding Templates: And all about Hooks:1 point
-
I have re-read your post and I see where we went wrong. Each field has only one repeater page. Its child pages are the parents of the repeater items. Using true in the delete deletes the repeater parent page and its children. That's what my code would do. However, you want to delete only the children. So... Repeaters Hierarchy admin Repeaters repeater_field_name name_of_page_with_repeater 1234567890// repeater item #1 on "name_of_page_with_repeater" 1346798941// repeater item #2 You want to delete 'name_of_page_with_repeater' AND NOT the page 'repeater_field_name' The below (untested) should work (@see amended code in post below...$child has to be deleted first) $page = $this->wire('pages')->get(1234); $pages = $this->wire('pages'); $repeaterID = $this->wire('fields')->get('eventpricerepeater')->id; // this is the 'repeater_field_name' page $repeaterPage = $pages->get("parent.name=repeaters, name=for-field-$repeaterID"); foreach ($page->children("include=all") as $child) { // this is the 'name_of_page_with_repeater' $childRepeaterPage = $repeaterPage->child("name=for-page-{$child->id}"); // will also delete the repeate item pages, e.g. the '1234567890' if($childRepeaterPage->id) $pages->delete($childRepeaterPage, true); $child->delete(); }1 point
-
strip_tags is the simplest for sure. If you want more control, try the textarea sanitizer: https://github.com/processwire/processwire/blob/35df716082b779de0e53a3fcf7996403c49c9f8a/wire/core/Sanitizer.php#L10221 point
-
Repeaters pages need to be deleted a bit differently // delete repeater page: admin/repeaters/for-field-xxx $repeaterID = $fields->get('name_of_repeater_field')->id; // make sure you get the right repeater page $repeaterPage = $pages->get("parent.name=repeaters, name=for-field-$repeaterID"); if($repeaterPage->id) $pages->delete($repeaterPage, true); Regarding the error, not sure why you are getting it, but you can check like this: if($parent && $parent->id) { }1 point
-
There's no way to test a migration beyond just using it. That's why I feel the downgrade functionality is so important. It enables you to quickly iterate on things missing. Also keep migrations small and focused on a single concern. Personally I don't even worry about backing up my database just for running a single migration. I'm using CronjobDatabaseBackup, which does a backup every day or so and I've not restored once of of them by now. There's not really to much, where you would destroy something not quickly fixable via the admin backend. For more involved changes, where lot's of pages are affected I also like to split things up in multiple migrations, which I can run manually – checking things after each migration. After a few initial migrations written the potential of bugs will also considerably drop for everything "standard". E.g. creating a field with a FieldMigrations is essentially just setting some properties. The hard stuff is already taken care for. If you make errors there it's a matter of deleting the field and rerunning the migration and everythings fine again.1 point
-
Thank you @kongondo, I will try it out in the next time and post it here if it works.1 point
-
1 point
-
Checks if you already have an image in that image field. If count returns something, it means there's an image in the field already. It presupposes you've never added more than one image before. If its empty, you can add an image, if not empty, do something else. This is near-pseudo code so things can be changed around...Edited the code above for clarity1 point
-
This works for me $c = $page->child;// page here is the parent page //$repeaterItems = $page->repeater_test;// repeater with 6 fields (email, file, integer, text, single image, multi-images) x 2 repeater items //$c->repeater_test->import($repeaterItems);// alternative import $c->repeater_test->import($page->repeater_test);// import (into an existing repeater field in the child page) $c->of(false); $c->save('repeater_test');1 point
-
More than a year later..... From the docs $building = $page->buildings->first(); // or whatever item you want to remove $page->buildings->remove($building); $page->save();1 point
-
If earlybookingdeadline is not an array itself, then this should work $k->earlybookingdeadline = $repeateritem->earlybookingdeadline;// earlybookingdeadline NOT an array; it just returns a value1 point
-
CKEditor is meant to be composed with different plugins, so the core is as small as possible, while people can add the things they need without the overhead of things they don't need.1 point
-
There is a recent discussion about calendars and events over here: I also recommend doing a google search like this: event calendar site:processwire.com/talk As for pimping the admin, there are all sorts of techniques to tweak it to your needs. Of course, you will need to deal with Roles/Permission, but you might really want to consider using @adrian's Admin Restrict Branch: https://processwire.com/talk/topic/11499-admin-restrict-branch/1 point
-
Hi, Is it the one you found from Ryan? https://processwire.com/blog/posts/pw-3.0.28/ As you can see, it is quite recent which suggests there in no core support at the moment.1 point
-
Thanks, just noticed you are running PW from a subfolder so most probably AOS is using relative paths and that's why the assets are not loaded. I will post a fix soon.1 point
-
<?php $out .= "<div class='row'>"; $i = 1; foreach($page->children as $p) { $out .= "<div class='col-xs-4'>"; $out .= "<img src='{$p->images->first->url}' class='img-responsive'>"; $out .= $p->title; $out .= "</div>"; if($i++ % 4 == 0) $out .= "</div><div class='row'>"; } $out .= "</div>"; Hi! For that stuff I use the handy modulo operator ... it is a division but you will get the remainder from the division. (See evaluations below) The divisor has to be n+1 of the number of inner sections of the division. (Your cols) Then I also do pre-increment the counter directly in the if statement to save some lines (Post- vs. Pre-imcrement). The counter gets incremented before the modulo operation and the comparison. Just changed it. Either you do pre-increment and put the line at the top ($i must start at 0), or post increment and put the line at the bottom ($i must start at 1). That way this logic fits into 2 lines (init the counter + the sectioning logic) Here some modulo results as a visualization: >>> $i = 0 => 0 >>> $i++ % 4 => 0 >>> $i++ % 4 => 1 >>> $i++ % 4 => 2 >>> $i++ % 4 => 3 >>> $i++ % 4 => 0 >>> $i++ % 4 => 1 >>> $i++ % 4 => 2 >>> $i++ % 4 => 3 >>> Hm. yep. Havent tested the code, but it should work. ..... .. I hope. cheers!1 point
-
Thanks @szabesz. You are right, I want to give partial access to the backend for vendors only. So, my question is how should I set up the backend to allow the vendors to be able to update a calendar? Then, this calendar will be showed in the vendor's frontend page.1 point
-
Hi @AndZyk Here is one: GlobalEmailSettings, such as: sender and reply to. See this recent discussion: I'm not aware of any already published solutions to this and although it seems to be easy to implement and may not necessarily needs to be turned into a module, even a very simple module has the advantage of being ready made, easy to add and update (provided it is the the Module Directory...).1 point
-
After having a closer look to the AutoSmush module, I don't think there is not much need for the module I had in mind: The ImageOptim web service requires an API key generated by your mail address It is similar like reSmush.it currently free, but only in beta and it is not clear how long the beta will last Also I should maybe develop a smaller module first. If anyone wants to give this idea a shot, feel free to do so. If reSmush.it gets shut down for whatever reason, this could be an alternative. @horst: Forgive me this silly question: But does optimizing the source image really make an noticeable difference for creating the variations? Of course it makes sense, but so far I never noticed any downside. But I am not an image expert like you are.1 point
-
Is there a unique class on the body element that you could use to style the element? Eg. "ProcessPageEdit-id-1005" or similar?1 point
-
Maybe one of the parent pages has a template that has access restrictions and children inherit these? I routinely define access for all templates (because I often set restrictions on the Home template and these would otherwise flow down throughout the site). Less head-scratching that way.1 point
-
Found a docker-compose to test it with docker / caddy + hhvm https://github.com/ubergarm/caddy-hhvm Looks good and feels fast.1 point
-
Media Manager version 009 (released 16/12/2016) Happy to announce the latest release of Media Manager. Changelog Filter Profiles: Feature enables configuring of various media filter interfaces (similar to ListerPro). This feature was requested here. Please see otes below Filter Profiles Usage To use the so-called Filter Profiles feature, you will first have to enable it in your settings (see images below). Head over to any media view. You will see a 'config' tab next to the Filters tab. Click on it. It will open a modal Create your profiles (one at a time). These are added to a table in that modal view. Click on the title of a filter profile to configure it's filters. Moves to 'single filter profile edit view' Set a filter as active by selecting it in the dropdown at the top of the modal view (#2) To delete one or more filter profiles, click their trash icon and save (there's a checkbox to confirm action) Close the modal. The Media Manager Library will reset and if you set an active filter in #5, your Media will be filtered according to your settings Currently, any user can create filters. Depending on your feedback, this might change. We might also add other features, e.g. locking down filters so they cannot be deleted. OK, that's it from Media Manager for this year. Hope it's been fun! Thanks.1 point
-
If you link to GitHub, please use the commit-id (instead of branch-names). Otherwise, future editions could make those links pointless. … … Example usage: Blog and Matrix modules. Protip: To get the SHAified url on GitHub, go to any file you want to link to (e.g. https://github.com/kongondo/Blog/blob/master/ProcessBlog.module) and press Y (without anything, just y) on your keyboard.1 point
-
Been there done that. I proudly present a ProcessWire 3 compatible version with the latest HybridAuth (only tested with Facebook). The code can be found on Github https://github.com/jmartsch/processwire-social-login with installation instructions. Please add your suggestions or create pull requests. The module and its dependencies are installed via composer. Have phun!1 point
-
Try ticking the "Make field value accessible from API even if not viewable" checkbox under "Access toggles".1 point
-
I've just submitted a pull request to you Rudy, based on Robin's code, to add the ability to compile all updated sass files. You then include your style sheets as you normally would, pointing to the generated .css file. You can now either use the SassifyAll() function anywhere or head to the admin and click 'compile sass' to compile all your assets at once. This is my first input to a Processwire Module so let me know if I've done anything wrong, or if I've stepped on anybody's toes!1 point
-
Hello, Yes maybe this could help you https://github.com/NinjasCL/pw-rest1 point
-
In case anyone else* (*so that would be the future me then, when I've forgotten o_O) wants to know how to do this, I worked it out, it's probably in the docs but for the life of me I could not find it (sorry doc writers). You have a hanna code called my_hanna_snippet and you want to output it from within a template, not from the Admin i/f. $hanna = $modules->get('TextformatterHannaCode'); echo $hanna->render("[[my_hanna_snippet]]"); Hope this helps someone/me in the future1 point
-
Hello, guys! I've started a new series of screencasts about ProcessWire. They are in german, if there is any interest I could record also the English version. Processwire is such a great CMS, I'm totally in love So I'm trying to convince more people to use it. https://www.youtube.com/channel/UCwkKKtIeOzfIqF8X5gNP0_g1 point