-
Posts
11,129 -
Joined
-
Last visited
-
Days Won
366
Everything posted by adrian
-
Ok, I have ChromePhpLogger installed. Catch is that nothing gets logged because nothing is sent to the browser when I am logged in. When logged out, or that section of code is commented out, it works fine. The one error I do get (in Firebug) is: status: aborted
-
No, I have used FirePHP in the past, but since switching to Chrome I haven't got ramped up on that front yet. Doing a million different things at the moment, but will get it installed and see if I can figure it out.
-
This is actually more complicated than I thought. Turns out all that clearing "Delete cookies and other site and plug-in data" did was log me out. The page works fine when logged out, but produces the error when logged in. Something as simple as: $markers = $pages->get("/schools/")->children(); foreach($markers as $item) { error_log($item->sister_school->id); generates the error. sister_school is a page field (single) select. The error log receives a list of all the sister_school ids. There are no php errors generated. Currently baffled - will let you all know if I figure it out!
-
Select field values not getting edited in front-end form
adrian replied to onjegolders's topic in General Support
I don't think that should be a problem. I think you should just have to edit: foreach($mypage->fields as $f) { $mypage->set($f->name, $form->get($f->name)->value); } to iterate through the fields from the $input->post, assuming the fields already exist in the backend. Even if they don't you could easily add them through a foreach that uses the posted form data. Might be a little fiddly, but not too difficult.- 24 replies
-
- api
- front-end form
-
(and 1 more)
Tagged with:
-
Select field values not getting edited in front-end form
adrian replied to onjegolders's topic in General Support
Not sure if you want to go with diogo's option in that thread I linked to, but I just remembered - be sure to check out the last comment in that thread by me, because there is one change that should be made (fix a non-fatal error), and one key one (saving the page) that has to be made I have found his approach really great for front-end forms - if you're still having troubles, I'd definitely revisit it as an option!- 24 replies
-
- api
- front-end form
-
(and 1 more)
Tagged with:
-
Select field values not getting edited in front-end form
adrian replied to onjegolders's topic in General Support
Is it possible that there is a discrepancy between the fields "Dereference in API as" and its "Input field type". ie is one multi and the other singular? If singular, try the "Single page (Page) or boolean false when none selected" option instead of the other one. I found I had to use this the other day - don't remember why but it worked for me- 24 replies
-
- api
- front-end form
-
(and 1 more)
Tagged with:
-
Select field values not getting edited in front-end form
adrian replied to onjegolders's topic in General Support
I figured they already existed for you. I don't think you can specify the page ID. I think you need to assign the page array itself. In my example above you can see that I assign: $newpage->organization = $neworganization where $newpage->organization is the "organization" page field from the page that was just created for the user's form submission and $neworganziation is the page array, rather than the ID of the page (I think that is right and makes sense )- 24 replies
-
- api
- front-end form
-
(and 1 more)
Tagged with:
-
Select field values not getting edited in front-end form
adrian replied to onjegolders's topic in General Support
onjegolders - I know this is not answering your question directly, but I have been doing a lot of front-end forms direct from templates using this code from diogo as a starter: http://processwire.com/talk/topic/59-module-want-form-builder/?p=11639 It lets PW take care of building and submitting the form. If you need to it is very easy to manipulate data before submission with some conditional statements in the final foreach eg: foreach($mypage->fields as $f) { if($condition_met){ $mypage->set($f->name, transform_result($form->get($f->name)->value))); } else{ $mypage->set($f->name, $form->get($f->name)->value); } } Back to your original question, I have sent pagefield data to the DB like this. This allows the user to add a new option (child) to the page field and then it populates that new value to the selected field. My point is that if you are doing things manually like you are, I think you need to pass an actual "page" to the field - like I have done with: $newpage->organization = $neworganization; $neworganization = new Page(); $neworganization->template = $templates->get("organization"); $neworganization->parent = $pages->get("/organizations/"); $neworganization->of(false); $neworganization->name = $sanitizer->pageName($form->get($f->name)->value); $neworganization->title = $sanitizer->text($form->get($f->name)->value); $neworganization->save(); // Save the new organization as a child in the organizations page $newpage->organization = $neworganization; //add it to the main organization field $newpage->organization_other = ''; //empty the organization_other field - no longer needed since it is now in the main organization field Anyway, hope that provides some insight into what the problem might be (in a roundabout kinda way). I would definitely suggest using that code from diogo though - it works beautifully- 24 replies
-
- api
- front-end form
-
(and 1 more)
Tagged with:
-
artaylor, Not really sure if this is related or not, but the instructions for setting up the comments module are missing a step. Did you add the new comments field to the template for the page?
-
Standardize file properties to PHP equivalents
adrian replied to adrian's topic in Wishlist & Roadmap
Sorry Ryan, I wasn't very clear on this - I was referring to the pathinfo options in php for: dirname basename extension filename Because I don't know what the extension is, I actually used which works great. pathinfo($file->filename,PATHINFO_FILENAME) I am fine with using this, rather than needing PW option. I think what prompted this email was the description in the API cheatsheet for $file->name which says: "Returns the filename without the path (basename)". I thought it would be nice if $file->name became $file->basename to make this clearer for those people used to PHP. Then it just seemed logical to have the other pathinfo options also availble. Anyway, really no big deal at all - just thinking out loud really -
$pages->get("/features")->find("field1<field2") possible?
adrian replied to dotnetic's topic in API & Templates
nik - true - I should maybe have explained the need for an SQL JOIN. I actually hadn't considered the other benefits of using a selector - good to note, thanks! -
$pages->get("/features")->find("field1<field2") possible?
adrian replied to dotnetic's topic in API & Templates
It is also very easy to use SQL in these sorts of situations. Have a read of this thread: http://processwire.com/talk/topic/3053-possible-to-select-modifiedcreated/?p=30093 -
Hi Martijn, Afraid I am not really understanding your suggestion. What I am wanting to do is make sure that when an admin user uploads a new version of the same file (with the same filename) that PW doesn't append a '1' etc to the filename. I could tell the user to delete the file first, then save the page and it will work as I want, but I am trying to avoid them having to do that step. It sounds like maybe you are talking about a front-end upload?
-
Hey Nico - thanks for the suggestion, but the page worked in other browsers and even an incognito Chrome window. Once the cookies/cache were cleared it also worked fine in a standard Chrome window. So it was all solved with no code changes. The weird thing though is that there was that one line of code that could be removed and it would load in standard Chrome window as well. I even had a live version of the site (as opposed to the dev version) with exactly the same code on that page that also worked fine. Anyway, my post here was really just a general heads up in case someone else gets this error. I do like Chrome, but I find its aggressive caching annoying at times. One other thing I did in fixing this page is flush the DNS cache in chrome and my OS. I don't think this is related but it was suggested when I was researching the no data received error!
-
Thanks Wanze, Was hoping there was a PW way. I ended up using the following: $images = $page->$image_field->getArray(); natsort($images); $reversed_images = array_reverse($images); $sortedImages = new WireArray(); $sortedImages->import($reversed_images); $page->$image_field = $sortedImages; I had to reverse the array, I am guessing because of the way import brings them in, so that they are in the correct ascending order. After the final line I make a few more changes to the $page and then save it. Anyway, this seems to work fine.
-
Hi Ryan, I think the title is pretty self-explanatory, but I would like to see a setting, just below the MaxFiles field that would force a newly uploaded file/image with the same filename to replace the old one, rather than deleting the old one, but still adding a counter to the end of the filename for the new one. My reasoning is mostly for external sites linking in to these files. If an admin user wants to update a file with a newer version, the "1" etc will be appended and the external incoming link will no longer work. I expect I could write/adapt the code you provided here: http://processwire.com/talk/topic/3299-ability-to-define-convention-for-image-and-file-upload-names/?p=32623 which I might end up doing, but I thought others might also find this useful in the core. Thanks!
-
Hey guys, Is there any way to emulate PHP's natsort using PW's sort functionality? I have image filenames with numbered suffixes and of course they aren't ordering correctly with a standard sort. Thanks
-
Sorry if I didn't explain well. The approach of having the content div open in the head.inc and close in foot.inc is just to make your life easier. You could have the head.inc just contain the html declaration, head tags, and things like banner and navbar, and have the footer contain just the footer div itself, but then you'd be stuck with needing to add the content div open and close tags in each template file. diogo's reply just came through and I think he explains it very well. PHP really does just string these elements altogether in the order you specify until the final HTML doc is built. It's pretty cool really
-
If you view the outputted HTML source of a page you'll see that those container divs need to span most of the document. The code in each of your templates needs to be between these. This is the only way to achieve this when you have both head and foot includes. Another approach is to have a main.inc that gets included at the bottom of each template. Then you can have all these container divs which control the general layout of the site in one file. Then in your template you build up a variable like $content = '' then $content .= 'content text', etc. Then echo this variable in the main.inc file. You may want to separate content into more than one variable, such as $header, $body, $sidebar. Lots of different ways to end up with the same result. Does that help?
-
Thanks guys - for some reason I didn't think to scroll down and click on the page that was already selected. I guess I was expecting to see it at the top somewhere. This approach makes sense, just apparently not intuitive to me initially kongondo - just checked out the latest version on github when I set this site up and haven't bothered to upgrade yet, but yes I need to get on the 2.3 master.
-
I don't see the unselect option. I am running 2.2.9.final-174-ga8024bb Maybe it is a very recent change, or maybe I am missing something ?
-
Hey Ryan, I am sure you have good reason for the approach you have taken - you usually do, and usually teach me something I don't know, but I was thinking it would be nice if we had the exact same options as PHP ie: dirname basename extension filename I know there is some overlap, but there seems to be some difference in behavior as well. In particular what I am missing is an emulation of PHP's filename which returns the basename without the extension. This of course would be a problematic backwards compatibility change. Anyway, just wanted to throw it out there
-
Not sure if anyone else has come across this error yet, but it was driving me crazy - all of a sudden on one page of my site. At first I thought it was a code error. I went through the offending file and found that if I removed $item->sister_school->id then everything loaded fine. I couldn't even send that via error_log($item->sister_school->id) without the error. The value was sent to the log with no other errors, but the page still wouldn't load. All other browsers and even an incognito chrome window worked fine. Clearing the browser cache didn't help. Not sure what fixed it in the end, but I removed all these: Clear browsing history Clear download history Delete cookies and other site and plug-in data Empty the cache I think it might have been the cookies ... option since I had cleared the others not long ago anyway. Hope that helps someone, although I am still not sure why removing that line of code also stopped the error!
-
How do I get connected page's custom field value?
adrian replied to Vineet Sawant's topic in Getting Started
I think within the entry for each show, you should define the theaters where it will play, not the cities at all. Your template code can then get the city from the theatre table/page. Make sense? Anyway, will leave you to it now