Leaderboard
Popular Content
Showing content with the highest reputation on 02/05/2017 in all areas
-
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.5 points
-
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.5 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.3 points
-
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 ?3 points
-
ProcessWire Prism JS Syntax Highlighter A module to parse given HTML and syntax-highlight code elements using Prism JS Features Support for 120 languages Very lightweight, core weights 2KB minified gzipped. Customizable. Specify your own CSS, or use one of 8 default themes Hookable. Use hooks to specify your own custom CSS, and JS Plugin support. You can use all available plugins that come with Prism JS. Installation Add module to /site/modules/ and then install. Or go to Modules > Install > Add New and use any of the options provided to to install. Create a text/textarea field or use an existing one then pick Prism Code Highlighter from Details > Text Formatters. Protip: This module parses HTML markup, so it should come after HTML parsers such as Markdown textformatters. Add code elements within the field content with language-xxxx classes. Or pick a default language from configuration page if you are unable to specify the classes. Go to configuration page and select any plugins you want. To use some plugins, extra classes are required. See plugin documentation. Install these recommended modules for the best experience: Parsedown Extra module to render Markdown Extra into HTML. You can also set custom attributes for each element unlike vanilla Markdown. Customization Go to module configuration to specify: Auto inclusion of highlighters for parsed languages Default language for inline code elements or ones without language-xxxx classes. Ability to use minified/non-minified component and parser files Plugin options Theme options Custom JS and CSS for configuration / theming Ability to use hooks to specify custom CSS and JS Hooks Hook into TextformatterPrism::getCustomCss and TextformatterPrism::getCustomJs in your ready.php file and return an (array of) URLs as follows: // specify custom CSS wire()->addHookAfter('TextformatterPrism::getCustomCss', function (HookEvent $event) { $event->return = 'path/to/custom.css'; }); // Specify custom JS wire()->addHookAfter('TextformatterPrism::getCustomJs', function (HookEvent $event) { $event->return = ['path/to/custom.js', 'another/custom.js']; }); Screenshots Links https://github.com/abdusco/pw-prism-code-highlighter http://prismjs.com/ http://modules.processwire.com/modules/textformatter-prism/2 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.2 points
-
I might be easier to change the parent of the RepeaterMatrix rather than trying to move each item and their contents. This is what I did with the PageTable to Repeater converter: https://github.com/adrianbj/ProcessAdminActions/blob/bcb8479e90224f958f0747476657c459cd230307/actions/PageTableToRepeaterMatrix.action.php#L294 Not saying it is the only/best solution, but it seemed to remove the hassles of handling different fieldtypes in my situation at least.2 points
-
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.2 points
-
I have no idea why you have such a setup but anyway, here goes. As per the instructions, your Hook needs to return a PageArray. This is untested: $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->name == 'result_judge_challenge') { $page = $event->arguments('page'); $event->return = $page->parent->parent_multi_page_field;// this should return a PageArray } }); You might want to add checks to see if the parent page actually has items in its page field.2 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.1 point
-
ProcessPageListerUrls Create links to specific ListerPages with predefined selector, column and sort settings. See GitHub for more information. Download ProcessPageListerUrls on GitHub1 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
-
@clsource thanks a lot for the very detailed answer, about my fifth point I have found the following libraries: https://github.com/guzzle/guzzle http://phphttpclient.com/1 point
-
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?1 point
-
thank you for the quick response! i got that now hmmm... so you define your query on the client side? how can you make sure that people do not modify your queries in a way that you do not want? i read of your server-side restrictions regarding templates, but wouldn't it still be possible to modify the queries to some extend (like changing number of records to show, fields and so on). i'm thinking of someone maybe stealing content or creating his own json exports of my site's content...1 point
-
hi @Nurguly Ashyrov this looks very interesting! could you please provide a simple example how one would use graphql and/or your module with simple ajax requests? i guess this could be great to return data for https://datatables.net/ ?1 point
-
Brilliant! I should pay you at least a couple of beers... I'll mark this thread as solved, thank you Robin for you inputs! regards1 point
-
Hello, In this tutorial I show how to use the wirePopulateStringTags function in order to improve translatable strings. https://medium.com/@clsource/better-translatable-strings-in-processwire-621e9e6b18ee#.tv2u23j4i Basically it will improve how the strings are shown in the translation administration. echo wirePopulateStringTags( __('There are {count} {items} in the {place}'), ['items' => 'apples', 'count' => 32, 'place' => 'basket'] ); Will render There are 32 apples in the basket And the Translator will see There are {count} {items} in the {place}1 point
-
Hi, I'm still subscribed to Carl Alexander's blog, which I do not read too often, but his bard new article might be interesting for web developers, especially for those working on a Mac. As he writes: "This article goes through the entire process of setting up my new MacBook Pro. It's pretty exhaustive because I talk about why I chose some of the tools that I'm using. I also go over some of the tools that I tried out and didn't end up using." https://carlalexander.ca/2016-macbook-pro-setup/1 point
-
I also like: https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions https://getgrav.org/blog/macos-sierra-apache-mysql-vhost-apc https://getgrav.org/blog/macos-sierra-apache-ssl1 point
-
You cannot access php files inside the site folder. You'd need to use the url of your settings template page.1 point
-
Here's my idea on how a repeater field could be limited. Instead of a hard lmit there could be a "separator", eg. consider a scenario of limit 3: Item above limit Item above limit Item above limit ------ separator ----- Item below limit Item below limit Item below limit ... As you can see there is no real limit but only a visual separator. Moving item 6 to the top would push all other items one place down, but still only the first 3 would be above the limit. The advantage would be that you shouldn't need to delete an item and can reuse them later. Anyway, I'm fine with the current solution, just wanted to share1 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
-
not sure if this could be handled by the module, and haven't researched yet about this... but i wonder about the possibility of hide and unpublish buttons on a page table, because it is something that would save my users a lot of time; example would be we have homepage sections which are handled by a page table. there can be many sections to the page table, but sometimes a user might want to hide one and unhide another one; in the current functionality of PT afaik you need to open the item, go to the settings page and check the buttons... TIA for reading!1 point
-
I think it's safe to delete if you don't use it. I don't know how could I make it optional without making it uncomfortable for others who are using it. What I could do (and it's on my todo) to reduce the number of files in the CKE plugins directory.1 point
-
Hello, my problem was that I get blank page after manual upgrade from 2.8.0/2.8.35 to 3.x. on localhost (Windows). Also there is no errors inside log files (php, apache... site/logs). Problem solved after addition in top of config file (site/config.php): namespace ProcessWire; One of the first thing what I done (after upgrade and blank page) was that I added this in site/config.php : // no need to add this!!! // disable module compilation $config->moduleCompile = false; // disable template file compilation $config->templateCompile = false; but did not pay attention on config file, and "configure" itself . Regards. p.s. maybe this should be noted in this page1 point
-
@Soma - just wanted to let you know that I have made more changes to @owzim's script. The new version adds this functionality adds dynamically added hooks like Page::viewable which were not previously detected cleans up code within a function when it's on the same line as the function definition, eg. https://github.com/processwire/processwire/blob/35df716082b779de0e53a3fcf7996403c49c9f8a/wire/core/NullPage.php#L112 removes any comments from the returned info - previously if a comment was on the same line as the function definition it would be returned also. You can see my changes here: https://github.com/adrianbj/TracyDebugger/blob/master/panels/CaptainHook/CaptainHookSearch.php Let me know if you have any questions.1 point
-
1 point
-
Jeffrey Way's free videos look great too! Thanks I will check them out as well. I'm in the middle of installing my clean system setup, so this is just the right timing for me to learn new tricks and read about these tools.1 point
-
That's right. That's the way it will work when module is done. Currently there is a support for template permissions. Support for Field permissions are on the way, I am working on it but it will take some time. For now you can limit the fields via module settings, I pushed support for legal fields two hours ago. Thumbs up from @horst ! Yeeeey I am a big fan of your modules!1 point
-
Ooh, that's right. Now I get what you mean. Thank you for clarifying that for me. That's true, with this module it gets available to the public without echoing it explicitly. So you will have to setup extra permissions to make it closed to the guest user. This was the initial intention of this module really. The goal is to build a tool that will allow you to quickly bootstrap an AJAX api of your ProcessWire content to build SPA out of it. For cases like you guys describe, this module might have some drawbacks. But you could always cook your own GraphQL api and make it behave however you want. It's fairly easy after you learn a bit about it. Here is the library I use for this module.1 point
-
Ah sorry, I know - I expressed myself not accurately - I also think legalTemplates and Fields are basically not necessary - but i think it is just a very convenient way to reduce the available data The confusion might be about this: Normally in processwire templates you have to "make the fields public" by manually echoing data in a template (echo $page->title) - so actually for a guest user everything is hidden by default - though by permission actually authorized. With this module - everything gets "unveiled" (to use another term here) automatically. This is what I meant by "public" and "private". ... am I right?1 point
-
I just updated the Captain Hook cheatseheet to latest version 3.x now there's a master and dev version. Thanks to @owzim for providing a cli script to parse the repos automaticly and generate a array to use. It helps a lot to update. https://somatonic.github.io/Captain-Hook/index.html1 point
-
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/Serializer1 point
-
Basicly you have one folder for templates by default. This is configured to be in "site root" + templates/ You are able to overrule this setting from the site/config.php as follow $config->urls->templates = $config->urls->site . 'mytemplates/'; $config->paths->templates = $config->paths->site . 'mytemplates/'; A trick i use a lot when developing in a live site is to duplicate the template folder and rename the copy to templates-dev. Then make sure i have an other domain (or subdomain) pointing to the hosting, for example dev.domain.ext and for the live site on www.domain.ext With the following code i can access the development templates while normal visitors keep getting the default templates. /** * Development: Alias for template-dev access * */ if($_SERVER['HTTP_HOST'] == 'dev.domain.ext') { $config->urls->templates = $config->urls->site . 'templates-dev/'; $config->paths->templates = $config->paths->site . 'templates-dev/'; $config->debug = true; } You can make up all kind of 'rules' to go by when overruling the templates folder with php from the config.php file. For example serving the same site with different layout and code for mobile on m.domain.ext /** * Mobile: Alias for template-mobile access * */ if($_SERVER['HTTP_HOST'] == 'm.domain.ext') { $config->urls->templates = $config->urls->site . 'templates-mobile/'; $config->paths->templates = $config->paths->site . 'templates-mobile/'; }1 point