Leaderboard
Popular Content
Showing content with the highest reputation on 09/08/2013 in all areas
-
Menu Builder As of 29 December 2017 ProcessWire versions earlier than 3.x are not supported Modules Directory Project Page Read Me (How to install, use, etc..) For highly customisable menus, please see this post. If you want a navigation that mirrors your ProcessWire page tree, the system allows you to easily create recursive menus using either vanilla PHP or Soma's great MarkupSimpleNavigation. In some cases, however, you may wish to create menus that: 1. Do not mirror you site's page tree (hirarchies and ancestry); and 2. You can add custom links (external to your site) to. That is primarily where Menu Builder comes in. It is also helpful if you: 3. Prefer creating menus via drag and drop 4. Have a need for menus (or other listings) that will be changing regularly or that you want to allow your admin users to edit. The issue of custom menus is not new here in the forums. The difference is that this module allows you to easily create such menus via drag and drop in the Admin. Actually, you can even use it to just create some list if you wanted to. In the backend, the module uses the jQueryUI plugin nestedSortable by Manuele J Sarfatti for the drag and drop and is inspired in part by the WP Custom Menu feature. Please read the Read Me completely before using this module. For Complex or highly-customised menus, it is recommended to use the getMenuItems() method as detailed in this post. Features Ability to create menus that do not mirror your ProcessWire Page Tree hierarchy/structure Menus can contain both ProcessWire pages and custom links Create menu hierarchies and nesting via drag and drop Easily add CSS IDs and Classes to each menu item on creating the menu items (both custom and from ProcessWire pages) or post creation. Optionally set custom links to open in a new tab Change menu item titles built from ProcessWire pages (without affecting the original page). E.g. if you have a page titled 'About Us' but you want the menu item title to be 'About' Readily view the structure and settings for each menu item Menus stored as pages (note: just the menu, not the items!) Menu items stored as JSON in a field in the menu pages (empty values not stored) Add menu items from ProcessWire pages using page fields (option to choose between PageAutocomplete and AsmSelect [default]) or a Selector (e.g. template=basic-page, limit=20, sort=title). For page fields, you can specify a selector to return only those specified pages for selection in the page field (i.e. asm and autocomplete) For superusers, optionally allow markup in your menu titles, e.g. <span>About</span> Menu settings for nestedSortable - e.g. maxLevels (limit nesting levels) Advanced features (e.g. add pages via selector, menu settings) currently permissible to superadmins only (may change to be permission-based) Delete single or all menu items without deleting the menu itself Lock down menus for editing Highly configurable MarkupMenuBuilder - e.g. can pass menu id, title, name or array to render(); Passing an array means you can conditionally manipulate it before rendering, e.g. make certain menu branches visible only to certain users [the code is up to you!] Optionally grab menu items only (as a Menu object WireArray or a normal array) and use your own code to create custom highly complex menus to meet any need. More... In the backend, ProcessMenuBuilder does the menu creation. For the frontend, menus are displayed using MarkupMenuBuilder. Credits In this module's infancy (way back!), I wanted to know more about ProcessWire modules as well as improve my PHP skills. As they say, what better way to learn than to actually create something? So, I developed this module (instead of writing PW tutorials as promised, tsk, tsk, naughty, naughty!) in my own summer of code . Props to Wanze, Soma, Pete, Antti and Ryan whose modules I studied (read copied ) to help in my module development and to Teppo for his wonderful write-up on the "Anatomy of fields in ProcessWire" that vastly improved my knowledge and understanding of how PW works. Diogo and marcus for idea about using pages (rather than a custom db table), onjegolders for his helpful UI comments, Martijn Geerts, OrganizedFellow, dazzyweb and Mike Anthony for 'pushing me' to complete this module and netcarver for help with the code. Screens7 points
-
Hani, ProcessWire will scale pretty infinitely in terms of pages, but not in terms of fields or templates. The same can be said of databases in general–you can have millions of rows in a table, but probably don't want millions of tables. I would say you've gone beyond what may be practical for long term use and maintenance of the site. At least, I have never tested ProcessWire with any more than 200 fields (and I thought that was an insane amount). I would be curious why so many fields are necessary? It might be good for us to get a list of all the fields, which may lead to some good suggestions on alternatives. But this is a situation where I think you might really benefit from making your own Fieldtype and Inputfield combinations. It is surprisingly simple to do, and can represent any DB table, no matter how many columns it needs. There is far less overhead in having a custom Fieldtype that represents a table with 100 columns, than there is in having 100 separate fields. Have a look at Adrian's new FieldtypePhone/InputfieldPhone module for a good example of how to represent a DB table with a Fieldtype. Some other options I can think of relate to ProFields, a pack of modules I've been working on to release soon (probably as commercially supported like FormBuilder and ProCache). It includes FieldtypeMultipler, FieldtypeTable, FieldtypeTextArray and FieldtypeTextareas, among others. These enable you to have a single field that can to represent any quantity of inputs. Though they all do it in a little bit different ways. FieldtypeMultiplier lets you take any other Fieldtype (that isn't already multi-value) and turn it into a multi-value field. FieldtypeTable is a multi-value compound type that lets you keep a user-defined combination of fields contained in a group… not quite as powerful as a repeater, but it's only 1 field and has far less overhead. FieldtypeTextArray lets you have a defined quantity of inputs for any text field… like say you needed a field to represent 3 email addresses, for instance. Lastly, FieldtypeTextareas lets you have 1 field that can represent any number of named textareas while having them all be searchable from the same field. For example, you could have a single field called "content" that contains separate inputs for body, sidebar, summary and about_the_author or something like that, but they only consume 1 field, accessed via $page->content->body, $page->content->sidebar, etc. All of these Fieldtypes/Inputfields are aimed at really reducing the overall quantity of fields necessary to represent lots of data. I developed this set because I had a site with lots of similar fields, and this group of modules helped me to reduce the quantity of fields by more than 70%. However, these aren't ready for production use, so it may be a little while before I have them ready. But if you'd be interested in helping to beta test them, your use case might be about perfect.4 points
-
HallExchange is a classifieds service exclusively for college students. Right now, it is only open to students from my school, but will expand to other college's in the future. What do you think? http://www.hallexchange.com/2 points
-
It's perfectly fine not to use ProcessWire's $session functionality and just use $_SESSION. rya has said before it's fine to use one or the other, but pick one and don't try and use them both on the same page I'd do something like this personally: // Create a session variable called something like this after you start the session: $_SESSION['user_start'] = time(); // Then when they get to submitting the payment, just check whether they're within the 5 minute window if (time() - $_SESSION['user_start'] < 300) { // 300 seconds = 5 minutes // they're within the 5 minutes so save the details to the database } else { // sorry, you're out of time unset($_SESSION['user_start']); // and unset any other session vars for this task } I would probably actually store it all in a multidimensional array though actually so it's easy to delete the whole thing: $_SESSION['myapp']['user_start'] = time(); $_SESSION['myapp']['someuserinfo'] = "whatever"; // Then when you get past 5 minutes, if the user is still browsing the site you do unset($_SESSION['myapp']; It might even be better to have that in the top of the head.inc file to check the 5 minute window - that way if a user browses to another page the session time check is happening wherever they are on the site and cleaning itself up as it goes.2 points
-
I'm not sure I agree that it's a good idea or that it would make more sense to clients. I think what makes the most sense to clients is when structure represents reality, both front-end and back-end. In that context, the homepage is the root page, the common ancestor of all others. The more you abstract those things, the less sense it makes to clients, at least in my experience. As a result, I encourage people to use the homepage as the homepage rather than trying to abstract it to somewhere else. If you are going to abstract it, then it depends how you do it. I would avoid handling it from the htaccess and instead edit your /site/templates/home.php to load and render the other page that you want to represent the homepage. $otherPage = $pages->get('/path/to/your/abstracted/homepage/'); $otherPage->you_be_homepage = true; echo $otherPage->render(); In the page represented by that path above, you'd want to have it throw a 404 (via it's template) when you_be_homepage is not set, just by throwing this at the top. if(!$page->you_be_homepage) throw new Wire404Exception(); or make it redirect to the root page: $session->redirect('/'); Using this strategy, you shouldn't have to consider any effects on SEO as the abstraction will be invisible from the outside.2 points
-
Hi Vineet, I have no knowledge about session_timeout. But when reading your post, another solution comes to my mind. Why do you not store the temporary data into the users history pages? Somehow signed as "pending aproval" together with a timestamp? Then there is no need for extra temp_pages or using & tweakin sessions. Maybe more secure, less data overhead and less coding. This way the data must not be deleted after 5 minutes. Its enough that it is only valid for 5 minutes. You may delete such records when come along that users pages the next time (needs only a (few) line(s) of code I think). EDIT: But if you want to delete those data by regular intervals, you may use lazy-cron running onto all "pending-aproval" pages. Just my 2cents.2 points
-
I sometimes end up with orphaned files as a result of doing mass imports during development. My code won't be quite right the first time around and I'll end up with extra and/or duplicated files. At least that was the case this last week. It was on a pretty large scale, so not something I wanted to clean up manually. Here's how I cleaned them out. Place this in a file in your site root called clean-files.php and then load it in your browser. /clean-files.php <pre><?php ini_set('max_execution_time', 60*5); // 5 minutes, increase as needed include("./index.php"); $dir = new DirectoryIterator(wire('config')->paths->files); foreach($dir as $file) { if($file->isDot() || !$file->isDir()) continue; $id = $file->getFilename(); if(!ctype_digit("$id")) continue; $page = wire('pages')->get((int) $id); if(!$page->id) { echo "Orphaned directory: " . wire('config')->urls->files . "$id/" . $file->getBasename() . "\n"; continue; } // determine which files are valid for the page $valid = array(); foreach($page->template->fieldgroup as $field) { if($field->type instanceof FieldtypeFile) { foreach($page->get($field->name) as $file) { $valid[] = $file->basename; if($field->type instanceof FieldtypeImage) { foreach($file->getVariations() as $f) { $valid[] = $f->basename; } } } } } // now find all the files present on the page // identify those that are not part of our $valid array $d = new DirectoryIterator($page->filesManager->path); foreach($d as $f) { if($f->isDot() || !$f->isFile()) continue; if(!in_array($f->getFilename(), $valid)) { echo "Orphaned file: " . wire('config')->urls->files . "$id/" . $f->getBasename() . "\n"; // unlink($f->getPathname()); } } wire('pages')->uncache($page); // just in case we need the memory } When you can confirm that it has found the right files (and no false positives) uncomment the "unlink" line above to have it remove the files on the next run.2 points
-
Hey, The Form API has CSRF protection build in, but if you for some reason don't want to use the API you can however use the CSRF protection. Its very simple but it took some time for me to find out, so i figured i share my findings with the rest. What is CSRF? First you need to create a token and a token name you do that as following: $tokenName = $this->session->CSRF->getTokenName(); $tokenValue = $this->session->CSRF->getTokenValue(); Very simple. Now what you want to do is create a hidden input field like this: $html .= '<input type="hidden" id="_post_token" name="' . $tokenName . '" value="' . $tokenValue . '"/>'; Now this will generate something that will look like this: You are done on the form side. You can now go to the part where you are receiving the post. Then use: $session->CSRF->validate(); This will return true (1) on a valid request and an exception on a bad request. You can test this out to open up your Firebug/Chrome debug console and change the value of the textbox to something else. Basicly what this does is set a session variable with a name (getTokenName) and gives it a hashed value. If a request has a token in it it has to have the same value or it is not send from the correct form. Well I hope I helped someone.1 point
-
Is anyone here a heavy bookmarker like I am? Typically I'll get most of my news from Hacker News and Slashdot, followed by some great blogs on a daily basis. I usually never have time to read an article in depth when I first come across it, so I'll bookmark it for later. Or, if I quickly need to get up to date on some topic, I'll do a search (usually by tags) and familiarize myself with important stuff I've bookmarked in the past. After having used browser native based bookmarking (Firefox and Chrome), then Delicious, then Diigo, then Pinboard and becoming frustrated by all of them for various reasons and limitations, I've decided to roll my own little single user (and non social) bookmarking system with ProcessWire (with Bootstrap 3 as the frontend framework). It's still a work in progress, but it takes the best of all those systems with my own power features. It also utilizes ajax for certain actions. I'll need to create a Chrome extension to tie it all together. I have to say however, after working non-stop on it for hours on end and not being able to think of anything else, it's looking slick. Damn you ProcessWire for making this so enjoyable. Jonathan1 point
-
1 point
-
Hello all, I haven't been around for quite a while, but I'm still trying developing stuff for my classrooms (I'm an English teacher) and this time I'm a little stuck even before starting... Let me explain : I've used ProcessWire for my English site (FLEnglish : http://flenglish.tuxfamily.org - if you're curious) and I just loved it (not my site, ProcessWire ;-), and I appreciated the community help a lot) So here I am again with a 'new' project and my questions : I'd like to implement some kind of RPG Game (in the style of HabitRPG) for the language classroom. Actually, it's a lot easier than HabitRPG since I'm interested mainly in managing the score part of the game. I'd like the kids to have a character (no images for the moment, just a name), and scores for Health Points, Experience, Level, Gold Coins) and according to their achievements in class, the scores improve and so on. The idea is that I'd need a tool quite handy to manage because I have many pupils in classes and no time in class to manage all this. Let's see an example : All kids did their homework. They all get +3 experience and 5 gold coins. I don't want to spend 10 minutes going over each pupil's name and adding their numbers... I thought of the Skyscrapers demo site for a start : yes, I could manage students this way, having field for XP, HP, GC and so on (this is what I started doing actually). But then,I can't manage pupils' results 1 by 1 going through the Admin page in PW. So I thought of using Javascript to avoid having to validate a page on which I would have 120 fields to update according to the task succeeded. That's when I started thinking trying to continue learning AngularJS, but I was unable to make it work along with PW... (I get a 403 error when routing to the view template_ I put everything in /site directory, maybe that's not a good way). Anyway, this is quite a mess in my head at this time even though I would like to try and do something this way. If anyone here could give me a possible thought about this to give it a start : could PW be useful for such a task? To be honest, I would love to use PW for this since I would like to be able to merge this score thing with my site already using PW (and why not imagine 'users' being able to log in to see their scores and so on...?) I'm afraid I'm being extremely complicated on that. Let me rephrase it : - Could I have such a system for scores management using PW ? - Could I have a user interface quite handy to update scores easily using PW? In brief, what do you think? I hope reading this was not too much of a burden. Thanks for your help! Celfred.1 point
-
Just created a simple TinyMCE plugin to work around a issue with TinyMCE and using div's (inserted via templates). I know (and many others) of this limitation since a long time, when using templates in TinyMCE and you have a single div you can't add content after it anymore as there's no element that can be focused. There's no real easy solution to this. As I'm also sometimes using (not often, but will in my current project) templates I just created a simple TinyMCE plugin to add a button where if you click it, it will add a paragraph at the end of the content. -> <p>Text ...</p> Here you go: https://github.com/somatonic/addcontent You can add this plugin to PW TinyMCE: create a new folder in /site/tinymce create new folder in /site/tinymce/plugins add this plugin folder into it. The folder should be called "addcontent" now in the PW admin in the TinyMCE configuration settings of your field you can add custom plugins via the text field "Third-party plugin" at the bottom. add this to the text on a new line: addcontent: /site/tinymce/plugins/addcontent add the button to one of the theme_advanced_buttons "...,addcontent" done You should now have a new button in your toolbar, click it to add a new paragraph to the end of the content. I couldn't think of a better name. "addcontent" maybe someone has an better name?1 point
-
1 point
-
Hi Peter, Thanks! My guess is that you maybe forgot to add the redirect URL in the Google APIs console which points to your VPS server? Here is where this error comes from: https://github.com/wanze/ProcessGoogleAnalytics/blob/master/ProcessGoogleAnalytics.module#L955 Google does not return a HTTP 200 status. If you can't solve the problem by setting the redirect URI, you can try to add this code: if ($auth['http_code'] != 200) { print_r($auth); die(); // Add this line and check which error code is returned $this->error('Could not fetch the accessToken'); return; } Good luck1 point
-
Reviving this old thread. Luckily, since I'm only getting into PHP now, by going straight to OOP, I've not really had to unlearn some procedural PHP in order to grasp OOP. I found the following helpful: http://net.tutsplus.com/tutorials/php/object-oriented-php-for-beginners/ http://www.tutorialspoint.com/php/php_object_oriented.htm http://phpro.org/tutorials/Object-Oriented-Programming-with-PHP.html http://www.codewalkers.com/c/a/Programming-Basics/ObjectOriented-PHP-Fields-Properties-and-Methods/ http://www.massassi.com/php/articles/classes/ http://net.tutsplus.com/tutorials/php/from-procedural-to-object-oriented-php/ http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/ PHP Academy tuts - videos1 point
-
Thank you, Ryan. My intent was to implement some sort of security auditing such that I would receive a message whenever a CSRF was attempted. So I needed to catch the exception. The following code works for me. try { $form->processInput($input->post); $session->CSRF->validate(); } catch (WireCSRFException $e) { echo "Processing aborted. Suspected attempt to forge the submission. IP logged." . $e->getMessage(); /* * Some code to execute whenever the token gets spoofed * Like sending a notification mail with the spoofer's IP address */ die(); // live a great life and die() gracefully. }1 point
-
Hi,I would recomment updating minify a.s.ap. in your module, see this thread: http://processwire.com/talk/topic/1537-minify/page-21 point
-
I love it. I said before: "I like it that way, PLEASE stay talkin' on the forums" Now I think, stay away from the forums and go code for us1 point
-
Yes, there should be a placeholder option for any text-based field in ProcessWire. You'll see it when configuring it. To use it from the API side, you'd do: $inputfield->attr('placeholder', 'your placeholder text');1 point
-
Looks like the same problem as here http://processwire.com/talk/topic/4434-pw-not-installing-correctly-admin-not-found/?hl=htaccess#entry43479. Try onjegolders' suggestion on the first answer. Replace /pw/ by your subfolder name.1 point
-
I think in terms of security Ryan is generally more careful, but also not relying on old code lowers the risks as well. If you look at how often other systems release security updates it is actually quite worrying, and for me as a developer it has been a headache in the past. On the plus side I have used this very point to convert several sites. Keep your points coming - the more we discuss the more answers there are to potentially help you. There is still always the chance though that an agency you go to will simply be too invested in another system, so it's down to whether you take the job anyway and try to convince them later (might be in a better position to build it in their preferred system in a week then spend a weekend doing the same thing in PW to show them) or if you get the feeling that they don't want to try something new (which can raise some alarm bells in a fast-moving industry actually) then you might want to look elsewhere anyway. With regards to the agency you mentioned at the beginning it might be worth asking them a few questions like what JS library they use, or a dozen other questions I can't think of right now to see if they're actually dragging their heels in other areas of web technology - if they're playing it safe stuck in the past in several areas then that would be worrying, but its worth asking all sorts of things that make you look like you're well-versed in current technology (something they should like) and also so you can see if they give any worrying answers1 point
-
Hi Adrian, With your latest version I just get blank pages on my PW 2.3.0 install when I try to export anything. My server PHP version is 5.3.25. Perhaps I need a recent dev version? There's something up with my install there I think. Tried it locally and it works perfectly. This will be a huge time saver Mr Jones. Thank you.1 point
-
My wife says the same thing to me all the time! Here's what I'm working on: I provide a service for realtors in my area that allows them to place a search engine for real estate properties on their website (with lots of functionality for their clients like saving searches, marking favorites, etc.) - the industry term for it is an "IDX System". It's completely functional, however, it isn't using ProcessWire. I'm attempting version 2 of the system with PW as the foundation. (Side note - it was a side project a few years ago and I only have 1 client using it right now, but I'm giving it some focus right now.) Now, our local MLS provides me with all the property listing data which is located in their own database. What I, and other IDX providers, essentially do is pull all the data and store it in our own database so that we can manipulate and search the data however we want. There are actually a few different tables, one for each different property type; residential, commercial, land, rentals, etc. Some of the fields are common among the tables, but some are not. Each property listing in their database has roughly 400 fields/points of information associated with it. Such as: MLS #, Realtor ID, Street Address, Street Suffix, City, State, ZIP Code, # of Bedrooms, # of Bathrooms, Washer/Dryer, Car port, garage, Style, Description, Listing Date, Price, Modification Timestamp, Master Bedroom Area, Master Bedroom Width, Master Bedroom Length, Bedroom 1 Area, Bedroom 1 Width, etc. Obviously TONS of individual pieces of information for each listing. What I have now, in the non-ProcessWire version, are 5 different tables with about 400 columns each. It's not terribly slow since when I pull data, I only pull the fields that I need .Now, that I think about it - you're absolutely right. Most of those fields, while containing data that I need to be able to display, are not fields that I have to ever search. So as diogo and Soma said, serialization and storing the data into a textarea field would be TOTALLY fine. And it would probably cut down on 80% of the fields. If I'm able to cut down on 80% of the fields, then this might not be an issue anymore. But I have never seen your Admin Hotkeys module - that's awesome! I'm totally going to be using it! I thought of doing that too; creating multiple pages for each property listing and splitting up the data - but like you said, I'd still have 800 fields in the system itself and whenever I do need to pull any of the pages to get the data, it would still end up using a lot of memory. Based on all the feedback, it sure sounds like I have! This sounds like a great solution too. But I suppose that since I never really need to search on so many of the fields I currently have, serialization would work for me without much effort. BUT the benefit of this method is that I would still maintain search capability on that data (using selectors) if I really needed it. Right? Those modules sound amazing and I can think of many scenarios where I'll need them. Like Adrian, can't wait to throw my money at you!1 point
-
1 point
-
Beautiful work @jlahijani! Great job with the screencast too–I need to hire you to do my screencasts. Unless you've got other plans to produce it into an SAAS app or something, you should definitely release it. I think a lot of people would find this very useful both as a great tool to use and an impressive example to learn from.1 point
-
It sounds like you might be running a version of ProcessWire prior to 2.3? It doesn't look to me like this jQuery multiselect plugin comes with any sort of pagination capabilities. I'm not really sure how they would do it, so kind of doubt that's on their roadmap, but will keep an eye out. At the moment, I don't plan to include this module in the core. Though if it's something that we find people will use on more than 30% of sites, then it would be something to consider. Okay I see what you mean there. Those two modules assume the "parent_id" to mean just the starting point (rather than both starting & ending point), which is why they are called out separately. I didn't think there's be much use for that feature beyond those two modules, but glad to hear I'm wrong–I'm sure I can find some other way to make that configurable.1 point
-
I'm using the 64-bit windows ST3 Beta and it is blazing fast! It is too fast my eyes are still adjusting1 point
-
The nice thing about Sublime is that you can basically make it do whatever you need with packages/plugins/build systems. I wrote a custom sass build system in about 3 minutes (the one I linked above didn't do exactly what I needed for the way I structure my projects).1 point
-
@Marty: thanks! Have you seen the post about PiM working together with Thumbnails too? I think you will like it! At least you are responsible for the existence of the Thumbnails Module. ( and yes, - Antti is responsible too) I'm very new and inexpertly with GitHub, because of that I have asked owzim if he can help me to send a pull request to Thumbnails repo with only code for sharpening support. While talking/writing about that GitHub stuff - we also come to conclusion that Thumbnails needs recreation of previously used thumbs. And as I don't know the JS stuff, owzim seems to know it very well and he wrote it! I really like that community here and also how good people work together to make things good and better. Thank you!1 point
-
Horst, no worries. Just merged the new pull request and now it remembers the cropping. Superb! Thanks fellas!1 point
-
Plus mine is more about creating two columns where variable-height fields will play nicely if you check the screenshot1 point
-
Looks like a .htaccess or folder location problem From Ryan When you get 404s for everything but the homepage, that means the .htaccess file is not working. Edit your .htaccess file and paste in some garbage at the top, like "alkjaelfkjaef" and save. Now view your homepage. If you get a 500 error, your .htaccess is working (and you should look at the RewriteBase Nik mentioned). But if your homepage still works, then you know your .htaccess is not working. At this point, you need to tell your web host to turn it on. Or if you run the server, you need to add "AllowOveride All" to your httpd.conf for the account. Try this 1. find the line "# RewriteBase /" 2. delete the "#" 3. Important: put in the whole URL of your processwire-folder without the "http://" From Nik Did you try this in your .htaccess already? RewriteBase /processwire-folder/ And then try http://mywebsite.com/processwire/ That would be the url if you didn't change it during the install.1 point
-
Not completely sure of what you want. I'm assuming that your pages fields accept only a single page, so this should work: echo $page->town->title // title of chosen town echo $page->town->country->title // title of chosen country inside the chosen town edit: corrected typo1 point
-
Before reading your replies, I wanted to send the user's local time back to php, then run a bunch of astronomical calculations on the server, then refresh the visitor's page. But that's 2 reloads after the 1st one, and it looks suspicious when a page blinks twice. Ajax might work without refreshing, but it's beyond me. So I've thought of a work-around by doing the .php calculations using UT time, then make adjustments in .js based on visitor's UToffset. ProcessWire is awesome. Thanks guys, Gregory www.1au.com1 point
-
Don't ditch jqueryui - it's confusing on the odd occasion when I've wanted to override something, but it is as logical as Mr Spock once you get use to the HTML it generates I'll be honest and say I think the biggest hurdle can be the colours. Some people just have an issue with baby blue and pink. It's hurtful I know, but someone has actually said to me that that made it look childish to them (I don't agree, and they should darned well look deeper than appearances, but I can at least step outside myself and see things from their perspective). Back when I worked for another web dev company, being able to change admin colours was something that was brought up, so simply being able to choose colours might help. I'm thinking if that functionality is built in, perhaps with a simple colour-picker for the 3-4 main colours, then that would help. That and some pre-defined colour schemes as has been mentioned. You could save the chosen colour scheme to a CSS file with relative ease so that it's all cached nicely too. I like where all this is going as it reminds be a bit of MODx with the ever-present tree, but like ryan says it's not always appropriate (and not every client has widescreen monitors yet even where this might be a problem ). In a future default admin theme I'd agree with others who have said this and suggest some configurability built in would really help. Things like: Easy way to create a custom colour scheme - maybe save as json so can be copy and pasted to other installations easily? Even a simple image upload field so they can stick a company logo at the top Easy way to select another page as the default admin (not applicable to everyone, but since we're talking about configuration options for the admin this might make sense to have it in the same config page) And why not take it one further and allow devs/agencies to type their company name in somewhere as well as a support telephone number? I'm not suggesting total white-labelling as it's important ProcessWire's copyright stays there and that the system is ProcessWire, but if we can think of a sensible way of helping devs struggling with brand identity to tick some of these boxes then it might well help. I know that branding can be a big issue to big companies, but certainly not all - it might be worth bearing in mind and making it easy so that they're not inclined to be rude and take out the copyright and logo so they've got somewhere to stick their own name and info (seen it happen before years ago). Not all of this will help people who only look at the surface of the product - compared to some more elaborate (read: overly compex styling) CMS admins out there it looks more streamlined and functional to many of us, but that translates to "basic" and "under-developed" to others - and there's no helping those people1 point
-
You can not know the client time at the point when the server is first hit, it would require two pages/requests - the first to serve the javascript and the second to recieve the result of the javascript. That is why it's much eaiser to pass PHP time() to the page as a javascript variable and let the client-side handle the locale, if you need to syncronize. <script type="text/javascript"> var d = new Date(<?php echo time(); ?> * 1000); document.write(d.toLocaleString()); </script> If you must do it the other way around, you can redirect to the session - but it's a bag of worms. I'm using a non-processwire session to keep the example simple. <?php session_start(); if( !isset($_SESSION['client_time']) && isset($_GET['client_time']) ){ $_SESSION['client_time'] = $_GET['client_time']; } ?> <script type="text/javascript"> var server_time = '<?php echo addslashes($_SESSION['client_time']); ?>'; if (server_time === ''){ var d = new Date(); window.location = window.location + '?client_time='+encodeURI(d.toLocaleString()); } document.write(server_time); </script> EDIT: Beaten by Adrian and Pete, also good answers.1 point
-
The problem is that you can echo PHP variables into Javascript but not the other way around - PHP is processed on the server before it's served to the browser - JavaScript is processed via the browser so it simply doesn't understand what you're doing. In the first example, you've essentially typed " = visitortime" EDIT: adrian beat me to it There are a few different options on StackOverflow, but I like the PHP approach in this one best so far as - whilst it's not foolproof - it doesn't use Javascript so it can't be manipulated by the user: http://stackoverflow.com/questions/1718935/how-do-i-get-a-visitors-time-zone-in-php1 point
-
The first option won't work because php is server-side and runs before the page loads. The second option has potential, but you are echo'ing: $input->post->utoffset; when the name of your hidden field is "vt" and not "utoffset".1 point
-
I personally think that the way that the current ProcessWire admin functions is exactly how it should continue to function, I'm not a fan of the always available page tree (or any kinda of extra clutter really), I've rarely had a client I was confident could understand/effectively utilize such a feature anyway. I get fewer calls about "CMS confusion" with processwire than I ever have before with ANY platform (yes, even WordPress). Though developing a new admin theme that may make itself more conducive to the addition of such major features would be great, if doable?(I'm not master programmer so I have no idea) I really think this simplicity is key in a default shipping product. Also making the default theme clean/minimal would also potentially make small visual changes easier for developers. My concerns about the theme don't come from a function stand point as I think some of the ideas floating around in these forums serve more to solve developer issues than client issues, and in the end our primary concern, particularly for the default theme, needs to be client experience. My concern is that honestly I was one of these superficial types that overlooked PW because the admin wasn't "cool" or "slick" enough for my tastes. There was probably a 3-4 month period between when I first discovered PW and watched the intro video to when I ended up back here out of my continued search for a "custom post type/custom content" CMS. This second time I took a peek around in the forums to realize that PW supported admin themes, I was in. Between Futura Remix and at the time a preview post for Ergo I knew I could be happy with the look of PW. But obviously not perfectly happy as I was still motivated to go on to make a few of my own (one particular motivator was the use of Jquery ui and its awful awful icons). And frankly in general jqueryui is a bit ugly and very dated looking (though I can understand the concern of moving away from it, seeing as how much code would need to be rewritten). The point before being that there is a very real risk of loosing out on new users because of this (just look at the CMS "Craft" which recently got tons of attention in a bunch of webdev blogs and yet has no single feature that processwire doesn't except it has a gorgeous admin interface, AND you have to PAY for almost all the other good features!). I think one thing that happens is people can't so quickly understand how amazing, flexible, straightforward, powerful and generally beneficial the PW API is, but what they can understand immediately, is whether or not the CMS admin panel is cool, clean, slick, simple, sexy.... whatever. And I think PW falls short here, its not terrible, but its nothing exciting. There are certainly plenty of CMS' to draw inspiration from though: Symphony CMS, Kirby admin panel plugin, Craft, Statamic, Anchor CMS... I'm sure there are more. I think the most effective place to put effort for now it a simplified cleaner rewrite that better supports 3rd party admin themes, no more specificity battles (there should be no need for the use of "!important" in the default theme, or at least very little). This combined with the ability to have "Admin Theme settings" and a per user admin theme selection could really fix most of the concerns floating around (at least I think so...). I really think something that takes the colors from the new processwire.com and a bit of inspiration maybe from others could really nail it. Oh and, I really think switching to an icon font would be smart..... and ditching jqueryui.... I'll stop here... phew.1 point
-
To be honest I use the default theme, not because I dislike the others, but mainly because it's the default. There are two main reasons for this: one is that it represents PW (in a "corporate identity" way), the second is because I trust it will break less then the others with PW updates. As much as I like to try, and to see that there are nice themes being designed for PW, unless one is much better, I will stick with the default. This is one of the reasons I would prefer to see the default theme evolving, than a proliferation of alternative themes, and that's also why I'm happy that Philipp started this (being is ideas used or not). That said, I do agree that the admin should be more appealing to newcomers and easily tweakable to have different appearances by changing colors and typography (business (Nico's colors are a great example), fun, serious, etc). I even think that the default install could offer 4 or five alternatives, besides of those that would be shared by users, I'm talking maybe a small json file that could be imported by the system to change it's appearence (a bit like Philipp's color changes, but maybe more profound). What I'm talking here are not different themes, but variations of the same (default) theme. IMO the possibility to easily make these kind of changes, would allow us to maintain the recognizable PW colors on the default appearance of the default theme. This is for me an important point: the PW corporate feeling should be kept. I also want to remind Reno's small tweaks for the edit page. I think they work great: http://processwire.com/talk/topic/2002-repeating-events-multiple-datestimes-for-datepicker/?p=18862 This post went too long. I'm sure it's a mess...1 point
-
Hey all, Here's a demo of what I've built. It's become my primary bookmarking system: I didn't demonstrate it in the video, but this system works amazingly on a mobile device too. It's so easy and quick to pull up stuff I want to read when at a coffee shop or have a few minutes to kill when on the go. I found Diigo's Android App very limiting in comparison, especially since it doesn't allow you to view all of your bookmarks on the mobile app (last time I checked). I have no plans as of yet to release this, but I may in the near future if you are all really interested. There are features I still want to build out as well as a lot of code cleanup and security measures that need to be implemented. Enjoy! Jonathan1 point
-
PW's coding style is visible in any core file. But it's the same idea whether we're talking about code, graphic design, architecture or really anything someone would create: When it comes to code, that translates mostly to not adding extra unnecessary bytes: Avoid having an opening bracket "{" on its own line. Instead, just use a single space before an opening bracket. Only closing brackets "}" should be on their own line. Avoid use spaces for indentation, just tabs. This is what tabs were made for, not spaces. Use just one tab per indentation, of course. Avoid extra spaces around parenthesis unless you think it's really necessary. For example, it's preferable to use function(a, b) not function ( a, b ) Put a space after a comma, just so the comma doesn't visually melt into one of the adjacent letters. Don't put a closing PHP tag "?>" at the end of a file. Use camelCase for most variable and function names except for when the variable resolves to a database column or ProcessWire 'name', then use lowercase and underscores. Use camelCase for class names except always have the first character be uppercase, i.e 'CamelCase' (there may be a more specific term for this). Put a space before and after the concatenation operator, as it's small and disappears (or becomes a sentence period) too easily. For example use "a . b" and not "a.b". And of course, comment as much as possible. Comments are bytes that are always appreciated for communication. Outside of internal comments within the body of functions/methods, PHPdoc style is the standard we prefer. Honestly the biggest one for me is just the opening bracket thing. I can't follow code that contains opening brackets on their own line. It makes the opens and closes so visually similar that I can't can't easily tell them apart. It could be that my eyes aren't great, but at least for me that coding style creates legibility problems. I have to "fix" code before I can read it. With the style I'm using, when I see a bracket on a line (before I see the nuances of the serifs), at least I know it is always closing something.1 point
-
Regarding learning OOP, WillyC actually makes a good point there about something that is kind of helpful in learning it. Thinking about interfaces in code the way you do interfaces with the objects you interact with in real life. Objects are meant to be self contained things that have defined inputs and outputs, hiding the [potentially complex] details of how it happens and just giving you predictable inputs and outputs. If you start relating objects in real life to their equivalent in code, things start to come together a little easier and it gets your mind in the right place. Stepping back from his toilet example and use something like a faucet instead. The inputs are knobs that set the temperature and strength of flow. And the output is water at the temp and flow you set. $faucet = new Faucet(); $faucet->setTemp(97); $faucet->setFlow(10); echo $faucet->render(); (or something like that)1 point
-
Absolutely! Here is a simple, but functional example for both login and logout templates. You would want to replace the markup with your own markup or includes. Likewise you'd want to change the redirects to redirect to whatever page you want them to go to after completing a login. /site/templates/login.php: <?php if($user->isLoggedin()) { // user is already logged in, so they don't need to be here $session->redirect("/somewhere/"); } // check for login before outputting markup if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if($session->login($user, $pass)) { // login successful $session->redirect("/somewhere/"); } } ?> <html> <head> <title>Login</title> </head> <body> <form action='./' method='post'> <?php if($input->post->user) echo "<h2 class='error'>Login failed</h2>"; ?> <p><label>User <input type='text' name='user' /></label></p> <p><label>Password <input type='password' name='pass' /></label></p> <p><input type='submit' name='submit' value='Login' /></p> </form> </body> </html> /site/templates/logout.php: <?php $session->logout(); ?> <html> <head> <title>Logout</title> </head> <body> <h1>You have logged out</h1> </body> </html>1 point