Jump to content

alevine

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by alevine

  1. That's got to be maddening! All I could find were comments about variables missing their $ identifier, and maybe launching apache with an -x and using truss. :/ Guess it's time to start blocking out segments of code in the new module and poor-man debug what's breaking. Keep us posted, please.
  2. :/ Perhaps another oddity between windows and other platforms when it comes to mysql? If there's anything I can provide you from my side, test case or attempts, please let me know. I'm very happy to assist in giving back -- adam
  3. I think you see the pros. As for the cons, I'm still new to PW, but the others haven't offered any comments about this being a bad thing. As for when the query is run, I honestly don't know either. I pretty much did a blind copy from the Concat field, which is also a run-time/invocation-time process. Hopefully Ryan and the others can provide some insight as to whether it should be called on all the hooks, or just some.
  4. Would someone mind moving this post to the Modules section? Sorry, and thank you.
  5. Hah I'm not entirely sure now what I was trying to ask (I was a mushy brain at that point). I think Ryan best answered, as my concerns were focused on visibility of tree items, and not allowing brute navigation from an end-user's side. I just need to better wrap my head around content accessibility from the admin and end views.
  6. Which version are you running? EDIT: I did notice in the comments that this is an error on windows systems (which is my dev area), but more of a warning on others. This may be our differences.
  7. Are you sure you tried it with a Concat field? There's no table created for Concat types, so the rename table should error out. And in the module, I see no reference to creating table data, but rather quite the opposite: public function ___deleteField(Field $field) { // deleting of field not necessary return true; } public function getDatabaseSchema(Field $field) { // no database schema necessary return array(); } public function ___createField(Field $field) { // nothing necessary to create the field return true; } Or is my install just this broken? :/ I am running mysql 5.6.7
  8. All: If you saw some of my recent postings where I was trying to solve the problem of running a query as a field, I have solved it. I started with Hanna text, but that didn't quite get me all the way. Then I tried just a Concat field, and that didn't get me all the way. I modified the Concat fieldtype for my solution. I had a need to dynamically pull Pages that were cross-referenced back: Product as a Page Photo Pages with a multi-Page Select field that referenced Product (A photo could represent 1+ Products) I wanted a ->photos field from Product that was updated dynamically according to what Photo entries were currently in place, and I didn't want copy/pasted code, and I wanted the selectors to be easily modifiable from the admin screens. Usage is faily simple: 1: Install as a normal module 2: Create a field as a PagesSelectorQuery type 3: On the field details, enter your selector string, ie: template=my_template,select_page_field=$page 4: Add your field to whichever templates. 5: Access the PageArray results like you would any other $page->field I hope you find it useful, at the very least as an exercise in my madness. Thanks again for all the help this community has provided. EDIT: Added to GitHub: https://github.com/alevinetx/processwire-modules/blob/master/FieldtypePagesSelectorQuery.module And Module's page: http://modules.processwire.com/modules/fieldtype-pages-selector-query/ FieldtypePagesSelectorQuery.module
  9. Okay, here's something. If I move the query to my page, it's picking up the additional parameter to the query $myPics = $pages->find("template=myContent,premium=0"); So, this tells me somewhere in the translation between defining the Hanna code, the field declaration, and invocation, only the first parameter (template=...) is being picked up, and everything after is being stripped. The Hanna code is only receiving "template=myContent" If I change the field value to be sent in quotes: [[pages_query pagesQuery=template=myContent,premium=0]] Hanna is getting: : template=myContent,=0 Im sure it has something to do with using the Concat fieldtype doing value substitution. Thoughts on what I need to do to amend that? EDIT: The selectors are fine. I just need to modify the Concat module to not do value substitution and all is well. Once I get my selector properly escaped, that is for including a $page reference in the query.
  10. As I showed in some of the examples, I can retrieve values from ->premium when the Pages are returned. As well, the query doesn't error if I give it nonsense for a field name as a 2nd+ selector value. Query code (as Hanna code entry): $foundPages = $pages->find($pagesQuery); echo serialize($foundPages); Field: query_pages, Type: Concat value: [[pages_query pagesQuery=template=myContent,premium=0]] The above value returns 2 pages, when it should only return one. If I look at ->premium on those 2 returns, one is 1, one is 0. I've tried putting the value for pagesQuery in single (') and double (") quotes; with either form of quotes, I get: Notice: Uninitialized string offset: 0 in C:\dev\xampp\htdocs\pwire\wire\core\Selector.php on line 49 Fatal error: Exception: Field does not exist: (in C:\dev\xampp\htdocs\pwire\wire\core\PageFinder.php line 248) #0 [internal function]: PageFinder->___getQuery(Object(Selectors)) #1 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array) #2 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('getQuery', Array) #3 C:\dev\xampp\htdocs\pwire\wire\core\PageFinder.php(145): Wire->__call('getQuery', Array) #4 C:\dev\xampp\htdocs\pwire\wire\core\PageFinder.php(145): PageFinder->getQuery(Object(Selectors)) #5 C:\dev\xampp\htdocs\pwire\wire\core\Pages.php(144): PageFinder->find(Object(Selectors), Array) #6 [internal function]: Pages->___find('template=myCon...') #7 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array) #8 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('find', Array) #9 C:\dev\xampp\htdocs\pwire\site\assets\cache\HannaCode\pages_query.php(3): Wire->__call('find', Array) #10 C:\dev\xampp\htdocs\pwire\site\assets\cache\Han in C:\dev\xampp\htdocs\pwire\index.php on line 214
  11. I feel like I'm getting super lost with all of my questions today I have a Checkbox field, "premium". This field is added to a template, myContent I have 2 pages created with the myContent template. One has premium checked, the other does not. My query is: Show me all Pages using 'myContent' as a template, and whose premium field is not selected (0): selector: template=myContent,premium=0 This query is returning 2 Pages, which is should not. When I iterate through the returned list, I can see ->premium as set 1 for one, 0 for the other. If I change "premium" in the selector to some random value that doesn't exist as a field name, the query runs and still returns 2 Pages. selector: template=myContent,feujfhejhejejhejhefje=0 I would think it should error out, but instead seems to be doing a short-circuit evaluation. Are comma-delimited selectors not "AND"ed together? If I place the premium field at the start, or even by itself selector: premium=0 I get this error: Notice: Uninitialized string offset: 0 in C:\dev\xampp\htdocs\pwire\wire\core\Selector.php on line 49 Fatal error: Exception: Field does not exist: (in C:\dev\xampp\htdocs\pwire\wire\core\PageFinder.php line 248) #0 [internal function]: PageFinder->___getQuery(Object(Selectors)) #1 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array) #2 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('getQuery', Array) #3 C:\dev\xampp\htdocs\pwire\wire\core\PageFinder.php(145): Wire->__call('getQuery', Array) #4 C:\dev\xampp\htdocs\pwire\wire\core\PageFinder.php(145): PageFinder->getQuery(Object(Selectors)) #5 C:\dev\xampp\htdocs\pwire\wire\core\Pages.php(144): PageFinder->find(Object(Selectors), Array) #6 [internal function]: Pages->___find('=0') #7 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array) #8 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('find', Array) #9 C:\dev\xampp\htdocs\pwire\site\assets\cache\HannaCode\pages_query.php(3): Wire->__call('find', Array) #10 C:\dev\xampp\htdocs\pwire\site\assets\cache\HannaCode\pages_que in C:\dev\xampp\htdocs\pwire\index.php on line 214 Please point out what I'm doing wrong! Thank you. Again!
  12. I have a Concat field whose name i just tried to change was: query_pages attempted: query_subpages After the failure shown below, the prior name still exists, and no reference to the new name I attempted. Result: ProcessField: Saved Field - query_subpages TemplateFile: Can't find file: '.\pwire\field_query_pages.frm' (errno: 2 - No such file or directory) RENAME TABLE `field_query_pages` TO `tmp_field_query_subpages` #0 C:\dev\xampp\htdocs\pwire\wire\core\Fields.php(187): Database->query('RENAME TABLE `f...')#1 [internal function]: Fields->___save(Object(Field))#2 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array)#3 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('save', Array)#4 C:\dev\xampp\htdocs\pwire\wire\core\Field.php(231): Wire->__call('save', Array)#5 C:\dev\xampp\htdocs\pwire\wire\core\Field.php(231): Fields->save(Object(Field))#6 C:\dev\xampp\htdocs\pwire\wire\modules\Process\ProcessField\ProcessField.module(741): Field->save()#7 [internal function]: ProcessField->___executeSave()#8 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array)#9 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('executeSave', Array)#10 C:\dev\xampp\htdocs\pwire\wire\core\ProcessController.php(194): Wire->__call('executeSave', Array)#11 C:\dev\xampp\htdocs\pwire\wire\core\ProcessController.php(194): ProcessField->executeSave()#12 [internal function]: ProcessController->___execute()#13 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array)#14 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('execute', Array)#15 C:\dev\xampp\htdocs\pwire\wire\core\admin.php(45): Wire->__call('execute', Array)#16 C:\dev\xampp\htdocs\pwire\wire\core\admin.php(45): ProcessController->execute()#17 C:\dev\xampp\htdocs\pwire\wire\templates-admin\controller.php(13): require('C:\dev\xampp\ht...')#18 C:\dev\xampp\htdocs\pwire\site\templates\admin.php(13): require('C:\dev\xampp\ht...')#19 C:\dev\xampp\htdocs\pwire\wire\core\TemplateFile.php(125): require('C:\dev\xampp\ht...')#20 [internal function]: TemplateFile->___render()#21 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array)#22 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('render', Array)#23 C:\dev\xampp\htdocs\pwire\wire\modules\PageRender.module(250): Wire->__call('render', Array)#24 C:\dev\xampp\htdocs\pwire\wire\modules\PageRender.module(250): TemplateFile->render()#25 [internal function]: PageRender->___renderPage(Object(HookEvent))#26 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array)#27 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('renderPage', Array)#28 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(293): Wire->__call('renderPage', Array)#29 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(293): PageRender->renderPage(Object(HookEvent))#30 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('render', Array)#31 C:\dev\xampp\htdocs\pwire\wire\modules\Process\ProcessPageView.module(97): Wire->__call('render', Array)#32 C:\dev\xampp\htdocs\pwire\wire\modules\Process\ProcessPageView.module(97): Page->render()#33 [internal function]: ProcessPageView->___execute()#34 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array)#35 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('execute', Array)#36 C:\dev\xampp\htdocs\pwire\index.php(192): Wire->__call('execute', Array)#37 C:\dev\xampp\htdocs\pwire\index.php(192): ProcessPageView->execute()#38 {main}
  13. I'm looking for any advice on best practices for creating placeholders in the tree that contain things like selectors, or even assets that should be accessible by end users, but not necessarily browseable. In my tree, I have a "Selectors" placeholder, underwhich I have various categories of Pages used for selector values. Should I have this marked as hidden and/or unpublished to keep it from appearing in any brute-force url attempts? I'm pointing directly to the specific selector tree when defining my fields, but I'm not sure what ramifications the upper selector's visiblity will have. I guess the underlying question is how are those attributes inherited/passed down to children? I know in my searches I can specify to include hidden pages, but if I start my search underneath will I also need to include that? Is this behavior explicitly defined, or currently just a "that's the way it is as an artifact of the way things are designed" that may accidently change at some point? I think a follow up question to this is, how do I best test my site for vulnerabilities/leaked information that's not locked away? Thanks as always!
  14. According to http://dev.mysql.com/doc/refman/5.6/en/blob.html, BLOB and TEXT fields cannot have a default value.
  15. Okay, I've solved this for now, tho it does add an extra find call. 1: Hanna only does text replacement - all you get back from a tag is text. So, my hannah code executes the query and returns the ids in a piped list $foundPages = $pages->find($pagesQuery); $idList = ""; foreach($foundPages as $img) { $idList .= "$img|"; } echo $idList; 2: I declared my field as a Concat field, with the formatting field as: [[pages_query pagesQuery=template=template-1]] 3: My code now receives the id list, in pipes, when referencing the field, which makes a 2nd call to find all the ids that were returned. $myIds = $page->query_pages; $myPages = $pages->find("id=$myIds"); foreach($myPages as $targetPage) I don't like having to make a second call to the db, as that's unecessary overhead. I may try to dive into hanna code code (heh) and see what it would take to return the original results, rather than doing text substitution. Ryan, any insight would be appreciated here Thanks again, Brent, for directing me to Hanna. It got me to 99% of where I want to be. EDIT: sleep always clears the head. seralize/unserialize to prevent a 2nd db trip I marked your answer as solved, thank you. I'll revisit the new Page form layout question at another time. -- adam
  16. Ok, this looks like it's mostly the solution. The piece that's missing is declaring default text at the field level 1: hannah code to run my pages selector 2: field declaration: Type: Text; TextFormatter: Hannah; Visibility: Always hidden -- default value?? The idea is to add this to a template so the same query is present on all pages/templates using this field. This keeps the content creators from having to worry about adding it (or even breaking it), and I know it's there and what to expect from it. I know it'd be easy enough to create a function somewhere to accept a page and return my page lists that I need, but what fun is that? I'm looking again trough all the modules to see if I overlooked a way to allow specifying the default value for a field.
  17. Brent: Thank you for the suggestion. I'm having issues installing Hanna code (and I've so posted on the support page), but I'm anxious to see if this is the solution that I hope it is. Thanks again, and I'll post back with my experience. -- adam
  18. I just downloaded 0.0.7 from the modules page. On install, I get: Module Install - TextformatterHannaCode Created Page: /processwire/setup/hanna-code/ Module Auto Install: ProcessHannaCode BLOB/TEXT column 'code' can't have a default value If I got to setup/Hanna, I get: Table 'pwire.hanna_code' doesn't exist I also get the same error message when trying to uninstall. EDIT: line 436 of TextformatterHannaCode, I removed "default '' " and it installed fine. I don't think will cause any unexpected issues... i'm using mysql, if that matters (567 I think)
  19. This is 2 questions in one post; I hope that's permissable. 1: I'm trying to find a way to create a field whose value is a selector query, and at page time the field runs the query. This is very akin to http://processwire.com/talk/topic/1489-how-to-retrieve-possible-pages-list-in-a-page-field, but reducing code duplication and making it as natural as any other field. The Page input already allows for the query/snippet to provide possible _selections_ at page creation, but not a way to harness that query's results as a field. Am I making sense? I've not started digging in to the fieldtypes, and I see http://processwire.com/talk/topic/4079-input-field-for-dimensions/ may be a good place to start down this path, unless there's a module I missed that already addresses this. 2: I've seen some screenshots where creating a new Page from a template has a nice layout to the field entries. I am aware that you can specify the entry widths during declaration. However, is this an adjust/reload/repeat process to get some fields grouped together on the same line nicely, or is there a way of handling the field entry layout that I'm not aware of? If either of these questions seem addled in thought, it's me, not you. Thanks for any help, input, and advice you may provide!
  20. Follow up: A few URLs are hard-coded to /, and that ends up a 404 if you have PW installed under a sub-context (ie, localhost/pwire/....)
  21. Khan: Great module! I see someone has already reported the problem with the avatar attribute already existing on a profile, but has no value (line 449) I encountered the problem on a new install, with no users but what comes by default. I'm currently logged in as the admin on the admin pages, and went to the main site and used the "profile" link that was added to the top menu. Someone above tried a solution, but I haven't yet -- perhaps checking for the length of the url > 0? Also, on the checkinstall, it is checking twice for the birthdate field, and skipped checking for the gender (lines 685 and 688). I hope that helps you and others! Thanks again!
×
×
  • Create New...