Jump to content

alevine

Members
  • Posts

    22
  • Joined

  • Last visited

Posts 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. I definitely did try it with a concat field--I still have test_concat_renamed sitting in my fields list. :) But I see what you are getting at: since this field has no tables, why is it apparently trying to rename tables in your installation? That's a mystery. I will take a closer look and see what I can find.  

    :/  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

    • Like 1
  3. Trying to figure out pros and cons of using this module because I'm doing something where I have a selector saved in a Page's text field and then do the find at render time. The module would have done that find, giving me a PageArray to use in the render. But I see that the find is done by runSelectorQuery() which is called by the wakeValue, sleepValue, loadPageField hooks. I'm new to a lot of this fieldType/hook stuff but isn't it redundant to do the find in the sleepValue hook?

    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. 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.

  5. Sometimes when I say text I actually mean varchar (since it is also a type of text field). But in this case, I think I must have just forgotten when writing the schema. My version of mysql (and apparently most people's) doesn't complain about a default value in a "text" field, for whatever reason. But I will correct this, as it's sure to come up again. 

    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.

  6. 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

  7. 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

    • Like 2
  8. 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.

  9. The Fatal Errors suggests you do not have a field by that name. Have you checked typos? Do you really have a field called premium? Otherwise your selector should work. Also post your query code here if you've doubled-checked field name is correct...Uninitialised string offset error can also occur if you are treating a string as an array...

    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

  10. 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! :)

  11. 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}
  12. 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!

  13. It sounds like your version of MySQL won't accept default values for a text field. I've not heard of that before. Perhaps it is some MySQL setting that I've not seen before. Seems like if it won't accept a default value (which we specify a blank string) then it could only be null as a default. Not that it matters much, but I'd prefer the blank string since there is no use for a null here.  I agree that removing the default that you did shouldn't cause any issues. I'm curious to see if this issue turns up for anyone else. 

    According to http://dev.mysql.com/doc/refman/5.6/en/blob.html, BLOB and TEXT fields cannot have a default value.

    • Like 1
  14. 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

    • Like 1
  15. 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.

  16. 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)

    • Like 1
  17. 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!

  18. 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!

    • Like 1
×
×
  • Create New...