Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/21/2017 in all areas

  1. This week's version of ProcessWire expands upon our markup regions support introduced last week, and also contains various minor fixes and tweaks. In addition, it adds a $urls API variable which is simply a shortcut to $config->urls. But since this is so commonly called upon, the shortcut can be useful in reducing verbosity in some template files. Meaning, if you want the URL to /site/templates/, you can now use the shorter $urls->templates rather than $config->urls->templates, if you'd like. This also adds consistency with our recently introduced urls() function that's part of the optional Functions API. https://processwire.com/blog/posts/processwire-3.0.50-core-updates/
    6 points
  2. Technically my rest helper is just some functions that I used when creating simple Rest backend with ProcessWire. So is nothing too fancy, just what I needed. See the voxgram repo that used the Rest Helper . The magic with PW is that you can integrate it with more sophisticated tools like Symphony components using composer if you want to. May be I should write a simple tutorial using Rest and PW?
    6 points
  3. Today I want to tell you about my most recent Project: Cooking-Couple.de Maybe you've already seen it. I've got it listed in the ProcessWire Sites section for quite some time now. Also it has been mentioned by ProcessWire Weekly as the Site of the week: ProcessWire Sites Section: https://processwire.com/about/sites/list/cooking-couple/ ProcessWire Weekly: https://weekly.pw/issue/137/ What is this website all about? Why did I make it? I'm using ProcessWire at my day-to-day job and this project is my private playground for learning. Besides of that of course it's actually really what it claims to be. We seriously love cooking and I hope we'll find the time to get enough content together so that all the powerful search capabilities make sense after all. Technical depth @teppo has already provided a great technical overview to the project. In this thread I want to give you the opportunity for digging even deeper. Want to know how I've implemented a specific feature on the site? No problem, I'll try my best giving you detailed answers about it so that you can build something similar. What happened since the review on ProcessWire Weekly got published? I updated Vue from 1.x to 2.x The faceted search has become even more intelligent and easy to use. (Especially on mobile devices) I've added suggestions on the detail page that respect content types and tags to show actually really relevant content instead of just showing some random pages. The website is no longer using the built in template cache. I've switched completely to ProCache. (Since template cache was already carefully implemented the whole switch was a breeze and the site is now blazingly fast) All the assets are now being served by a CDN (thanks again to ProCache) Several minor CSS improvements Now that I've made these updates I think the website is actually a very good showcase for the power of ProcessWire. Just have a look at the source code of some of the pages and you can see what is actually being cached. (<body ... class='ProCache'>) This alone is a huge proof of the scalability of this system. Almost every single page is being cached with static files thanks URL segments caching. Yes I'm really excited about ProcessWire and it's optimization opportunities. Roadmap Most of the features I've initially planned for this project are already implemented. Anyways there are some more ideas I find quite interesting: Adding some more filters (time, difficulties) Negating specific search filters (show recipes without specific ingredients) Rating recipes iOS and Android apps that are reading the data from ProcessWire I'm not exactly sure which of these I'll implement or if other ideas will come to my mind that I like even more. Maybe you also got some input for me? When it comes to the apps I'm actually pretty excited about that idea. I've even started building a simple API: https://www.cooking-couple.de/api/v1/recipes/ (Yes that's cached with ProCache as well ) Anyways I might wait until we get the Front-end JS $pages API mentioned at: http://processwire.com/blog/posts/roadmap-2017/ Conclusion So I guess you get the idea. I'm really excited about ProcessWire and am willing to share the knowledge I've obtained while building this website. I'm looking forward to your questions, feedback and / or input. Have a great time and thanks for being part of the community!
    5 points
  4. Or rather not do that, because it would mean uselessly loading pages. $count = $pages->count("template=$template_has_title, has_parent!=2, title!=''");
    3 points
  5. Hello guys! i'm here to solve the mystery of seavuel.com ! I'm the owner. I am planning to release a commercial site-profile for a hotel-website on codecanyon.net What do you think about the idea/project? I mostly think of it as a long-term project with regular updates and a low-price.
    3 points
  6. Try: $template_has_title = $fields->get('title')->getFieldgroups()->implode('|', 'name'); $page_has_title = $pages->find("template=$template_has_title, has_parent!=2"); If you just want the count of the pages rather than the pages themselves you can do: $count = $pages->count("template=$template_has_title, has_parent!=2");
    2 points
  7. For testing purposes I am running a simple website providing vat exchange rates related to german tax law via api in different formats. http://umsatzsteuer-umrechnungskurse.org I have a template api.php where the api get vars are sanitized. A custom module process the input and provide the requested data by sending headers. One output function of my module as an example: /** * @param int/string year * @param int/string to year (optional) * @param bool return the € value referenced to the listed currency * @return bool/ json document * */ public function outputJSON($from_year, $to_year = null, $invert = false) { if (false === $json = $this->getStringJSON($from_year, $to_year, $invert)) return false; header('Content-Type: application/json; charset=utf-8'); print $json; } my template api.php $config->prependTemplateFile and $config->appendTemplateFile disabled via module settings. <?php // a data request if ($input->get->k) { // get the module $gvr = $modules->get('GermanVatExchangeRate'); // sanitize input $key = $sanitizer->name($input->get->k); $checkKey = $gvr->keyCheck($key, $max); // ... try { $result = $gvr->convert($curr, $value, $month, $year, $inv); // log api access $gvr->log($key); } catch (WireException $e) { $result = "ERROR: ".$e->getMessage(); } die($result); } // ... // something went wrong die('ERROR: Not specified'); } // not a data request render api page else { include_once('_init.php'); $content = $page->body; include_once('_main.php'); }
    2 points
  8. May be you can use two approaches. One is creating an API inside PW using special templates and responses. maybe using my Rest Helper https://github.com/NinjasCL/pw-rest heres an example https://github.com/NinjasCL/voxgram The other one is creating an API outside PW using an specialized rest framework and calling PW using composer. http://flightphp.com http://phpsx.org http://phpflow.com/php/restful-api-frameworks-for-php/
    2 points
  9. Custom Inputfield Dependencies A module for ProcessWire CMS/CMF. Extends inputfield dependencies so that inputfield visibility or required status may be determined at runtime by selector or custom PHP code. Overview Custom Inputfield Dependencies adds several new settings options to the "Input" tab of "Edit Field". These are described below. Note that the visibility or required status of fields determined by the module is calculated once at the time Page Edit loads. If your dependency settings refer to fields in the page being edited then changes will not be recalculated until the page is saved and Page Edit reloaded. Usage Install the Custom Inputfield Dependencies module. Optional: for nice code highlighting of custom PHP install InputfieldAceExtended v1.2.0 or newer (currently available on the 'dev' branch of the GitHub repo). The custom inputfield dependencies are set on the "Input" tab of "Edit Field". Visibility Show only if page is matched by custom find Use InputfieldSelector to create a $pages->find() query. If the edited page is matched by the selector then the field is shown. Show only if page is matched by selector As above, but the selector string may be entered manually. Show only if custom PHP returns true Enter custom PHP/API code – if the statement returns boolean true then the field is shown. $page and $pages are available as local variables – other API variables may be accessed with $this, e.g. $this->config In most cases $page refers to the page being edited, but note that if the field is inside a repeater then $page will be the repeater page. As there could conceivably be cases where you want to use the repeater page in your custom PHP the module does not forcibly set $page to be the edited page. Instead, a helper function getEditedPage($page) is available if you want to get the edited page regardless of if the field in inside a repeater or not. $edited_page = $this->getEditedPage($page); Required The settings inputfields are the same as for Visibility above, but are used to determine if the field has 'required' status on the page being edited. https://github.com/Toutouwai/CustomInputfieldDependencies http://modules.processwire.com/modules/custom-inputfield-dependencies/
    1 point
  10. 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/
    1 point
  11. The Fotomediale is a annual festival of photography for children's and youth photography in Freiburg, Germany. This small website provides information about the festival and its workshops. Because of the topic, this site is very picture heavy. Almost every page contains it own set of images displayed in the background. The images cycle through automatically, but you can also use the buttons on the edges (or if you want arrow keys on your keyboard ). If you want to see the images, you can collapse both the navigation and content area. The transitions between pages were made with Ajax and pushState, but you can also access them directly via their URL. To handle the large image backgrounds, all of the images are lazy loaded using lazysizes. The registration form was created using the API. www.fotomediale.de Modules used: ProCache Markup Sitemap XML Email Obfuscation (EMO) Tracy Debugger Regards, Andreas
    1 point
  12. There's no automatic translation anywhere. You'll still translate those texts in the backend, just not as part of a page in the pagetree, but as standalone translations.
    1 point
  13. There's not really a way to reliably detect an overall first visit to your website. You could however use the session and store some key or really anything by which you can differenciate between first visit (redirect) and later visits (no redirect) while the session remains active. Or you could use a cookie, which could even outlive the session of an user.
    1 point
  14. This works for me: $languages = wire('languages'); foreach($languages as $language) { $selected = ''; // if this page isn't viewable (active) for the language, skip it if(!$page->viewable($language)) continue; // determine the "local" URL for this language $url = $page->localUrl($language); // if language is current user's language, make it selected if($user->language->id == $language->id) { $url = "#"; $selected = " class='current'"; } // output the option tag echo "<li$selected><a href='$url'><span>$language->title</span></a></li>"; }
    1 point
  15. @AndZyk The websites I've seen from you all were surprising to me. (In a good sense) Keep up the good work!
    1 point
  16. +1 tutorial for simple api and using PW with composer. @kixe think I've bee working on a similar structure with a special api.php template that disables preappend and append files.
    1 point
  17. Congrats for the Great Work. I wonder how you will distribute the site. Please write an article about your experience so we can learn how to do the same :). How you will manage updates? (specially database related ones) cheers.
    1 point
  18. A classic case of RTFM %#~* Thanks @Mike Rockett, this is brilliant.
    1 point
  19. A way you could do this without any code: 1. Create one image field for the first image and one image field for the second/subsequent image(s). 2. Set "Min width for uploaded images" to 200 for the first image field. Incidentally, your original post says that the first image should be under 200 pixels wide, but that doesn't make sense so I assume you mean over 200 pixels wide. 3. Make both image fields "required".
    1 point
  20. For sure. This time the theme development was mixed with "stolen 5 minutes spare time" and the excitement of being able to achieve it but I will be concentrating more on the technical part next time especially after I have done the "long version" and will be having some support that would need more guidance at the beginning. P.S. Mauriziobonami workflow is really cool so I would give it a try and see some additional ideas and eventually improve the my coding.
    1 point
  21. @Robin S It wasn't my intend to talk that much about separation of concerns at all, but about the fact, that people new to ProcessWire need a system which is first and foremost clear to grasp. This new region syntax is in my opinion the opposite. It might work for the tutorial type of situations, but I'm not sure it'll hold true for much beyond that. My biggest issue with it is that it's keeping it's state without any clear indication of what's happening. Someone who didn't read the docs on this feature or maybe just skimmed it lazily won't be able to tell why things happen as they happen. And that's probably the average guy or gal out there trying out ProcessWire for the first time; clueless of any of the magic id matching happening in the markup. The older function-based implementation of the regions api is way more explicit in telling even the clueless reader of the code that stuff is being placed in some kind of regions, which are later printed in the wrapping markup. My addition of "separation of concerns" as part of an educational piece on templating was just for it's own sake: education. I see lot's of code examples around the forums, which are just a mess of business logic mixed with view logic mixed with html markup. Such code is a nightmare if the client comes around and asks you to change some things here and there. Even better if things should later be used in multiple different places. It would be a shame to leave those issues out when discussing the differences between templating strategies in processwire.
    1 point
  22. @owzim - This is what destination selectors are for. In your case: source: project?id={id} dest: [[parent=/projects/, oldID={id}]] Anything inside double-square-brackets is a selector, and returns the full httpUrl of the page. You can also append a query string to the destination for the purposes of analytics, if you wish. (The syntax is changing in v2 to @[selector].)
    1 point
  23. Got it working! Thanks for the help <?php foreach($pages->get("/deals/")->children as $post){ foreach($post->children as $child) {?> <?php echo $child->title;?> <?php } }?>
    1 point
  24. Hi @holmescreek I see you are working with mp3 files. One of my first (learning)-projects with PW was a local Music-DB with importfunctions of ID3-tags into page fields. If this is of interest for you, here you can find some examples and libs: (function to retrieve infos from a mp3 file) https://github.com/horst-n/LocalAudioFiles/blob/master/LocalAudioFilesImportShellScript.php#L108 (the libs that are used in the importer class) https://github.com/horst-n/LocalAudioFiles/tree/master/site-default/modules/LocalAudioFiles (the old project page here in forum) https://processwire.com/talk/topic/3604-release-localaudiofiles-mp3-db/ (a online demo, where you can log in as "myusername" with the buttons top-right, and inspect the Admin, - how pages and sections are sorted with the auto-importer) http://pwlaf.biriba.de/dbinfo/
    1 point
  25. you might not need jquery
    1 point
  26. Hey, a lot of times I create a role called "editor" and give all of the page-* permissions to it. No problems so far. But I normally forget to go to "home" template afterwards to set the permissions for the template, too. So my idea is to show a list of templates (maybe only the once you have selected as "Manage access individually") in a list like the following in the role edit screen: I think this would be a huge performance improvement and could save a lot of confusion and clicks.
    1 point
×
×
  • Create New...