Leaderboard
Popular Content
Showing content with the highest reputation on 02/06/2017 in all areas
-
@microcipcip At the time of writing this tutorial and coding a real world application that uses this approach, I wasn't aware of the fact that PW brings it's own http client Class WireHttp. So today I wouldn't bother using an external library like guzzle or phphttpclient. I would go with WireHttp. It has all the methods you need. @clsource thanks for answering microcipcip's questions so thoroughly.6 points
-
@LimeWub - you might also find this useful: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users It's lets you place your users under a different parent or with a different template.4 points
-
I know this is old, but just a follow up to mention that Tracy Debugger has a few options for achieving similar functionality. Files Editor panel lets you test changes without affecting what other users see. When ready you can push the changes live. Template Path panel lets you choose from a variety of templates with -dev, -test etc suffixes. The User Bar has a "Page Versions" component that lets authorized users choose from alternate templates (this is basically a non-superuser version of the Template Path panel. User Dev Template Options - this lets you set users with certain roles to automatically see the page with a different version of the template file. Anyway, thought some of these might be useful to others who come across this topic.4 points
-
@Nurguly Ashyrov Hello Nurguly, I was following this thread from day one and I am deeply impressed by the passion you are putting into your 'baby'. Especially your in-depth explanations helped me understand your concept and getting first results on my own. Very often talented programmers do not have the same skill in teaching others . But you definitely have. Right now I am experimenting with your module to figure out if this could be a method to be used in a PWA (progressive web application). Using the GraphQL channel I would reload just my 'new' data via the service worker . Therefore it wouldn't matter that this data is exposed to the public - it should go there anyhow.4 points
-
Hey guys, Here is our latest creation, a website for a landscape architecture studio in Freiburg, south of Germany. http://freisign.eu/ As you can see this is a very simple site. The most complex pages are the project pages since here we wanted to give the editors flexibility to construct the content at their will. Because we had a decent amount of different content blocks the obvious choice was to use the "Repeater Matrix" ProField. We also used the oldie "Page List Image Label" by Soma, which works pretty well for organising the admin of this kind of sites. For the slideshows we used the excellent Slick Carousel jQuery plugin. It still amazes me how flexible and easy to use it is The site is responsive, of course. As always, opinions and suggestions are welcome!3 points
-
As for organising your forms in the page tree, you could also save all form pages under one parent. When you save a form page via API, you can set the user who has created the form (which is the logged in $user). Some dummy code to achieve this $form = new Page; $form->template = 'form'; $form->parent = $pages->get('template=formparent'); /* set user who created this form */ $form->set("createdUser", $user); Then in the user's dashboard you get all the forms for that user with something like $forms = $pages->find("template=form, created_users_id={$user->id}"); I'm using this approach in some projects with frontend user dashboards and it works really well. Users can only see the content they created. All user content (here forms) lives under one parent page which makes it easy to create and query. Important note: in the backend you need to edit the form template and enable "Allow the 'created user' to be changed on pages?" under the "Advanced" tab. For the admin dashboard where forms for all users should be listed, you might want to spend a few bucks on Lister Pro. This saves you from developing a custom admin page. Lister Pro is very powerful and you can create a Lister that shows all pages with template form. You can list all forms sorted by created date, filter for forms of specific users etc. Also inline editing for the status field is possible. So admins can change the status very quickly. For the multi-step form: I also think that using Angular here would be overkill. I have a multi-step form that I render with PHP and use some very simple JS to step through the form. The form is divided into fieldgroups that reflect the steps. In the JS you can use AJAX to save the steps of the form that have been completed. Since you want to store the form data as JSON, you might want to look into a JS form framework that renders forms from JSON, something like Alpaca Forms. This would save you from creating the form rendering logic on the PHP side. They also support multi step form wizards. And, finally, what @adrian suggested above for creating users under different parents makes a lot of sense. I use this approach quite often.3 points
-
Thanks for your work => it looks very good! Will this work together with ProcessWireUpgrade? This will make updates through more easily I presume.3 points
-
yes, it is: https://www.google.com/search?q=change google map colours should be very easy using their readymade styles: https://snazzymaps.com/3 points
-
@kongondo You are right. I'm a complete PHP novice, trying to wing my way through, copying code without understanding. Obviously that's no way to do things. It's time to teach myself the basics of PHP, and I'm determined to do that. Thanks for pointing out the resources. And thanks for all your help and patience.3 points
-
NOTE: This thread originally started in the Pub section of the forum. Since we moved it into the Plugin/Modules section I edited this post to meet the guidelines but also left the original content so that the replies can make sense. ProcessGraphQL ProcessGraphQL seamlessly integrates to your ProcessWire web app and allows you to serve the GraphQL api of your existing content. You don't need to apply changes to your content or it's structure. Just choose what you want to serve via GraphQL and your API is ready. Warning: The module supports PHP version >= 5.5 and ProcessWire version >= 3. Links: Zip Download Github Repo ScreenCast PW modules Page Please refer to the Readme to learn more about how to use the module. Original post starts here... Hi Everyone! I became very interested in this GraphQL thing lately and decided to learn a bit about it. And what is the better way of learning a new thing than making a ProcessWire module out of it! For those who are wondering what GraphQL is, in short, it is an alternative to REST. I couldn't find the thread but I remember that Ryan was not very happy with the REST and did not see much value in it. He offered his own AJAX API instead, but it doesn't seem to be supported much by him, and was never published to official modules directory. While ProcessWire's API is already amazing and allows you to quickly serve your content in any format with less than ten lines of code, I think it might be convenient to install a module and have JSON access to all of your content instantly. Especially this could be useful for developers that use ProcessWire as a framework instead of CMS. GraphQL is much more flexible than REST. In fact you can build queries in GraphQL with the same patterns you do with ProcessWire API. Ok, Ok. Enough talk. Here is what the module does after just installing it into skyscrapers profile. It supports filtering via ProcessWire selectors and complex fields like FieldtypeImage or FieldtypePage. See more demo here The module is ready to be used, but there are lots of things could be added to it. Like supporting any type of fields via third party modules, authentication, permissions on field level, optimization and so on. I would love to continue to develop it further if I would only know that there is an interest in it. It would be great to hear some feedback from you. I did not open a thread in modules section of the forum because I wanted to be sure there is interest in it first. You can install and learn about it more from it's repository. It should work with PHP >=5.5 and ProcessWire 3.x.x. The support for 2.x.x version is not planned yet. Please open an issue if you find bugs or you want some features added in issue tracker. Or you can share your experience with the module here in this thread.2 points
-
Selectors are your friend. $my_special_pages = $pages->find("parent=/, name=foo|bar|baz"); // or match by template, or anything else $my_other_pages = $pages->find("parent=/, id!=$my_special_pages"); // now build your menus from these PageArrays2 points
-
Or @kongondo's menu builder: http://modules.processwire.com/modules/process-menu-builder/2 points
-
You have many options. One is to have the pages that you don't want on the main menu as "hidden", and build the second menu by hand. Another is to make a simple menu builder, for example on the home template, with two different page fields. There are more options, but I think those two are already pretty good.2 points
-
Hi @Doc I've never done it with ProcessWire, but here are some topics: Huh, that's all for now2 points
-
2 points
-
+1 Experienced developers should not have problem learning the basics of Composer, however, using the ProcessWireUpgrade module is easier and even site owners can use it out of the box, so generally I prefer relying on it instead of Composer. This is a module that should support ProcessWireUpgrade as well, I think.2 points
-
2 points
-
thanks for all your suggestions. I also found out this: https://medium.com/@clsource/the-wire-render-pattern-806bf6d6097a#.82as32ldy which seems quite interesting. Now I will check and find out which solution suits my needs best...2 points
-
Users are pages in PW, if you look at the database there is no users table. This is how you create an user // Create the user $u = new User(); $u->name = $sanitizer->pageName($username); $u->email = $sanitizer->email($email); $u->pass = $pass; $u->addRole("member"); $u->save(); this will create a new page under /admin/access/users/ and that is your user. What i suggested above is just what i find easier to work with as i don't want to mix default pages with the rest.2 points
-
Just stumbled across this very old topic while looking for something else and thought I should mention the Admin Restrict Branch module in case others come across this.2 points
-
I have already started to build upon the new site profile: http://szabesz.hu/ I replaced uikit.min.css and uikit.min.js with their currently up-to-date counterparts (3.0.0 beta 9, February 3, 2017) so it looks OK in IE and Edge too.2 points
-
I already answered how to do this . If you don't want pagination, then, in your case, grab only 1 item. // GET 1 post, SORTED BY created {you could also sort by '-blog_date'} $singlePost = $pages->get('template=blog-post, sort=-created, blog_categories=News'); $out = $blog->renderPosts($singlePost); echo $out; I am not being rude but this is the point at which I encourage you to get that 'PHP for beginners' book (e.g., this one) as well as revisit the PW docs. Let's walk through your code: Line 1#: You grab some posts using find(). That returns a PageArray. You then assign it to the variable $posts. Line #3: You are overwriting the variable $post (which contains the PageArray from Line #1), assigning it an empty string, i.e. ''. Line #4: You are appending to the empty string $post an Object which contains the current page's image. Line # 6: You then append to $post other stuff..... That's why it doesn't work as expected . I am surprised it didn't throw an error. Maybe you have debug turned off?2 points
-
That will all depend on how you configure your api. If you wish this module can expose all pages in your website, including the system ones. Or you can restrict to some very limited data. There are more functionality to come, but at this stage the module supports: Template restrictions. You can choose which templates are enabled, but in addition it will conform to ProcessWire permissions. So you could limit access to certain templates only to certain user roles. You can enable access to only logged in users for example. Field restrictions. Also supports ProcessWire permissions. Including template context permissions. Meaning, you can allow title to be viewable for one template and restrict for another. Max limit support. Like the one you use in selectors. So users won't be able to get list of data for more than say 50 pages at a time. and also many other security options are on the roadmap: Built in field restrictions. At it's current stage api gives access to page fields like children, parents, createdUser..., or there are path, size, basename for files and images fields. Those will be disabled and available as extras. Query complexity limit. Currently you can build queries as deep as you want, to request ridiculous amounts of data. This will also be limited for only couple levels of complexity and you will be able to increase or decrease it.2 points
-
I am not sure I understand this one. Not sure if you want 1 post from 1 category or several posts from 1 category. Irrespective, pagination only kicks in when you grab a limited number of items and the results returned are a PageArray. If what you mean is: 1. Render only 1 post from a given category: Here the trick is to return a Page rather than a PageArray. So, we use a get(). findOne() (if you are using PW 3.X) should also work. $content = ''; // render a single blog post on Blog Home Page //$singlePost = $pages->get(11335);// grab by ID $singlePost = $pages->get('template=blog-post, sort=random, blog_categories=News Article, limit=1');// grab a random post $content .= $blog->renderPosts($singlePost); 2. Render several posts from only 1 category. In this case, this will return an array. So, to avoid pagination, we need to grab ALL the available post, i.e. no limit (careful with this one if you have lots of posts!). $content = ''; // render ALL blog posts from a single category on Blog Home Page $oneCategoryPosts = $pages->find('template=blog-post, blog_categories=News Article'); $content .= $blog->renderPosts($oneCategoryPosts); // these will also work; passing in a selector #$selector = "template=blog-post, blog_categories=News Article"; #$content .= $blog->renderPosts($selector); No need to create a different template for blog posts classified as 'News Article'. Instead, we include some extra logic in the template file blog-post.php. See example below. // get the category 'News Article' $newsArticle = $pages->get('template=blog-category, name=news-article'); // special render for blog posts that are classified under 'News Article' if($page->blog_categories->has($newsArticle)) { $options = array('post_categories'=>1, 'post_tags' => 0);// options ONLY for news articles $renderAuthor = '';// don't render blog post author for news articles $renderComments = '';// ditto comments } // normal blog post else { #$options = array();// if you wish, options for all other blog posts go in here $renderAuthor = $blog->postAuthor();// render authors for normal blog posts $renderComments = $blog->renderComments($page->blog_comments);// ditto comments } $content = $blog->renderPosts($page, false, $options) . $renderAuthor . $renderComments . $blog->renderNextPrevPosts($page);2 points
-
@LimeWub Regarding the processing of the form pages. You can save the forms in one or more pages under a page representing the user. For example you create a page named "Users" and whenever an user registers you create a page under users with the user's name. Users --username1 --username2 Then when he submits a form you create a page under the corresponding user. Users --username1 ----form1 ----form2 ----form3 --username2 ----form1 ----form2 Or create just one page and you save just the fields from the current form and on the next forms you update the page with the new fields. Then you can get the forms for a user with $currentUserForm1 = $pages->get("parent=/Users/username1/, name=form1"); $currentUserForm2 = $pages->get("parent=/Users/username1/, name=form2"); create pages through api upload files2 points
-
Hello, I will try to respond these questions Questions 1, 2 and 4 could be resolved by using "Transformers" a "Transformer" is simply a class that convert data from one format to another. In this case a transformer that converts PW pages to rest json. And example. If you got a template named video that stores youtube videos and contains the following fields: url, title. You can create a Transformer named like transformers/youtube.php <?php namespace ProcessWire; class YoutubeTransformer { public $source; public __construct(Page $source) { $this->source = $source; } public function toArray() { return [ "url" => $this->source->url, "title" => $this->source->title ]; } public function toJson() { return json_encode($this->toArray()); } } That way you could create a special class that could render specific outputs depending on what do you need. For example {catID}/articleList/{articleID}/galleryList/{galleryID} You could have a specific transformer for categories, articles and gallery items and share the output for each class and join them in the final response. This could also be combined with field specific templates https://processwire.com/blog/posts/processwire-3.0.7-expands-field-rendering-page-path-history-and-more/ 3.- For answering this it depends on your architecture and your api requirements. The rule of thumb is think how the developers will use the api and what information they will need. 5.- Well depends on what do you need and feel more confortable, those are just helper methods. there are tons of good code that you could use like https://github.com/marcj/php-rest-service http://symfony.com/doc/current/bundles/FOSRestBundle/index.html http://symfony.com/components/Guard http://symfony.com/components/HttpFoundation http://symfony.com/components/Serializer2 points
-
hey @szabesz, thanks for all those links ! I'm going to read all that and will post here the one I choose.1 point
-
I suggest you structure your pages based on how the front-end URLs should be (e.g. mydomain.com/page/subpage/) rather than how you happen to be styling your menus.1 point
-
Yes, that would get tedious with PageListSelectMultiple. But can't you substitute a different inputfield? You say you are using checkboxes in your modal page: checkboxes are an inputfield option for Page Reference fields, so can't you just use checkboxes directly in your Page Reference field?1 point
-
ProcessPageView::pageNotFound send 404 header, I can't send it once again. Problem solved using urlSegments on home page (plan B =).1 point
-
Can't you go back to the official released version? Honestly I don't plan on spending too much time on this module - I don't think it gets much use. I created that new version for you to support url segments, but now it seems that you don't want them? Maybe I don't fully understand your needs. If you could give me a full explanation of all the scenarios you want supported I can take another go at it.1 point
-
I guess I am not sure what the problem with the render approach is then. You say you want a 200 header. Can you add this before render() header("HTTP/1.1 200 OK"); I don't know what the incompatibility with the MarkupSEO module is, but maybe you can workaround it by setting the priority of your hook. See an example in my 404Search module: https://github.com/adrianbj/Process404Search/blob/4d9bd7a773d14bc29524c0798ad500050d969685/Process404Search.module#L581 point
-
i would suggest doing the following: create a new template file for your page that holds the map data with exactly the code from the google example (javascript + html): https://developers.google.com/maps/documentation/javascript/examples/map-simple?hl=de change nothing but your api-key. when you view this page you should see the same map as on the google docs page. replace the fixed values for lat/lng/zoom by those saved in your processwire site. see my example above ($page->map->lat...) view your page, it should show the map at the position that you specified in your backend change your style by adding the styles options (see code below) view your page, you should see the new style if everything works, try to implement your map in your original template file var map; function initMap() { map = new google.maps.Map(document.getElementById('map'), { center: {lat: -34.397, lng: 150.644}, zoom: 8, // add comma here styles: [ { "stylers": [ { "hue": "#c1d72e" } ] } ] }); }1 point
-
Thanks so much for the responses @adrian @fbg13 and @gebeer ! You are all fantastic and so helpful! Looking into the recommended options now1 point
-
So I couldn't figure it out in a reasonable time, so I started fresh from a backup before switching to multi-languages and switched again. This time it works. So I guess something went wrong whilst installing the appropriate modules.1 point
-
1 point
-
1 point
-
1 point
-
@fbg13 Yes! Having the submission under the users on the tree makes quite a bit of sense as I wont have to be storing a UserID! Thanks Just wondering though, shouldn't the users be created the same way admin users are created, just with a different usergroup (instead of as "pages" ?) -to allow for things like password reset etc?1 point
-
1 point
-
No need to wait for a day. Go to your module in the repo, click button to edit it and immediately save; (no need to edit anything actually). Voila, it is updated in the repo! .1 point
-
I forgot to update module info file. Fixed it and pushed v1.0.1, module repository should update in a day I guess. Thanks a lot for the heads up!1 point
-
For some websites this might even be the goal. But I can understand your reasoning. It might be interesting to be able to use the module to create endpoints with a somewhat fixed queries. Once the experimental phase is over and it goes towards production queries could be moved from the frontend to the backend.1 point
-
Hey there @bernhard! I am happy people like it. To make an AJAX request to your GraphQL api, you need to send a query variable that describes what you want. You should've seen how the query looks like in the first post of this thread. To send the query you can use any of your favorite AJAX libraries. Here is how it looks like in jQuery. $.post( '/graphql/', // this is the url where your GraphQL api is exposed. { query: "{ skyscrapers { list { title } } }", // this is your query, this one requests the skyscrapers and title field for each of them. }, function (res) { console.log(res); } // here you do whatever you want with the returned data ); Or if you prefer to communicate with your api in application/json, you can do that too. Here is how it looks like in my favorite AJAX library - superagent. superagent .post('/graphql/') .set('Content-Type', 'application/json') .send({ query: "{ city { list { title } } }" }) .then(function (res) { console.log(res.body); }); PLEASE NOTE: When making requests to your api make sure the url is pointing where it is supposed to. The request will not work if you omit the trailing slash. With default settings the request to /graphql won't be processed by ProcessWire but instead redirected to /graphql/ and the ProcessGraphQL module will not receive the query parameter you sent. Same might happen with leading www. prefix. The request to http://example.com will be redirected to http://www.example.com which will also loose the query parameter in the middle.1 point
-
A small news for this morning, the AmazonS3 feature is implemented on the module (its a pain when you don't know about a SDK). Also please check the name of the final package as it was suggested by @szabesz. Thanks again for the suggestion, its better and easily manageable. Edit: For information, all SDKs are installed via composer. Is it a problem for you ?1 point
-
Sounds like a useful thing to have. In terms of UI I imagine something like the action buttons in Page List, where publish/unpublish/hide/unhide buttons appear when hovering the title link in the table. Will investigate how this could be added. Not sure if it's something that belongs in LimitPageTable, or should be a separate module, or perhaps added to AdminOnSteroids. Will have a think.1 point
-
Just bumping as I did a bit more thinking about this today. Basically I think I am almost there, but as I don't want to reinvent the wheel, I'll just share my ideas in case there is functionality that does more of what I want to achieve out of the box instead. Form is built (by the developers) Users login Not sure exactly how to do but have seen multiple threads about this on this forum so should be ok to do. Potentially useful links from my search: https://bitbucket.org/pwFoo/frontenduser/wiki/Documentation https://processwire.com/api/user-access/permissions/ https://processwire.com/talk/topic/3706-how-to-blockredirect-one-user-role-away-from-admin-pages/ https://processwire.com/talk/topic/107-custom-login/ https://processwire.com/talk/topic/12896-frontend-user-login-and-access-levels/ https://processwire.com/talk/topic/2937-creating-a-front-end-admin/ Users edit multi form Angular 2 has been recommended to do this. Although might be overkill and should be able to do with pure JS/ajax (?) opinions? Form autosaves/saves per page Same as above... opinions? Secure Uploads included on the form, need to be visible only for the user who uploaded and site admin Never done this before either but was thinking of using Wanze's Secure Files module http://modules.processwire.com/modules/fieldtype-secure-file/ I'd need to create a front end upload field too, so could be a bit tricky? ideas? On save, form visible in the user's dashboard and submission's admin Should be straightforward enough. Form data would be saved in json form but I would be able to render that. Submission's admin an extension of the site admin for the admin user to be able to view submissions. An extra 'status' field in the only thing editable in the submission's admin. Maybe possible via Admin Custom Pages Module, although not 100% sure. On final submit, form gets posted to salesforce Data is sent to salesforce api and awaits an ok response if all ok, confirmation emails are sent. Not sure which module to use for that, or maybe just raw php but assuming should be very easy (?) Basically, if there's some easier way to do what I'm thinking or have any better ideas, please let me know (rough chart of my way of thinking included) Feel free to ask me to clarify if I don't make sense ^^1 point
-
Remove the line where you call $prm->repeater_videos->add. getNew() already adds the item, you just need to fill and save it. Edit: the same should be true for $page->repeater_matrix_content->add1 point
-
Hi @MaryMatlow, Same way, really. renderPosts() takes 3 arguments, the third of which is $options. Since you need to pass in the 3rd argument, in blog-post.php, line #56, you also have to specify the second argument like so: $options = array('post_comments'=>0); $content = $blog->renderPosts($page, false, $options) . $blog->postAuthor() . $renderComments . $blog->renderNextPrevPosts($page); The 'false' is the second argument. The post will be rendered in full since what that says is that $small = false.1 point
-
THANK YOU to you and Ryan I now have a much better approach to my problem1 point