Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/15/2017 in all areas

  1. This is a perfect use case for Page Reference field. Create a new field from Setup > Fields > Add New. Give it a name. Set its type as Page Reference. Save. If you want to select a single user, specify so on the Details tab, Switch to Input tab, set input type to Select. (Optionally install InputfieldPageAutocomplete core module to enable input with auto-completion capabilities) From Selectable Pages, set template to user. Optionally, use Custom Find and specify template as user, and a role, or any other field you like. Add the field to a template. Inside your template file, you can get the user using $page->userFieldName
    5 points
  2. Visual Page Selector version 004 (released (15/08/2017) Happy to announce that the latest release of Visual Page Selector is now available for Download/Purchase. Changelog Add and close option: Please note this behaves differently if VPS used in a single page field vs. a multi page field as well as if other options are enabled such as 'Delete Images' and 'Delete Pages' or if in a Lister view in the modal. In a single page field if these 'deletes' are disabled, just clicking a page thumb in thumbs view will add the page and close the modal if this option is enabled. In other cases, the modal will be closed when the Add Page option is selected and the Apply Action button is clicked. Please also note the value of the submit button can change to 'Add' depending on the context. Ajax refreshing of Inputfield! No more page reloads once you apply an action in the modal. If you add or remove a page or delete it or its image, the Inputfield refreshes automatically. It also listens to changes made to pages in the page field if editing (in a modal @see below) a page in modal. Please note that direct Lister view actions such as unpublish, trash, etc are currently not captured in this feature. Only Adding/Removing Lister view pages via VPS Apply Actions are covered. Edit selectable and selected pages: You can configure options to edit selectable options when in the modal or selected pages already in the Inputfield (which will open a modal). Any changes you make to the selected page will be reflected in the Inputfield on save. You will see them when you close the edit modal. Support for both single and multi image fields. Please note that if you Delete and Image in a selectable or selected page, VPS will check for the next available image in the named image field(s) (named in VPS settings). If an image is found, it will be returned. Otherwise, the page will be removed from the page field. This only applies to all cases expect the combination of a List view page edit and Lister modal view where no image is required. Support for both single and multi page fields Bug fixes Apologies for the delay. Hit a couple of snags that needed to be resolved. Please test thoroughly in a non-production server first. I see a couple of JS errors in the console but they seem to be related to ProcessPageLister or JqueryCore.js. Have not been able to confirm what's causing them. The module works fine though. Please note: Docs not yet updated to reflect above changes.
    2 points
  3. Could you do? 1=1|Kalundborg Red 2=1035|Education Teal 3=1036|Living Orange 4=1037|Good Life Blue 5=1038|Careers Cyan Then you access it through $page->option->value
    2 points
  4. @adrian After a short break and becoming a father for 4th time, I had a few minutes to redo the comments form and it seems to work fine now. The only thing I could think of messing around would be to have some browser cache for the logged on user form. Today I echoed $user->name above the contact form and noticed that I had to refresh a few times before the name of the logged on user shows correctly. As far as I did not yet activate the cache, I would expect it not to happen but will see what can be done. So for now the comments form is working as expected and I can close that chapter as well. I am thinking on adding some email verification if allowing non-registered users to post comments, but that is beyond this topic. So again, thank you very much for the help and sharing.
    2 points
  5. I agree. I'd really like to be able to support ProcessWire and @ryan much more. We should have a git-backed documentation site. The Meteor Docs, as an example, are built in Hexo and managed on Github: https://docs.meteor.com We can then make sure it is up to date as a community instead of it resting on Ryan's shoulders.
    2 points
  6. Hi PW fanatics In this post I share two of my addHookMethods for those interested. As you surely already know (if not, time to take a look at it) the Wire::addHookMethod() and the Wire::addHookProperty() API methods can be used to "breath some extra OOP" into your projects. Using addHookMethods and addHookProperty are alternatives to "Using custom page types in ProcessWire". The methods I want to share: basically the idea here is to get the URL pointing to images uploaded in the admin without writing much code in the template files. With methods like these below, it does not matter what Formatted value is set to the images, because some predefined defaults are used in all circumstances. #1 Example template file code: <?php $img_src = $latest_article->siteFeaturedImage(); ?> <img src="<?= $img_src ?>" alt="<?= $page->title ?>"> addHookMethod goes into /site/init.php <?php /* Returns URL of the original Pageimage of Article. * Image field's value can be either null (default missing image), Pageimage or Pageimages. * * @return string */ $wire->addHookMethod('Page::siteFeaturedImage', function($event) { $page = $event->object; if ($page->template != "article") { throw new WireException("Page::siteFeaturedImage() only works on 'Pages of article template', Page ID=$page is not such!"); } $article_featured = $page->getUnformatted('article_featured'); //always a Pageimages array if (count($article_featured)) { $img_url = $article_featured->first()->url; } else { $img_url = urls()->templates . "assets/img/missing-article_image.jpg"; //we show this when image is not available } $event->return = $img_url; }); ?> #2 Example template file code: <?php $img600_src = $page->siteProductImageMaxSize(600, 600, ['rotate' => 180]); ?> <img src="<?= $img600_src ?>" alt="<?= $page->title ?>"> addHookMethod goes into /site/init.php <?php /* Generates image variations for Product images. Returns URL of Pageimage. * Image field's value can be either null (default missing image), Pageimage or Pageimages. * * @param int arguments[0] Max allowed width * @param int arguments[1] Max allowed height * @param array arguments[2] See `Pageimage::size()` method for options * @return string */ $wire->addHookMethod('Page::siteProductImageMaxSize', function($event) { $page = $event->object; if ($page->template != "product") { throw new WireException("Page::siteProductImageMaxSize() only works on 'Pages of product template', Page ID=$page is not such!"); } $width = isset($event->arguments[0]) ? $event->arguments[0] : 48; //default width $height = isset($event->arguments[1]) ? $event->arguments[1] : 48; //default height $options = isset($event->arguments[2]) ? $event->arguments[2] : $options = array(); //default empty options $product_image = $page->getUnformatted('product_image'); //always a Pageimages array if (count($product_image)) { $img_url = $product_image->first()->maxSize($width, $height, $options)->url; } else { $img_url = urls()->templates . "assets/img/product-missing-image.jpg"; //we show this when image is not available } $event->return = $img_url; }); ?> BTW, you can find more examples here: How can I add a new method via a hook? Working with custom utility hooks Adding array_chunk support to WireArray addHookProperty() versus addHookMethod() Have a nice weekend!
    1 point
  7. In a current project I am using a Repeater field to build a kind of pseudo-table, where each Repeater item is a row. Some of the rows are headers, and some have buttons that toggle corresponding checkbox fields in a hidden FormBuilder form. The problem was that when the Repeater items were collapsed I couldn't see which rows were headers and which contained buttons. I tried including the fields in the Repeater labels but it still didn't provide enough visual difference to be quickly recognisable. So I investigated how classes could be added to selected Repeater items in admin depending on the value of fields within the Repeater items. This is what I ended up with... In /site/ready.php // Add classes to selected service row Repeater items $this->addHookAfter('InputfieldFieldset::render', function(HookEvent $event) { /* @var $fieldset InputfieldFieldset */ $fieldset = $event->object; $attr = $fieldset->wrapAttr(); // Fieldsets in a Repeater inputfield have a data-page attribute if(isset($attr['data-page'])) { // Get the Repeater item $p = $this->pages((int) $attr['data-page']); // Check field values and add classes accordingly // If item is a header if($p->row_type && $p->row_type->id == 2) { $fieldset->addClass('header-row'); } // If item has a checkbox button if($p->fb_field) { $fieldset->addClass('has-checkbox'); } } }); In admin-custom.css (via AdminCustomFiles) /* Special repeater rows */ .Inputfield_service_rows .header-row > label { background:#29a5aa !important; } .Inputfield_service_rows .has-checkbox > label .InputfieldRepeaterItemLabel:before { font-family:'FontAwesome'; color:#73cc31; content:"\f058"; display:inline-block; margin-right:6px; } Result
    1 point
  8. I like to showcase my new website acniti on the forum here. History Building and managing a website is a hobby, over the years, making websites got more complicated and more technologies, knowledge and wisdom are required. I started building my first website around 1997. It started out with a static site built with FrontPage, a WYSIWYG HTML editor. A few years later it was time for the first content management system, I looked at Joomla but settled for MediaWiki. I run those websites for 2 years on the MediaWiki platform and then moved on to WordPress. WordPress was good, it did a good job but over time, it became more complicated to make something out of the box, if it's not a blog, it becomes complicated and to have a feature rich website requires a lot of plugins. Little by little it became less fun and more and more hassle juggling the various plugins. In 2014 I became interested in learning PHP programming, I wanted to do this already for many years, but never had enough time to bite the bullet and work my way through the basics. At the end of the courses I though and now what have I learned, how to put this into action? To built modern website with PHP only is difficult, it also requires knowledge of html, MySQL, CSS, java-script etc. I started looking for a framework experimented a little with CakePHP and then came across Processwire via a CMS Critic blog post. Development setup I developed the acniti website on a Linux Ubuntu 16, with PHP 7 and MySQL as the development server. For the IDE I use PhpStorm, before using Storm I have used and tried some other IDE's such as Zend, Eclipse, Netbeans, Aptana but none of them I liked, some were feature poor, Zend and Eclipse were slow and use a lot of memory. PhpStorm not free but definitely worth the investment. I make use of the free tier Git repository of AWS called CodeCommit, I still use GIT Cola to commit the changes, I could also use PhpStorm for this but I never took the time to change my workflow. For project management I am a big fan of Redmine, Redmine is a web-based open-source project management and issue tracking tool. I use this also for my other work so it easily integrates with the website building flow as well. It's easy for maintaining lists of features you want to carry out per version, it supports a wiki which is easy for making notes and keeping a log of the activities. I use it everyday and it runs on Ruby. For images and graphics I switch back to Windows for some Photoshop. Processwire The acniti website runs on the latest stable Processwire version at the time of writing 3.0.62, the website has 4 languages including an Asian language. The Japanese language URL's are implemented with their 3 alphabets kanji, hiragana, katakana i.e. https://www.acniti.com/ja/インレットフィルタ. Some images on the site have text and image language tags help to select the correct language, the Processwire blog post from 30 June was helpful to get this running. The main site has a bootstrap theme, for the mobile version of the site the google AMP specification is implemented. This was really fun to do but challenging at times as the AMP specification is still a little limited. To visit the AMP pages type /amp/ behind any URL like https://www.acniti.com/amp/ for the homepage. The Google webmaster portal is really easy to troubleshoot and check for the correct AMP implementation. Finally structured data according to schema.org is added to the site via the JSON-LD markup. The commercial modules ProCache and Formbuilder are installed. The ProCache module is really amazing and makes the website lightning fast. Besides the commercial modules around eleven open-source modules are used, Database Backups, Tracy Debugger, Wire Mail SMTP, Protected Mode, Batcher, Upgrades, PublishAsHidden, URL (Multi-language), Twitter Feed Markup, Email Obfuscation (EMO), Login History, Selector test. During development the Processwire forum is really helpful and checked often. The forum is good for two reasons, most of the questions, I had during development of the site, are already on the site. Secondly the only 6 questions I posted over the last 2 years, are quickly and accurately answered. The downside I didn't become a very active member on the forum but see that as a compliment. An open issue on the acniti site is the AMP contact form with Formbuilder, the restricted usage of java-script for the AMP specification requires some more in-depth study. Hosting setup For the hosting services the acniti site uses Amazon EC2, I use AWS already many years to manage my cloud office so it was easy to decide to use it for the web hosting as well. The site is running on a micro instance of EC2 and with the ProCache module CloudFront is serving webpages worldwide fast. Updates from the development server are sent to CodeCommit and from there to the production server. From a site management point of view it would be nice to use AWS RDS to manage the MySQL databases, but from a cost perspective I decide not to do that for now. Via a cron I have set up automatic MySQL backups and these are via another cron job uploaded to AWS S3. To make sure the server is safe, a cron job runs daily snapshots of the server, this is getting initiated via AWS Lambda. Lambda also removes older snapshots because during creation a delete tag is attached for sevens days after their creation. It's important to make a separate MySQL backup as with snapshots the database often gets corrupted and its easier to restore a database backup than to fix a corrupted database. Another nice feature to use AWS Lambda for is a simple HTTP service health checker, which reports to you by email or sms when the website is down. Making use of all these Amazon services cost me probably somewhere between 10 - 15 $ a month, I have to estimate a little since I am running a lot more things on AWS than only the website. The site is running on a Comodo SSL certificate but next year I will change to the free LetsEncrypt, as it is easier to add and will automatically renew after 90 days. The Comodo certificate requires manually copy pasting and editing the certificates in place. Writing Content The content for the site I write in the Redmine wiki, most of the content I write requires research and it takes about two weeks before I publish the content to the Processwire site. For writing content I use the google spell checker with the grammar checker, After the Deadline. To ensure catchy headlines they are optimized with the Headline Analyzer from CoSchedule Social Media Now the site is running, it needs promotion. The robots.txt files shows the search engines the way as does the sitemap.xml both of these I have made in a template file. Most of the blog articles I promote are republished on social networks like, LinkedIn, Tumblr, Google+, Twitter, and some branch specific networks as the Waternetwork and Environmental XPRT. To check, the search engines index the site well, Google webmaster and Bing webmaster check for any problems with the site. For statics on the same server there is an instance installed of Piwik. Piwik is a leading open alternative to Google Analytics that gives full control over data. The Piwik setup works very well and gives a good overview of the site usage both on the desktop via the site or via a mobile app. As a part of a test I have installed the open-source SEO-panel on the same server to manage keywords and to further improve the scores in the search engine, a nice feature is that you can also track your competitors. I am still new to SEO panel and have to learn more how to use the tool effectively.
    1 point
  9. I'll see if I can (flat out at the moment but needed an email image module for Processwire as Ryan's isn't supported in PW 3)
    1 point
  10. 1 point
  11. I guess it is normal. IDs "cannot be edited". They get deleted first and afterwards new record is created.
    1 point
  12. I've just tried to assign custom integer values as @oma did, and I'm having the same issue. Once I submit, PW tries to delete former options as well. This is probably the intended behavior. and once I confirm to delete those options, I get unique incremential ids for the new options Checking the database entries, it seems value field isn't filled at all, instead option id is returned I'd say there's definitely a bug here.
    1 point
  13. Thanks for the quick update! I didn't even had time to blink
    1 point
  14. According to the docs there should be no issue with it: "While we recommend letting the Options Fieldtype assign unique ID numbers for you, you may optionally assign your own. To do this, specify 123=title when adding a new option, where 123 is the ID number you wish to assign and title is the title text for your option." https://processwire.com/api/modules/select-options-fieldtype/#adding-new-options Also in the fieldtype_options table of database, option_id is int(10), so your numbers should work. Maybe a bug?
    1 point
  15. Not a problem, thanks for the quick fix. Reinstalled and working perfectly
    1 point
  16. Sorry, @houseofdeadleg and @szabesz. Looks like one of my previous performance improvements caused this module to require PHP 5.5+ , which is probably the source of the issue you experienced. The latest version pushed to GitHub reverts that particular change, so upgrading to the latest version should fix this issue.
    1 point
  17. I've just updated this module on my local and development servers. On the local machine there were no problems, however, on the dev server after updating the site's gone down with a 500 error and the log shows "Compile Error: Can't use method return value in write context (line 346 of /var/www/sm-prod-new/site/assets/cache/FileCompiler/site/modules/ProcessChangelog/ProcessChangelogHooks.module)". The only way I can see to get the site back up and running is to remove the ProcessChangelong directory from the Site > Modules folder. Once back on the site though I still have the Changelog page in the menu, it just shows the message "The process returned no content." If I try to reinstall the module I get the error message again and the site goes down. I'm running ProcessWire 3.0.62.
    1 point
  18. well! that was easy. thanks alot. i didn't know that users are page references.
    1 point
  19. It's an AdminOnSteroids module issue, please update to the latest.
    1 point
  20. Yep, several times though the download icons was not harmed at all Update to v151 to fix.
    1 point
  21. No, no in this product had very large place for clean categorisation. It is very easy to separate tools and showers or tiles or parquet or painting colors... Except, had that problem on category level, but for that use "tags". As example, in category "Tools" are about 100 products, but also inside that category had tags "for painting", "cleaning"... Also know what are you talking here, as example in some rental site some house can go to rent and sell at the same time (that was my client request in one project). Solved that without problem using "tags". Low level item is property, but same property can have various status... Also property can be house, flat, ship...whatever...
    1 point
  22. Interesting... I've been saying for a while that I'd love to help the docs get better. As they are now, I think they're pretty good - but things could always improve, and if there is one thing in development I am uber-passionate about, it's documentation!!
    1 point
  23. @Mustafa Online The Admin Theme Uikit is ready to take to the next level by the community, however, no one has taken a grasp of that project yet. I sadly don't have the time yet to work on it, however I have ideas for it. I expect @renobird will pick it up at some point and guide the project. It will not hit master until UIkit comes out of beta, which from what they say, will be a very long time.
    1 point
  24. @benbyf Thanks Ben The token request could be on the admin side BUT the Dropbox call back URL must be a publicly viewable page to receive the token. I chose to put both the request and response on the same page and then unpublish the page once I'd received the token. According to the documentation, https://github.com/kunalvarma05/dropbox-php-sdk/wiki/Working-with-files the answer is yes. The PW module really does little more than authenticate the user and allow you to create the $dropbox object (as in example above for sending a file). Add all the appropriate "use" namespace statements in your template and you'll have full access to the API, including the ability to List Folder Contents
    1 point
  25. WordPress guys have already "invented" the idea of integrating a 3rd party plugin into the core of the next major release. If developers can nominate and vote for the next such plugin/module then it is a very effective way to boost the system with features most people need.
    1 point
  26. Thank you gmclelland, I'll take a look at the module, looks promising. ...ok, I have a modified version of the twig module for the "TemplateEngineFactory" Module. If someone is interested: https://github.com/cojaco/TemplateEngineMustache
    1 point
  27. On the subject: https://blog.toggl.com/how-does-music-affect-work-infographic/
    1 point
  28. Aha, yes! Thank you! I keep forgetting that we have unformatted values too. I updated both methods in my original post. Cheers,
    1 point
  29. Nice tutorial, thanks! You could simplify the methods a little by making sure you always get the Images field as a Pageimages array, e.g. $wire->addHookMethod('Page::siteFeaturedImage', function($event) { $page = $event->object; if ($page->template != "article") { throw new WireException("Page::siteFeaturedImage() only works on 'Pages of article template', Page ID=$page is not such!"); } $article_featured = $page->getUnformatted('article_featured'); // always a Pageimages array if (count($article_featured)) { $img_url = $article_featured->first()->url; } else { $img_url = urls()->templates . "assets/img/missing-article_image.jpg"; //we show this when image is not available } $event->return = $img_url; });
    1 point
  30. what about returning some json data from inside modules? the halt() method only applies to templatefiles. is there a way to halt any other output inside the admin (inside a module) other than this? echo json_encode($mydata); die(); or is it fine to do so?
    1 point
  31. Hi @rick, I can't share my custom profile because it contains pro modules. And it's set up to suit my preferences and idiosyncrasies which would surely be different for each person. But it's very easy to make your own custom profile. If you find yourself installing the same modules or creating the same kinds of page structures over and over for each project then the idea is: Create a new installation on your localhost using the "blank" profile Customise /site/config.php how you like, e.g. imageSizerOptions, useMarkupRegions, setlocale() Install your favourite modules - include the Site Profile Exporter Set up any admin tweaks with AdminOnSteroids and/or AdminCustomFiles Create the fields, templates and template files you tend to need for every new site (it doesn't hurt if there are some that aren't always used as you can always delete them in any project that doesn't need them) Create any page structures you want to have pre-existing (I have a "news" section, and a "selects" section for Page Reference options) Export your site profile Then when you are creating a new project you just copy the profile folder to the root before installing PW and select it during the install process. I keep my starting profile on localhost and update/re-export it from time to time with the latest module upgrades and any new tricks and tweaks I have learned.
    1 point
  32. Now I found out that the Tags get saved for me also under PW 3, but the form fields (Tags, Descriptions) got not populated via AJAX, so when the page finally gots saved in the page editor, the previously saved values get blanked out again. I HAVE USED THE WRONG HOOK! Damn! It has to be addHookBefore and not addHookAfter. I changed the code in the first post so that it now is working with PW 2 and PW 3. Sorry for the confusion. (I copied the function out of an old module into a $wire->hook for site/ready.php. Hereby I must have accidently changed to the wrong hook event. Damn!)
    1 point
  33. Ok. // code snippet that belongs into the site/ready.php file: // a hook that reads IPTC keywords on images upload and populates them into the images tags field $wire->addHookBefore("InputfieldFile::fileAdded", function(HookEvent $event) { $inputfield = $event->object; // handle to the image field if(!$inputfield instanceof InputfieldImage) { // we need an images field, not a file field return; // early return } if(version_compare(wire('config')->version, '2.8.0', '<')) { $p = $inputfield->value['page']; // get the page, PW < 2.8 } else { $p = $inputfield->attributes['value']->page; // get the page, PW >= 2.8 | 3.0 (or only from 3.0.17+ ??) } $image = $event->argumentsByName('pagefile'); // get the image // check for IPTC data $additionalInfo = array(); $info = @getimagesize($image->filename, $additionalInfo); // read image markers if($info !== false && is_array($additionalInfo) && isset($additionalInfo['APP13'])) { // APP13 is the IPTC marker $iptc = iptcparse($additionalInfo['APP13']); // IPTC field 025 = keywords collection if(is_array($iptc) && isset($iptc['2#025']) && is_array($iptc['2#025']) && count($iptc['2#025']) > 0) { $tags = array(); foreach($iptc['2#025'] as $k => $v) { if(empty($v)) continue; $tags[] = trim(strtolower($v)); } $p->get($inputfield->name)->trackChange('tags'); // prepare page to keep track for changes $image->tags = implode(' ', $tags); // add the tags list as string $p->save($inputfield->name); // save the page images field } } }); EDIT: code was modified to detect $page also with PW version >= 2.8 | 3.0 EDIT 2: Now it is working for all PW versions again. Had have the wrong HookEvent used here (addHokkAfter, but must be: addHookBefore!)
    1 point
  34. Processwire is great and all, but not magic it won't guess what you want to do with the fields, so you have to tell it with code. You'll have to know at least some html and learn the API in order to do structural changes to your website or, in alternative, hire a developer.
    1 point
  35. Getting back to this topic may I ask if there are any plans to update the cheatsheet in near future? Or is it discontinued? The cheatsheet is such a valuable resource. I would be glad to assist in updating it but I'm afraid my understanding of the API isn't good enough. Thanks for keeping us informed.
    1 point
×
×
  • Create New...