Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/18/2014 in all areas

  1. PW has very flexible UA management. Most of the sites can get the exact needs fulfilled after little clicking. But when you need to scale it in horizontal way: ie. adding ten different news sections, each with same templates but managed by different group of people, PW doesn't make it too easy (since UA is tied to templates). Also roles&permissions&template access is a combination, that at least we cannot leave to our clients (it's way too complicated for your average editor) - it means that UA management have to be done by us. This is fine on small scale, but some of our sites are pretty heavy on UA: biggest site has over 800 user groups and many times we do have something like 50 000 users importet (these sites are not build on pw today, but hopefully they will be). So we need to have simpler UA that our clients understands and can use on daily basis. That will also mean less granular control, but easier to manage. Lucky for us, PW has hook system in place, that is flexible enough to allow hooking to UA also. Few months ago I started building module to add two features for PW: -user groups (user can belong to more than one group) -page based permissions based on groups (so you can say: this page and it's children can be edited by groups A + B and viewed by groups A + B + C I first thought that I should release this as a paid module, but after showing this current early version to Nik and Teppo (I knew they had similar needs) and when they showed interest in development I wanted to make this a community project (this is gonna be thousand times better than just me building it alone). So lot's of progress is coming and of course everyone is invited to collaborate. Be it ideas, comments, testing, use cases etc.
    10 points
  2. Or simply use the getPage() method. $page = $event->object->getPage() https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module#L1110
    4 points
  3. Just wrote a new tutorial! Instead of writing it down here I did it on my recently created new blog. http://soma.urlich.ch/posts/create-a-helper-module-for-processwire/
    3 points
  4. I'm *not* a fan of anyone deciding for me whether or not a link opens in new window / tab, but this is the one case where it might make sense. I'm not too fond of the "even content authors should be able to get used to it" explanation either, partly because I myself keep forgetting it.. Form Save Reminder helps a lot with this issue, though. As a matter of fact it's one of those 3rd party modules I think should definitely be baked into core and even enabled by default. By the way, Ryan, this is probably wrong place and time for this, but were you aware that modules directory is currently doing exactly the opposite of this? Module links are catching mouse middle button clicks and redirecting, effectively overriding commonly used setup where middle click opens link in a new tab. (It's driving me nuts, another quirk I just can't seem to memorize..)
    3 points
  5. It wouldn't be safe to exclude pages without template files from most find()s as that would be making the assumption that all find()s are for presenting navigation or search results to a user. PW makes no assumptions about what you are using the data for, so couldn't safely exclude pages based on that factor. If we were to implement something for this in the core in the future, we'd probably do it with a new selector option like "template_file_exists=1" or something along those lines. But if you've got pages without template files showing up in your search results, it might also be good to look at whether your search might need to be made more specific, or if your pages with no template file should be excluded with an access controlled parent. But I'll keep marinating on this template_file_exists option for selectors, as it may be a worthwhile addition.
    3 points
  6. Great tutorial Soma! Thanks for making it. One thing I wanted to mention is that this syntax: wire("fuel")->set("helper", $this); has been replaced by this syntax: wire('helper', $this); // or this: $this->wire('helper', $this); But of course your tutorial is correct in using 'fuel' since it would be compatible with past versions of ProcessWire too. Just wanted to mention it since I think the API is simpler if all getting or setting of API variables is just done through the wire() or $this->wire() functions. But the old syntax will always continue to work as 'fuel' is itself an API variable, but one that I figured makes more sense as an internal-only API variable.
    3 points
  7. Hey Macrura, if I understand correctly, this module is working on the Admin, so you need to get the template of the page that is being edited. If you do $page->template / wire('page')->template, it won't work, because this will be the template of the "Edit" page, which will be the admin template. What you need to do is something like this: $page_id = (int) wire('input')->get('id'); $edited_page = wire('pages')->get($page_id); if($edited_page->template != 'camp') return; I think that should do the trick!
    3 points
  8. I think it would be good thing to add domain to html title in admin default theme. I added a long time ago to my admin theme. Instead of Pages • ProcessWire make it mydomain.com • Pages • ProcessWire or Pages • ProcessWire • mydomain.com This would help a lot with seeing in windows list and bookmarks, what site it is from. I can't stand seeing my co-worker looking for the correct window for hours Thanks
    2 points
  9. Whether cached at view or save, t's exactly the same amount of work either way. Though caching at save potentially creates more work. Whether we're talking about template cache or ProCache, there are a few reasons why it's better to do it upon first view, rather than upon save. Pages are only cached for guest users. If we performed an automatic cache after a page save, it would be within the context of the user editing the page. This is not a context we want to cache. You want the page to be cached within the context of a real page view, not from something automatic or behind the scenes. This ensures that any other modules that are part of the render process also get to participate. You may save a page multiple times in a short period of time (don't we all?). If it gets cached on every save, you are potentially using a lot more resources than if it was just cached the first time it was viewed from a guest user. If we regenerated on save rather than view, that would be a whole lot of extra saves that have to be performed in the system (a save uses a lot more resources than a view). Keep in mind cache files automatically expire after some period of time (defined by you). You can't rely purely on a save() for knowing when data is stale or not, as your site may be pulling data from multiple pages or other resources.
    2 points
  10. While I can't duplicate the small square, I do see that the dropdowns aren't showing for a user with the permissions you mentioned. I've fixed it and it'll appear in the next update. Thanks! I honestly don't agree, and really don't like sites/apps opening new windows/tabs for me (that's what option+click is for). But you aren't the first person to mention it, so I'll try to accommodate both preferences somehow or another.
    2 points
  11. Soma is right, this was already added a few months ago. Double clicking the trash icon on any file/image now marks all for deletion. Double click again and it unmarks them.
    2 points
  12. Too simple to be a module, consider a script like this: $array = $pages->find("template=basic-page")->explode(function($item){ return array( 'id'=> $item->id, 'title' => $item->title ); }); $fp = fopen('file.csv', 'w'); foreach ($array as $fields) fputcsv($fp, $fields); fclose($fp); Note, $pagearray->explode() used here is only available in 2.4 (2.3 dev) http://cheatsheet.processwire.com/pagearray-wirearray/getting-items/a-explode/ And the anonymous functions requires php >= 5.3 http://php.net/manual/de/functions.anonymous.php
    2 points
  13. Double click the trash icon. Voila.
    2 points
  14. Hi Folks, I just added a small module that keeps track of search keywords encoded in http referrers from common search engines leading to your site. See the README for a full documentation of features. Please let me now, if you have found any issues, feature requests or opinions by leaving your comments here in the forum or on github. Regards from Hanover, Germany, Marco
    1 point
  15. Gotta say that latest iteration looks, feels and works great! Also I love the themes as a modules thing.
    1 point
  16. I wonder how many people vote at least twice for their favorite app, once via their home connection and once via 3/4G with their smartphone... These kind of polls are fundamentally flawed butt it is nice to see PW up there
    1 point
  17. You can use PHP's default mail function: $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); But personally I would recommend installing the free SwiftMailer class (swiftmailer.org). It is incredibly powerful and can easily send mail using SMTP, can include both HTML and plain text versions in the one send, allow you to add attachments which is great if you are using a PHP PDF generating class to automatically generate a receipt, and lots more!
    1 point
  18. ok guys, there have been some major updates to the boilerplate. Check it out at https://github.com/fixate/pw-mvc-boilerplate, and take a look at my original post for a few details on the updates. Things are far neater
    1 point
  19. Too bad, WilllyC missed the 50'000th massages. Congrats PW!
    1 point
  20. Regardless of a CMS/CMF for sites like these you need to have decent knowledge of scripting. Next, the preparation before you even can start building sites like these takes awful lot of time. As Kongondo stated, those sites require significant amounts of custom code. 1) When you're new to ProcessWire and want to build this you need to have a good understanding of PHP/ OOP. 2) Accept the extra time it takes finding out `best practices` for PW. 3) Very, very good preparation. If you want to do it with PW, it's all in there. ps, I don't want to build anything not build on top of PW.
    1 point
  21. I think something like this should do what you want: echo date("j. F Y", $pages->get("sort=-modified")->modified); It finds the last modified page. You can of course change this to created and also limit to various templates, parents, etc if you want.
    1 point
  22. Hi Alec, Welcome to the forums. The simple answer is yes.... the realistic answer is: Such sites will most likely require significant amounts of custom code. As you rightly stated, PW is a framework It will give you the necessary tools to build the site but you will have to get your hands dirty...Having said that, there will be some things you will be able to get with PW right out of the box, e.g. pagination... Maybe you can expound on the specs of your travel site to get better answers... These sites built with PW may be of interest: http://www.villasofdistinction.com/ http://www.goaroundeurope.com/ http://processwire.com/skyscrapers/ More here: http://processwire.com/talk/forum/9-showcase/
    1 point
  23. Running PHP Version 5.3.27, memory limit set to 64M and max_execution to 60 seconds. Trying it with 128MB now. Looking through the logs, I've found some suspicious entries. Time it little bit off: [Thu Jan 16 20:12:50 2014] [error] [client 87.165.***.***] mod_security: Access denied with code 406. Pattern match "cc:" at POST_PAYLOAD [severity "EMERGENCY"] [hostname "redacted.com"] [uri "/processwire/page/edit/?id=22354"] If this is the issue, Ryan was right. Thanks. Looking into mod_security now. EDIT: Solved! Google spit out some interessting links for "POST_PAYLOAD" and mod_security. I've deactivated the POST filtering for mod_security. Just add this to your .htaccess file: <IfModule mod_security.c> # Should mod_security inspect POST payloads SecFilterScanPOST Off </IfModule> Taken from this site (more info)
    1 point
  24. Oh, there are plenty. Finding them awake, sitting upright and facing front is another matter, however.
    1 point
  25. Had the exact same issue with a stubborn Trash. Patched my 2.3.1 installation manually -- thanks Ryan!
    1 point
  26. What version of PW are you running? Does this post help - Ryan has a fix for the current stable: http://processwire.com/talk/topic/4384-cant-empty-trash-or-delete-indivdual-trashed-pages/ PS In case you don't know, the search mechanism in this forum is not great, but the following search in google works a treat: site:processwire.com "Call to a member function hasRole() on a non-object"
    1 point
  27. This viewable check is something done on runtime and not on db level. Here an example to do what you want: $excl_tpls = "template!="; foreach($templates as $tpl){ if($tpl->filenameExists()) continue; $excl_tpls .= "$tpl->name|"; } $excl_tpls = rtrim($excl_tpls,"|"); foreach($pages->find("parent=1, $excl_tpls") as $p){ $content .= "<p>{$p->title}</p>"; }
    1 point
  28. Good to now! I was able to pull this off like this for now. Thanks a lot for your input! Maybe a config page will be better for a public module, off course. <?php class EmailNewUser extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( // The module's title, typically a little more descriptive than the class name 'title' => 'Email New Users', // version: major, minor, revision, i.e. 100 = 1.0.0 'version' => 101, // summary is brief description of what this module is 'summary' => 'Send New users a welcome email', // Optional URL to more information about the module 'href' => '', // singular=true: indicates that only one instance of the module is allowed. // This is usually what you want for modules that attach hooks. 'singular' => true, // autoload=true: indicates the module should be started with ProcessWire. // This is necessary for any modules that attach runtime hooks, otherwise those // hooks won't get attached unless some other code calls the module on it's own. // Note that autoload modules are almost always also 'singular' (seen above). 'autoload' => true, ); } /** * Initialize the module * * ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called * when ProcessWire's API is ready. As a result, this is a good place to attach hooks. * */ public function init() { $this->pages->addHook('saveReady', $this, 'sendEmail'); } public function sendEmail(HookEvent $event) { $page = $event->arguments[0]; if ($page->template != "user") return; // stop here if this isn't a User // Only send an email if the User page is published (A new User goes live) if($page->isChanged('status') && !$page->is(Page::statusUnpublished)) { $body = "Welcome {$page->name}!"; $this->message("Welcome {$page->name}! A welcome email has been sent to {$page->email}."); @mail($page->email, "welcome, {$page->name}!", $body, "From:xxxxx@xxxxx.com"); } } }
    1 point
  29. @landitus: you're right in that using the code I posted earlier message would get sent every time user is saved, which probably isn't correct behavior. One way to achieve what you're describing here would be by simply adding a check for changed status (published). You might want to take a look at Process Changelog for some sample code. "@" character was missing by purpose; in PHP adding @ before function such as mail() suppresses errors. If you're relying on these emails getting sent, this makes very little sense, as it just tells PHP that "if this fails, no worries, just keep going as if nothing happened!"
    1 point
  30. First I'd check and double check the code you're searching for is exactly right - but you must have done that already to be able to give such a detailed description. Still, could those codes for pages 99.. have for example a space in the beginning? To check if the issue is about getting an exact match you could try it out with $pages->find("code%=xyz"). If this gives you the right matches then it has to be something with the data. To check the data you could see the database directly. Something like "SELECT LENGTH(data), data FROM field_code" will expose codes that have a length different from what you're expecting. Be it a 6 or 9 letter string, don't know which as the length changed in you post .
    1 point
  31. Thanks for the Help Soma. Yea I am still getting use to php and processwire. I will definitely nix the use of the $GLOBALS upon final testing. Just using it due to where I am loading the site. As for the issue. It seems that either addHookAfter or addHook work. It was all an issue with the fact that the FieldtypeSelect.module wasn't loaded or installed correctly. Once that got re-installed all was fine. Once again thanks for the help! Processwire's forums are great! Oh and btw, I am using version 2.3.0, just fyi. Not that it probably matters anymore!
    1 point
  32. I think you would also want to make sure the module is really loaded. If you tinkered with the autoload => true at some point you would have to reinstall the module. You could also make sure with in template if(!$modules->isInstalled("FrontendUserProfile")){ echo "is not installed"; } $modules->get("FrontendUserProfile"); // now it would be loaded Edit: Something I noticed is that strange ugly $GLOBALS you use $GLOBALS['baseUrl']."/site/templates/styles/images/loginPic.png you could just use wire("config")->urls->templates . "styles/images/loginPic.png"; which will always return correct url. But then I don't understand what your baseUrl should be good for, as you use it also for a redirect.. ? I guess you have pw installed in a subdirectory? But pw urls methods will already include that.
    1 point
  33. Correct me if I am wrong, but I feel you may be a bit out of your depth by starting with the Skyscraper profile. How comfortable are you with PHP? Secondly, it will be helpful if you show code examples of what you have done. It is a bit difficult to follow what you are saying (for me at least ; no offence meant). I don't get the question about the section...But, you just can't copy paste code without making changes and expect it to work...So, show us your code and clarify what you mean by section..
    1 point
  34. If life was a $page we had less trouble hacking it
    1 point
  35. Thanks so much for all the suggestions people. I ended up opting for pages built from four tables, and that seems to everything I want and more. For the benefit of any future readers..... While it's probably self-evident, a separate template for each table made the whole process easier to manage.Tables imported like a dream with the import Pages from CSV module. What was even dreamier was correcting a few mistakes or three (having too much fun with PW to catch up on some sleep) with the ability to do bulk trash/change templates operations with the Batcher module. I found out the comma delimiter is a bad idea if your field already has commas in it (duh). Delete mangled pages, reimport as tab delimited, problem solved. Linking the tables/pages up inside PW was a joy instead of a nightmare. There's probably better/other ways, but I just coded the templates to provide the functionality (mostly navigation and display) that I needed. I'm wrapt and can't wait to push the envelope further. Who'd of thought Christmas would come round again so quickly.
    1 point
  36. Just updated the Twig library that is shipped with the module to the current release v1.15.0.
    1 point
  37. Noticed an issue with the dropdowns and user permissions. I gave an non-superuser permission to administer users. The Access menu then appears, but nothing drops down from it, other than a small square - just a few pixels in size. The same thing actually happens when I add a "Tools" main menu item using diogo's Custom Admin Pages module. Again, the dropdown won't work unless the user is a superuser. On an unrelated note, I think the new site link should open in a new tab by default so no-one will lose any unsaved edits.
    1 point
  38. Well, yeoman is a pure client-side stack, meaning it isn't made for backend programming at all. It is pure JS. What I did was set up two distinct projects for the frontend and the backend, respectively: I set up my PW templates as RESTish servicessingle php file with GET based logic for simple items php file + same name folder of related assets if it is something more complex And my UI as a yeoman project, that exports to templates/ui Then linking the two is just a matter of calling it in home.php: <?php include("./ui/index.html");?> Remember, yeoman is strictly frontend, and in general only caters to single-page-app type projects. But for that scenario, it is amazing!
    1 point
  39. Hi, I just released the new minor version 1.0.4 of the TemplateTwigReplace module. The module now lets you access the Twig_Environment instance used for rendereing pages and chunks via a public getter. So now you may customize the twig environment (e.g. by adding custom filters) to better meet your needs. Please take a look at the modified readme. Regards, Marco
    1 point
  40. I just created/imported 45k pages for users infos in about 1min.
    1 point
  41. $rss->itemDateField is for fields and not for code! It's configurable on the module screen (default) and via API. To do what you want, give every page in the feed the date of today, you could add a property hook to Pages. So you can define what, for example, $page->myPubDate will return. Then use that property for itemDateField. So such a hook would look like this, as also shown in the HelloWorld.module example. In your template code just before you render the feed: wire()->addHookProperty("Page::myPubDate", null, "addPropertyDate"); function addPropertyDate($event) { $event->return = date(DATE_RFC2822); } Now after this code a call like echo $somepage->myPubDate; Will return the current date. SO later in the $rss code you can set: $rss->itemDateField = "myPubDate";
    1 point
  42. Glad to help. Just one thing - from what you describe, it sounds like you are editing the core ProcessPageAdd module. You don't want to do this, because you'll have to make these changes again every time you upgrade PW. Instead you should create your own simple module using that code. Read here for a tutorial on creating your own module: http://wiki.processwire.com/index.php/Module_Creation
    1 point
  43. http://thestationhotel.com.au/ ... for the wonderfully talented designer: http://www.jacinabox.com.au/ (ProcessWire site #32) Cheers Marty
    1 point
  44. Kongodo summed it up well. I would suggest gathering your data from the outside world into conventional database table(s) outside of PW. Set them up so they are easy for you to fill and check over. Then write a module based on Ryan Cramer's module for importing from CSV files. Make it read from your table(s) instead of a file. You can put all your code for massaging the content right in the module. With liberal use of the UI modules have for settings you can use the same tool to make various kinds of pages from input data. Working with an external database can be pretty simple: protected function externalDbConnect(){ $this->extDb = new mysqli('localhost', 'xxxx', 'yyyy', 'zzzz'); } protected function queryCount($qry){ $result = $this->extDb->query($qry); return $result->num_rows; } protected function queryForFields($table){ $a = array(); $result = $this->extDb->query('SHOW COLUMNS FROM '.$table); while($row = $result->fetch_array(MYSQLI_ASSOC)) $a[] = $row['Field']; return $a; }
    1 point
  45. Depending on your data structure, you might also consider this approach: http://processwire.com/talk/topic/5040-events-fieldtype-inputfield-how-to-make-a-table-fieldtypeinputfield/ This example module shows you how to build a custom PW fieldtype that allows you to have the power of PW API while still storing the data in a more traditional way - multiple fields per DB row. Again, the best option depends on lots of different things, but kongondo has outlined these very well already.
    1 point
  46. Hi Wilsea, It really depends on how you want to use and present your data at the end of the day + how much data we are talking... A search of the forums will tell you that most people would choose pages over custom tables. Why? For one, you get access to the powerful PW API. Of course, behind the scenes, it is all db tables, but PW takes care of that. There is (almost) a selector for any query you would want to make....If this is not the case, you can also query PW tables using normal MySQL queries. If you want to present your data at unique URLs, then pages is the way to go.... How many tables are we talking? You have probably noticed that PW is insanely fast. Ryan has done a tremendous job in optimizing selectors. With power comes responsibility; so, limit=xx is a good friend when using "find".... Relational db/References...pages is the way to go...Page Reference Fields in PW make this very easy!! If you went the pages route, you can also harness the extended power of templates, e.g. using templates to control page access... For some people, having thousands of pages in the pages tree is not desirable. However, depending on how you structure your site, this may not be a problem. If it is a problem, then you might want to think of custom tables....although, there are ways around displaying your pages in a grid (as in a table) in the backend rather than the tree..Btw, I reckon you are talking about a local db table? (i.e. not external to your domain..). Easy-on-the-eyes...PW API is beautiful and easy to read....even though MySQL-like code is easy enough to read as well... Bottom line is this: If you really don't have to, do not reinvent the wheel. PW already gives you an easy, consistent and powerful way to query your data....using the API.. It is late and I am not thinking straight. I could have missed something. Others will chip in. Also use Google to search the forums (e.g. custom tables...). You might also find it useful to read the various threads detailing how some folks here imported data from other platforms/websites into PW....There are also bulk editing modules such as CSV Import module... Hope my comments give you a little idea how you might proceed... Edited: for clarity + additions...
    1 point
  47. I recently had to deal with this too. I ended up creating a checkbox field called "rtl" and added it to the "language" template. Now you can easily add a class or hardcode like: <?php if ($user->language->rtl) echo "style='direction:rtl;'"; ?> If you add another language which needs RTL you can just check the "rtl" field and don't have to change the code.
    1 point
  48. Just launched the official website for zürich transit maritim today (just right for the press conference). Responsive (ZURB Foundation) new site for Swiss art intervention in public space. Probably the most talked about art happening 2014 in Zürich, Switzerland, and beyond. Feature excerpt: (most features will be activated / revealed later on) Bilingual (german + english) setup - with PW 2.3.8 (atm only german content available) Image gallery slideshow + galleries Download section for journalists Blog Live webcam Basic e-shop w/Paypal Google-Maps Google Drive Form I had to remove certain stuff in the last minute (e.g. showing random quotes). Now it visually looks a bit bland on pages that don't contain a left navigation. But I was too busy to create another template or change the existing ones 5 minutes before launch (expand grid for main content etc.) (I googled just now for an article in english - guess the international media will cover the story later this year only, or later this week)
    1 point
  49. I ended up with this code, extract from the session db handler module, modified excluding guest users and focusing just on count: <? function onlineUsers(){ $mins = 1; $table = SessionHandlerDB::dbTableName; $sql = "SELECT COUNT(*) FROM $table " . "WHERE ts > '" . date('Y-m-d H:i:s', (time() - ($mins * 60))) . "' " . "AND user_id!=40 " . "ORDER BY ts DESC LIMIT 1000"; $result = wire('db')->query($sql); $row = $result->fetch_array(); return $row[0]; }
    1 point
  50. Hi Ryan, My question above unfortunately was unclear and I apologize. It was clear in my head, but often is harder to explain when typed. To sum it up, I wanted to keep track of each players stats to include their opponent, kicks and punches. Each player can have up to 10 opponents so what I did was create an opponent field, kicks field and punches field and put them all in a repeater field and assigned that to the player template. Then I wanted to show the total kicks and total punches for each player. This was easy to do on the player template. Getting the total amounts of Kicks and Punches was key. Now, on a new "Leader" page, I wanted to loop through all players plus show their total kicks and total punches. Because I was using repeaters, there was no way for me to get the total kicks or total punches for each player. I would end up with something like so: Player Name Total Punches Total Kicks player 1 8 10 player 1 4 5 Player 2 3 5 Player 2 6 3 So what I did to solve this was create my first module (hooray for me) and added two hidden fields, totalpunches and totalkicks to the player template. The module loops through the repeater field for each player adding the kicks and punches and storing their totals in the hidden fields. I then just pulled in the player and their total fields on the "Leader" template. The moral of the story here is several things: 1. Creating the module was intimidating since php is murky, but OOP is like the black sea to me. After reading a few post, your tut here and having a look at the hello world module, I just dove in. I am glad I did. 2. I did not want to use repeaters because I was concerned if the site grew they would not scale well. Fortunately for me you came to the rescue again here With all that said, I am sure there is a better way or it is possible without the module, but this way works as well.
    1 point
×
×
  • Create New...