-
Posts
10,902 -
Joined
-
Last visited
-
Days Won
349
Everything posted by adrian
-
Just testing out this module and noticed that the codemirror plugin icons folder is missing, so when you are viewing source, there are 4 blank buttons at the top. Grabbing the icons directory from https://github.com/w8tcha/CKEditor-CodeMirror-Plugin mostly fixes the problem, except the first button image is referenced as searchCode.png, but is named SearchCode.png The other thing I noticed was that codemirror plugin.js file and the lang folder was also missing from this module's installation.
-
Hey Ryan, I just went to install the latest dev for a new site and initially had the DB user permissions incorrect. I received the errors that all the tables etc could not be created, but after fixing the permissions problem, there wasn't an option to redo that step of the install, so I had the start the install again. Everything went fine until I got through to the DB install step again. Then I received a bunch of errors about not being able to create the cache, logs, and sessions directories. Of course these were already created from the previous install attempt, so it was fine to enter the admin account info and proceed, but it might be a confusing error for some users.
-
How come PW is not listed on this page: http://www.cmscritic.com/resource-lists/cms-list/
-
Because in the details tab of the customer field you must have it set to "Multiple Pages". Change it to a single option and you won't need first() anymore. You should only have it set to multiple if you want multiple customers assigned to each order.
-
You can definitely access images from other pages. When inserting into a RTE field (either TinyMCE or CKEditor) there is the option to insert an image from any page in the tree. If you are wanting to grab the image from another page using the API, then something like this will work: $image = $pages->get(/page-name/)->imagefield->url; If your imagefield is set to support multiple images you'll need to specify which image you want, eg: first(), eq(x), last() etc. EDIT: Btw, welcome to PW. Be sure to check out these resources: http://cheatsheet.processwire.com/ http://processwire.com/api/fieldtypes/images/
-
I am not sure on your page structure, but looking at your code in more detail, do you need to do something like: $orders = $pages->get('/orders/')->children(); or if this code is in the orders page template, then you could just do: $orders = $page->children(); At the moment your ->get will only return one page - the orders parent. Also, did you try the ->first()->title option?
-
Depending on the setup of your customer field, you'll need either: $c = $quotation->customer->first()->title; or just $c = $quotation->customer->title;
-
Hey Ryan, Any thoughts on incorporating those changes in post#7? I am actually using this on a couple of sites now and if you aren't planning on doing something like this for the core, then I might start thinking about a module. No pressure, just want to make sure I don't forget about this when I do a PW upgrade Thanks, Adrian
-
Ordering by date reversed, then time normal order
adrian replied to adrian's topic in General Support
Hey Soma, Thanks for both examples - I really appreciate you seeing me through on this one! I decided to go with the dummy array for generating the pager links - it works perfectly! and it easily allows me to use either the direct SQL approach, or the original idea I showed in post #2. What I am now wondering is if it would be at all possible to have PW parse a selector that uses a combination of PW selectors and SQL such that you could write something like: $results = $pages->find("template=x, limit=10, sort={ORDER BY DATE(data) DESC, TIME(data) ASC}"); Not sure on the syntax, but the idea is that if the selector parser comes across something inside curly braces (or some other delimiter), it uses that directly in the final SQL query. Maybe in this example you could even leave out the "ORDER BY " as the sort would be inserting that anyway. Maybe this could get way too complex to deal with, so I won't bring it up again -
Ordering by date reversed, then time normal order
adrian replied to adrian's topic in General Support
Hey Soma, Of course direct SQL works, but it can become much more complicated if you are trying to limit page results to certain parents, templates, etc. Not difficult once you understand PW db table structure and if you know how to use SQL JOINS, but more complex nonetheless. In this case it looks something like: SELECT id FROM pages INNER JOIN field_date_time ON field_date_time.pages_id = pages.id WHERE parent_id = " . $page->id . " ORDER BY DATE(data) DESC, TIME(data) ASC LIMIT " . (($input->pageNum-1)*10) . ",10The above works and /page2/ etc urls work, but MarkupPagerNav no longer automatically generates the page link buttons.Do know the best way to trigger MarkupPagerNav to generate these buttons? I actually just discovered that one of the limitations to my approach above (http://processwire.com/talk/topic/4257-ordering-by-date-reversed-then-time-normal-order/?p=41709) is that generation of the page button links doesn't work either, so I still don't have a fully working solution. I am thinking that I might need to go with Horst's suggestion of a module to split the field into separate hidden date and time fields - won't be difficult, but goes against the principles of database redundancy. -
Ordering by date reversed, then time normal order
adrian replied to adrian's topic in General Support
Hey Ryan, I think maybe I wasn't clear I am not suggesting that you need to replicate sql functionality, just allow sql functions to be included in the selectors. I haven't looked over the core code yet to see how the selector string gets translated into an sql string, but would it be too difficult to allow anything like: field_name->sqlfunction() to be translated into SQLFUNCTION(field_name) to be translated into SQLFUNCTION(field_name) This would allow all these: http://dev.mysql.com/doc/refman/5.0/en/func-op-summary-ref.html to be used directly. Obviously the date and time functions would prove useful, but I am sure lots of others would be handy as well. Maybe it is more complicated to implement than I realize, or maybe there are just lots of good reasons not too -
"What I'm looking for is the topmost page right under an arbitrary page. "The top most parent page under page X". That sounds to me like you are looking for the first child of an arbitrary page - is that right?
-
Ordering by date reversed, then time normal order
adrian replied to adrian's topic in General Support
Hey Ryan, Thanks for another option - there are lots of ways to do this for sure. Any thoughts on the ability for PW to support all mysql functions and operators within selectors? Maybe haven't thought it through fully, but shouldn't it be easy to support? eg: sort=date_time->time() would be converted into ORDER BY TIME(date_time) -
Ordering by date reversed, then time normal order
adrian replied to adrian's topic in General Support
Hey Horst, I actually tried separating the date and time fields, but there was no way to make a user friendly time-only field - they would have to manually type the time. However, I didn't think of automatically splitting them with a module - nice idea! -
Ordering by date reversed, then time normal order
adrian replied to adrian's topic in General Support
Hey kongondo, Thanks, but what I am trying to achieve is ordering like this: July 25 - 9am - 12pm - 2pm July 23 - 8am - 10am My page array sorting works, and there are lots of other ways to achieve the same results (eg. population of the page array using sql directly, restructuring the page tree to have day based children and then time based grandchildren), but I just feel like there should be a way to do this with selectors to manipulate the sql query. I am actually wondering how difficult it would be to facilitate the use of all mysql functions and operators in selectors, not just DATE and TIME like I needed for above. I am on vacation this week, but if Ryan hasn't chimed in on this thread by the time I am back, I might post the idea as a feature suggestion and see what he thinks. -
Ordering by date reversed, then time normal order
adrian replied to adrian's topic in General Support
Ok, here is what I have ended up using for the moment: $results = new PageArray(); foreach($page->children("limit=10, sort=-date_time") as $p){ $date_time = $p->date_time; $p->date = date("Y-m-d",$date_time); $p->time = date("Gis",$date_time); $results->add($p); } $results->sort("time")->sort("-date"); Definitely not thoroughly tested yet. These results are being paginated, hence the limit=10. I guess it might be possible if the 10th and 11th items are on the same day for this to put these out of time order. I guess I could load more results and then truncate to 10 after sorting, although that will mess with the pager module. Will think about it some more - might just go back to an SQL based option to populate the $results array in the first place. Any thoughts? -
OK, here's a tricky one. I want to group event items by day in reverse order so that most recent is on top, but then with multiple events on the same day, I want them ordered by time of day in normal order. With SQL I could easily do: ORDER BY DATE(date_time) DESC, TIME(date_time) ASC Anyone have any ideas how best to do this in PW with a selector? I am thinking I might just end up sorting the page array afterwards, but thought someone might have a cooler idea. Ryan - any chance you could implement mysql's date and time functions so something along these lines would be possible: "sort=-date_time->date, sort=date_time->time"
-
How to automatically set the value of a field?
adrian replied to bytesource's topic in API & Templates
It certainly doesn't hurt and is good practice, but you don't really need to sanitize it at all - you are defining exactly what it will be yourself. The one thing to note on this is that PW is automatically converting the "/" in between the year and the page id, into a dash for the name field. You could do this yourself, which $sanitizer->pageName would take care of. The one thing you might want to sanitize is $parent_id by using "(int)", eg: $parent = wire('pages')->get((int)$parent_id); which converts it to an integer, making that pages->get completely safe. Probably unnecessary since this is an admin form, but that original get variable could be changed by someone. -
https://github.com/ryancramerdesign/ProcessWire/releases/tag/2.2.9
-
How to automatically set the value of a field?
adrian replied to bytesource's topic in API & Templates
Looks like everyone else was out of bed before me this morning - glad you sorted out the scope issue. As you figured out, $_GET variables are passed via the URL and so are very easy to find. -
Now I think I understand your question It sounds like your editor isn't styling your code as PHP because of the .inc name. It must rely on the file extension to decide how to color the code. You could easily rename these files with a .php extension. The .inc is not necessary for them to work. Otherwise there are other code editors out there that will style the php sections of a .inc file correctly. SublimeText is one example that I am familiar with, but I am sure lots of others do as well. Also, there might be a configuration option in your editor to set the styling of .inc files to php. Hope that helps.
-
How to automatically set the value of a field?
adrian replied to bytesource's topic in API & Templates
When creating a new page, there is a get variable set: parent_id=xxxx You should be able to use $input->get->parent_id to do what you want. -
I just ran your Russian through Google translate in an attempt to better understand your question. "sectoring" was changed to "markup". Sorry if I am still not understanding, but I am wondering if you are familiar with PHP? Your editor won't show what the final page will look like because it is a server-side language that creates the final HTML which is what is then displayed on the site. If I am not understanding, perhaps you could try a more detailed question - perhaps some more details will give us a better chance of understanding the translated text.
-
There are several different, and no "correct" way of structuring a site in PW. The default profile uses head.inc and foot.inc, the skyscraper demo makes use of the _init.php and _out.php files, as set in the config.php file. Some people use one main.inc file that contains all the framework HTML etc. Each template populates content to a variable (eg: $out), which is then echo inside the appropriate content div in the main.inc file. Here is a discussion about a different approach altogether: http://processwire.com/talk/topic/740-a-different-way-of-using-templates-delegate-approach/ Lots of options and it really comes down to what makes most sense to you.
-
I have used that script of Ryan's for front-end password resets on several sites now - works a treat! Sorry, if I'd have known that's what you were looking for I'd have pointed you straight to it