-
Posts
11,182 -
Joined
-
Last visited
-
Days Won
372
Everything posted by adrian
-
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
-
Ah ok, that makes sense I presume you have seen this, but just in case: http://modules.processwire.com/modules/process-forgot-password/ Also, worth reading this: http://processwire.com/talk/topic/490-how-to-reset-your-password-how-to-enable-the-forgot-password-function/
-
Hey Marty, But doesn't that module send a new password - I don't think it can send the user an existing password. Not sure how it would help in your case, but maybe I am missing the point. I am sure what you want to do is quite easy to accomplish, I just think that it might be better to explain to the client why it's not a good idea. Not many sites allow password recovery these days. EDIT: A password reminder might be a reasonable solution though, rather than sending their actual password. That could easily be stored as a custom field in the user template and emailed out on request.
-
Hey Marty, the password is encrypted, which is why this isn't really possible. I guess you could hook into user save and make a copy of the password in a plain text field that could then be emailed, but I am sure everyone would agree that this is not a good idea
-
I haven't got many ideas left for you at the moment, but I would try generating your feed using the vanilla example that Ryan's mentions on the module page: http://modules.processwire.com/modules/markup-rss/ Take the code out of your function and see if that generates the feed xml properly. Also make sure there is nothing else in that rss.php template - no main or head/foot inc files etc. If that works, then you can try adding it back into your function if need be.
-
http://processwire.com/talk/topic/3775-formbuilder-export-to-csv-or-excel/
-
Hi lowlines and welcome to PW. Not sure if you have seen this module or not: http://modules.processwire.com/modules/after-save-actions/ but it allows you to control what happens after a page is saved. Not sure exactly what would be your best option, but you should be able to hook into before save, eg: $this->pages->addHookBefore('save', $this, 'setPublished'); The setPublished function would then remove the unpublished status for the page. Does that help at all? Also, have you seen: http://processwire.com/api/hooks/ http://processwire.com/api/hooks/captain-hook/ EDIT: Have a read of this: http://processwire.com/talk/topic/2331-doing-additional-logic-after-saving-a-new-page/?p=21881 Talks about doing additional logic after saving a new page and so I think might suit your needs. Might be the addHookAfter('added' that you are looking for, although do you really want to publish a page that has just been created and still only has a title and name field assigned?
-
Here is a revised version of the module. It accepts all Page::status options, eg. $form->pagestatus = Page::statusUnpublished; $form->pagestatus = Page::statusHidden; If left blank, then the page will be published. Not sure if this is really an ideal default. Maybe it would be good to get some input from others on this. FormTemplateProcessor.module
-
Nice - the only thing I was thinking by the approach I suggested is that it would allow you to also set the status to hidden, or any other option you wanted.
-
It might be best to go with something like: $form->pagestatus = 'unpublished'; That way the module could simply grab "pagestatus" and add it to the page using addstatus before saving. I'll see if I can find a few minutes to modify the module to handle this.
-
I don't think Ryan has that option in the module. The module code could be enhanced to handle that, or you could do something like this after rendering your form. $newpage = $page->children->last(); $newpage->removeStatus(Page::statusUnpublished); $newpage->save(); I think this should work. EDIT: added the necessary save line at the end. EDIT #2: Actually not sure if this will work at all - this could get messy if the form is rendered and not submitted and if someone else submits while another form is still being filled out. Sorry, might need to rethink this and go with editing the module code properly. Ignore all the above and see http://processwire.com/talk/topic/59-module-want-form-builder/?p=41431
-
Oh, I see - you are actually using Ryan's module from the first page of this thread - sorry, my bad! I assumed you were using diogo's code. There is a line in that module: $this->contact->status = Page::statusUnpublished; The easy hackish option would be to remove that line from the module code.
-
Just before: $mypage->save(); which I mention a couple of posts above, you just need to add: $mypage->removeStatus(Page::statusUnpublished); EDIT: although I thought they were published by default and you actually had to add: $mypage->addStatus(Page::statusUnpublished); to set them to be unpublished.