Popular Content

Showing content with the highest reputation on 02/22/2015 in all areas

  1. 14 points
    Just saw this announcement in my favourite german computer magazine c't. In the next issue on March 7th, there will be an article about our favourite CMS processwire. Anybody knows who is writing this article, someone from the forum? And be prepared for some traffic... For all non german speaking people, the text reads as follows: ProcessWire instead of Joomla, WordPress and others A modular content managment system, which adapts to the needs of web developers - instead of contrary. ProcessWire promises much freedom without ballast. Whether blog, club site or a complex business site - the free CMS handles it all.
  2. 5 points
    I made a Leaflet version of this module: https://github.com/madebymats/FieldtypeLeafletMapMarker- Front-end demo: http://tegelwebb.se/leaflet-map-test/
  3. 3 points
    @pideluxe, that is AWESOME news, c't is a huge computer magazine in Germany. And look at the logo within that futuristic collage, adorable Very excited. thanks for the info.
  4. 2 points
    You could also iterate all users instead: foreach($users as $u) { if ( $u->hasPermission('page-view', $page) ) // send email to $u->email }
  5. 2 points
    Yes, they are equivalent, but you had: $wire->$input->post->search; instead of: $wire->input->post->search; Note the $ before input in your version. Sorry I should have explained a little more completely
  6. 2 points
    Just a guess, but what about the path to your query.php. You say it's in your website root, but if it's being called from a PW page, then you need to use a root relative path, likely just: url: "/query.php", Don't forget that you can find out if there was a 404 on that file in the Network tab of your dev tools console.
  7. 2 points
    You can't do that (getUnformatted is method of Page object, tableRow doesn't have that), but you can do: $raw = $page->getUnformatted("draw"); var_dump($raw); But in your case it might be easier just to convert your field into timestamp: $timestamp = strtotime("pretty much any date format");
  8. 1 point
    Some time ago I developed a module (FieldtypeImageExtra) which extends Fieldtype Image with the ability to add custom fields to an image. This worked well but it had a somehow restricted applicability and did not meet all of our needs. There of course are other useful image modules like CroppableImage or ImageFocusArea, but up to now there was no possibility to combine image cropping with custom fields support. So you had to decide whether to add image cropping or the possibility to add custom fields because each of those modules sets up their own field type (and input type) which cannot be combined. The new module ImageExtra allows you to have both functionalities. You can get the module from GitHub. For more informations have a look at this blog post. If you notice any problems or unexpected behaviour please let me know.
  9. 1 point
    Where do i get? From here: https://github.com/IDT-media/Pages2JSON (thanks to LostKobrakai for "bug" report) What does this do? Simply adds method toJSON() to Page and PageArray elements, is capable to converting image and file arrays to URL containers, travels recursively all objects before outputs actual JSON. How to use? Simply install this module, configure data you want it to export in JSON result (similar to Ryan's ServicePages, thanks btw used some of ur code here). in templates or anywhere you need JSON output, call: $page->toJSON(); or $pages->toJSON(); Live example with template: search.php /***************************************************************** Do search *****************************************************************/ $term = $sanitizer->text($input->term); $results = array(); if($term) { $input->whitelist('term', $term); $term = $sanitizer->selectorValue($term); $limit = (int)$input->limit; $limit = $limit ? $limit : 50; $limit = $sanitizer->selectorValue($limit); $selector = "title|categories|content*=$term, limit=$limit, template=default|product"; // Prevent admin pages. if($user->isLoggedin()) $selector .= ", has_parent!=2"; // Find pages that match the selector $results = $pages->find($selector); } /***************************************************************** Output *****************************************************************/ header("Content-type: application/json"); echo $results->toJSON(); exit(); Customizing values: if(wire('config')->ajax) { wire()->addHookAfter('Pages2JSON::getValue', function($event) { $value = $event->arguments(0); if(!is_object($value)) return; $page = wire('page'); if($page->template == 'thumbs' && $value->className == 'Pageimage') $event->return = $value->size(28,28)->url; }); } Here i swap URL of all Pageimage objects in JSON response to match thumbs. Simple hu?
  10. 1 point
    FieldtypeSelectFile & InputfieldSelectFile Inputfield Select File is an Inputfield & Fieldtype to select a single file or folder and stores the name and / or use the selected file as page template. The last option enables the editor to use multiple views for a page, depending on the selected template. Settings The folder containing the files and/or folders.A relative path relative to the /site/templates/ folder. Hide file extensions Hide files Hide folders Natural Sort (Select options)Sort files and folders in natural ordering (PHP >= 5.4.0) Change Page Template Just before the Page::loaded event the selected file is set as template file for the page. This setting can only be applied once per a page and folders are exluded from the select inputfield. Note that a page with no associated template file will render with the selected file. When to use ? Let editors select a file and base your own logic upon this. With the change page template setting you're able to use the selected file as template file. This could reduce the amount of normal templates needed and let editors choose how the page get rendered. There are plenty of use cases for this Inputfield. In the examples I call the field selected_file. // let the editor choose a CSS file $config->styles->append($config->urls->templates . "styles/" . $page->selected_file); /** * advanced usage example * * You need multiple ways to render your markup. Let the site editor choose which * file the page need to render. * */ $tpl = new TemplateFile($config->paths->templates . "includes/" . $page->selected_file); $tpl->set('current', $page); $markup = $tpl->render(); (It could be a real good companion with InputfieldSelector) Download at GitHub Modules directory
  11. 1 point
    Hi everybody, First of all: Thanks to everybody for keeping the community alive. Every time I search for something in the forum I find the solution. Great work! I wanted to share a small module with you / my first one. I use it in order to switch the user language on page load. Processwire GeoInfo GeoInfo is a small module that Implements Geoplugin PHP web service. Please donate to "geoplugin.com" in order to keep the service alive. The Module ads two methods to retrieve data from the web service. $page->GeoInfoIP('IP ADDRESS'); you can enter the ip address manually. If left blank the server remote address will be used. The retrieved data is then stored to the active session, in order to limit the requests. The web service gives back following data. 'geoplugin_request' 'geoplugin_status' 'geoplugin_credit' 'geoplugin_city' 'geoplugin_region' 'geoplugin_areaCode' 'geoplugin_dmaCode' 'geoplugin_countryCode' 'geoplugin_countryName' 'geoplugin_continentCode' 'geoplugin_latitude' 'geoplugin_longitude' 'geoplugin_regionCode' 'geoplugin_regionName' 'geoplugin_currencyCode' 'geoplugin_currencySymbol' 'geoplugin_currencySymbol_UTF8' 'geoplugin_currencyConverter' for e.g. $page->GeoInfoIP('IP ADDRESS')->geoplugin_countryCode; will give back the country iso code. $page->GeoInfoLatLong('LAT', 'LONG'); Enter Latitude and Longitude in order to get following information: 'geoplugin_place' 'geoplugin_countryCode' 'geoplugin_region' 'geoplugin_regionAbbreviated' 'geoplugin_latitude' 'geoplugin_longitude' 'geoplugin_distanceMiles' 'geoplugin_distanceKilometers' for e.g. $page->GeoInfoLatLong('40.712784', '-74.005941'); will give back the city name "New York City". Todo store places in json file / check if place exists implement nearby "service" https://bitbucket.org/pmichaelis/processwire-geoinfo
  12. 1 point
    <?php $last = $pagearray->pop(); echo $pagearray->implode( ', ', 'title', ['append' => ' & '] ) . $last->title;
  13. 1 point
    @Mats, Thanks for this. Please consider submitting your module to the modules directory as well as creating a new (support) thread for it
  14. 1 point
  15. 1 point
    Take a look at lazysizes from Alexander Farkas who's on the modernizr team: https://github.com/aFarkas/lazysizes Very complete and constantly updated, it even includes its own responsive images polyfill and a set of additional plugins to lazyload iframes, modules, background images, etc.
  16. 1 point
    That depends a lot of how you are structuring your templates. scripts and CSS should go on the head and before the closing body tag, but this has to do more with markup than PW itself. The example on the Owl docs has everything on the head <!-- Important Owl stylesheet --> <link rel="stylesheet" href="owl-carousel/owl.carousel.css"> <!-- Default Theme --> <link rel="stylesheet" href="owl-carousel/owl.theme.css"> <!-- jQuery 1.7+ --> <script src="jquery-1.9.1.min.js"></script> <!-- Include js plugin --> <script src="assets/owl-carousel/owl.carousel.js"></script> Make sure you call jQuery before calling the Owl script, and follow these examples to adapt the css and script links to point to PW templates folder https://github.com/ryancramerdesign/ProcessWire/blob/master/site-beginner/templates/_head.php#L8 https://github.com/ryancramerdesign/ProcessWire/blob/master/site-classic/templates/head.inc#L32 https://github.com/ryancramerdesign/ProcessWire/blob/master/site-default/templates/_main.php#L39
  17. 1 point
    The following works for me. You first have to enable 'Do you want to manage view and edit access.....' in the Access tab when editing that template. //$t = $page->template;//if on this page $t = $templates->get("skyscraper"); //echo $t->name . '<br>';//confirm we are looking at the right template $tRoles = $t->getRoles(); foreach ($tRoles as $r) { echo $r->name . '<br>'; } getRoles() seem only to work if 'view pages' permission is enabled on that template for a role.
  18. 1 point
    array() is a php function, so "Boo!"
  19. 1 point
    @martijn, wow can't thank you enough; this module has come in handy so many times; this is a great enhancement to it.. thanks!! BTW - just tested and it works perfectly!
  20. 1 point
    I didn't forgot... Here is my solution: templates(fields): - mailbox (generate view and calls MailboxClass as controler) - threads (title, headline, userProfiles [FieldtypePage]), - messages (title, threads [FieldtypePage], msgBody, dateCreated) userProfiles contains 2 userinfo pages (sender and receiver) which title is equal to username page structure: - Mailbox (mailbox.php template) -- Threads (threads.php which purpose is only as selector) ---- salepg (messages.php which purpose is only as selector) ---- salepg-1 ---- mr-fan ---- lostkobrakai mailbox.php <?php include './functions/MailboxClass.php'; /** here some code to generate basic view */ ?> MailboxClass.php <?php $out = ''; /** locate threads page */ $p = $pages->get("/mailbox/threads/"); /** find threads that belong to logged user */ $threads = $p->find("userProfiles={$user->name}, template=threads, limit=10"); foreach($threads as $thread) { /** making thread object */ $t = new Mailbox($thread); /** output thread's info and last message in that thread */ $out .= "<a href='#'>".$t->receiver."</span> <span>".$t->subject."</span> <span>".$t->msgBody."</span> <span>".$t->dateCreated."</span> </a>"; } class Mailbox { public $thread = NULL; public function __construct($thread) { /** title contain only username of someone who start conversation */ $this->title = $this->title($thread); $this->subject = $this->headline($thread); /** * output receiver's name; user assume that he is in conversation * userProfiles contain 2 User Pages as persons involved in conversation * sender is person who start conversation * receiver is person who will be displayed to person who checks messages */ foreach ($thread->userProfiles as $up){ $this->sender = $this->title; if($this->title != $up->name)$this->receiver = $up->name; } foreach ($thread->children as $message){ $this->msgBody = $message->msgBody; $this->dateCreated = $message->dateCreated; } } private function title($thread) { return $thread->title; } private function headline($thread) { return $thread->headline; } } I ommited a lot of code to simplify this solution and showed just threads that belong to logged user. For starting new thread, reply or open specific thread or message, it's easy to upgrade this code. Also, I used PHP class as a part of maibox.php, again, for the sake of simplicity. powered by mr-fan and LostKobrakai Cheers!
  21. 1 point
    Adrian no problem Indeed I appreciate this, it's always good to learn more and to get some feedback. I just started my second ProcessWire project and there is so much more to discover... I tried to use the Page Fieldtype (parent=page.otherpagefield) but I got a complete different output. The point is that I don't want to get a whole page object, I need a plain value in order to receive this value using the ServicePages API. Unfortunately my use case is quite complex and you need a lot of background knowledge so I had to find another example. Use case: Categorize Posts/Pages "The common way": Create a single page for each category. Add a Page Inputfield, set up the parent page / template and you get a select list of categories (pages). Fine. "My way": Create just one page to hold all categories in a repeater. Add a SelectRelation Inputfield, set up field=category, repeater=r_categories. Then you get "the same" list. If you need more than just the title (or any other field) you should use the Page Inputfield for sure. The difference is that you don't select a page, you select a field value depending on a page. I guess this should also work for Profield Table subfields but I didn't test it.
  22. 1 point
    I've just committed and update that will let you remove any system flag/status from Fields, Templates or Pages using this method below. This is how you could delete system fields, templates or pages. The code below is what you would do right before you delete them. Please don't do this on any of PW's system fields, templates or pages. The system flags exist precisely so people can't delete these. This override is provided only for uses like yours and mine where we've created system fields/templates (or pages) with modules but want to be able to uninstall them with the API. So here's how you'd do it: Field: <?php $field = $this->fields->get("discussions_message"); $field->flags = Field::flagSystemOverride; $field->flags = 0; // all flags now removed, can be deleted Template: <?php $template = $this->templates->get("discussions-forum"); $template->flags = Template::flagSystemOverride; $template->flags = 0; // all flags now removed, can be deleted Page: <?php $page = $this->pages->get('some system page'); $page->status = Page::statusSystemOverride; $page->status = 0; // all status removed from page, can be deleted With regard to users adding your fields to other templates, I would just throw an exception on your uninstall if that is the case. That way you can tell them to remove the field from any templates where they may have assigned it. Though if you've made them system fields, chances are people won't be adding them to other templates since one has to be in the $config->advanced system dev mode in order to do that. <?php if($field->getTemplates() as $t) if($t->name != 'discussion-topic') throw new WireException("Please remove {$field->name} from {$t->name} template before uninstalling."); If you want to do a recursive delete of a discussion tree, you could do it like this: <?php foreach($this->pages->find("template=discussion-forum") as $p) { $this->pages->delete($p, true); // true = make it a recursive delete }
  23. 1 point
    That might be a good thing to add. In the Languages module, I was running into the same question yesterday. I ended up making them system fields and templates. So for fields I did this: $field->flags = Field::flagSystem | Field::flagPermanent; flagPermanent means it can't be removed from the template it's assigned to (which you may or may not want). flagSystem means it can't be deleted from the system and doesn't show up in the regular fields list. And for templates I did this: $template->flags = Template::flagSystem; Using this method, your fields and templates shouldn't show up in the user-defined places, and the user can't delete them either. Then the question of uninstall… I'm working on an override option so that the API can delete them (for the uninstall method).
  • From Twitter

    • New post: This week we take a look at what’s in ProcessWire 3.0.126 which focuses largely on resolving issue reports, but also includes a handy new Page if() method— processwire.com/blog/posts/pw-…
      15 February 2019
    • New post: ProcessWire 3.0.125 has several useful new Sanitizer methods & options, plus new ways to access them directly from the Input API variable. This makes handling user input even easier than before. Plus updates to our i18n functions & API docs— processwire.com/blog/posts/pw-…
      25 January 2019
    • New post: In this week’s post, we’ll take a look a look at the new website and focus on some parts of it and how they were built. Then we’ll dive into the latest version of ProcessWire on the dev branch, version 3.0.124— processwire.com/blog/posts/pw-…
      11 January 2019