Jump to content

kixe

Members
  • Posts

    803
  • Joined

  • Last visited

  • Days Won

    10

Posts posted by kixe

  1. I took most parts of your code and implemented it. It works.
    InputfieldSelectMultipleTransfer expects item-content class 'InputfieldSelectMultipleTransfer', which is not rendered. tested with InputfieldWrapper. It would be great if the developer could change this and make the module flexible like InputfieldChosenSelect. I like also install method in this one, which adds the module to InputfieldPage settings otherwise it should be done by hand.

    Thanks a lot for your support.
     
     

    • Like 2
  2. quick look
    InputfieldPageListSelect and Autocomplete are subclasses of Inputfield and not InputfieldSelect. Maybe its good to restrict the selectable Inputfields to all subclasses of InputfieldSelect, which includes the method addOption() too. Furthermore render() method should be hookable.

    Everything else is more on the side of Inputfield Developers. :)

    Thanks again

    • Like 1
  3. Adrian, thanks for your remarks and help to push this forward.

    • It doesn't work in the latest devs. It works until 2.5.16. not later! No problem with master 2.5.3. There are changes in InputfieldSelect.module where I hook in.
      The new setAttribute() method converts object values to string. I try to get a solution. Maybe Ryan should check this too.
      Edit 20-03-15: added PW Version Switcher to enable hook for older versions on dev branch.
    • I thought about adding a Javascript which will save the page after the datatable is selected. Maybe a note is enough for now.
    • I put this on the list. List is getting longer.... Hey you gave me a lot of homework. :P
    • Like 1
  4. pushed Version 1.0.6 on github dev-branch.
    Works now with the API Adrian recommended:

    for single values
    //selected value (int)
    $page->myfield->value
    // selected label
    $page->myfield->label
    // associative array with column => value of depending datatable row
    $page->myfield->row
    
    muliple values can be called with WireArray API
    examples:
    $page->myfield->last()->row['land']
    $page->myfield->first()->row['id']
    $page->myfield->eq(3)->value
    

    To prevent conflicts with datatable column names like 'data' I decided to access the values via $page->myfield->row['data'] instead of $page->myfield->data. 'data' is an reserved property of  the WireData object.

    Please check out and comment. Thanks

    • Like 3
  5. Adrian, thanks a lot for your interest and your comments.
     


    $page->selectextoption = 1
    $page->selectextoption->selectedLabel = Title (assuming the field I chose for the label was the title field)

    I was a little bit confused about that. If selectextoption is a instance of WireData or any Helper Class how could this work?

    Thanks for the hints with FieldtypeDimension and FieldtypePhone.
    I find it a bit tricky to instantiate class objects with flexible properties. I will try. I am thinking about the following, depending on your recommendation.
     

    // selectextoption is the name of our field
    
    $page->selectextoption // returns WireData Object
    $page->selectextoption->value // returns the stored integer value
    $page->selectextoption->label // returns the label value
    
    // to prevent a conflict between 'label' and a column in the datatable named 'label'
    $page->selectextoption->data // returns array(columnname => rowvalue) of the datatable
    // or better a class
    $page->selectextoption->data->columnname // whereas columnname presents the name of any column in the datatable
    

    What do you think?
    I will put a dev branch on github for further development. But weekend first ...

  6. For single values ok, but what do you recommend in case of multiple values? Like this?

    $page->selectextoption->3->id = 1
    $page->selectextoption->3->name = title
    $page->selectextoption->3->label = Title
    $page->selectextoption->3->flags = 13
    
    $page->selectextoption->29->id = 1
    $page->selectextoption->29->name = title
    $page->selectextoption->29->label = Title
    $page->selectextoption->29->flags = 13

    For now I prefer this

    $data = $modules->get('FieldtypeSelectExtOption')->row(null,'id=245');
    
    $data['29']['country'] = Germany
    
  7. How can I get the index type of a mysql database table with pw-api? The Following doesn't work. Why?

    $table = 'pages';
    $column = 'pages_id';
    
    $sql1 = $db->query("SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$table' AND COLUMN_NAME = '$column'");
    $options = array();
    while ($row = $sql1->fetch_array()) $options[] = $row;
    var_dump($options); // return empty array
  8. Ups, this looks strange  $page->selectextoption returns always the fields value (string or array in case of InputfieldAsmSelect and InputfieldSelectMultiple). I cannot follow. ???

    I found another solution to access all values of all columns of the source table depending on the field value ($page->selectextoption) label included.


    Use the following API

    // call the module
    $getdata = $modules->get('FieldtypeSelectExtOption')
    
    // will find the first or only field of type SelectExtOption in your page
    $getdata->row();
    
    // will find a specific field of type SelectExtOption in your page, useful if more than one field of same type in template
    $getdata->row('myfield');
    
    // will find a specific field of type SelectExtOption in a page found by selector string
    $getdata->row('myfield','selectorstring');
    
    // will find the first or only field of type SelectExtOption in a page found by selector string
    $getdata->row(null,'selectorstring');
    

    Output will be an Array with the stored value like ($page->selectextoption) as key and whole information about the row in the databasetable belonging to this value.

    Example
    Field Settings

    • Inputfieldtype = 'InputfieldAsmSelect'
    • Source Table = 'pages'
    • Option Value = 'id'
    • Option Label = 'name'

    Selected Values in Frontend

    • 'admin'
    • 'user'

    Output

    array (size=2)
      2 => 
        array (size=10)
          'id' => string '2' (length=1)
          'parent_id' => string '1' (length=1)
          'templates_id' => string '2' (length=1)
          'name' => string 'admin' (length=5)
          'status' => string '1035' (length=4)
          'modified' => string '2015-01-29 06:37:43' (length=19)
          'modified_users_id' => string '41' (length=2)
          'created' => string '0000-00-00 00:00:00' (length=19)
          'created_users_id' => string '2' (length=1)
          'sort' => string '15' (length=2)
      29 => 
        array (size=10)
          'id' => string '29' (length=2)
          'parent_id' => string '28' (length=2)
          'templates_id' => string '2' (length=1)
          'name' => string 'users' (length=5)
          'status' => string '29' (length=2)
          'modified' => string '2011-04-05 00:39:08' (length=19)
          'modified_users_id' => string '41' (length=2)
          'created' => string '2011-03-19 19:15:29' (length=19)
          'created_users_id' => string '2' (length=1)
          'sort' => string '0' (length=1)
    

    Does this help? It is working already. I will check a little bit and than upload to github.

    New Version on github.

  9. Stupid me. I turned on debug mode in wire instead of site folder. :P

    For my use it is enough because I need only a unique ID for further processing. But in general you are completely right. There should be an api variable to get both value and label from external tables. I will try to solve this.

    Access tables depending to PW is easy. For example if you choose 'templates' as source table the API is like:

    $templates->get($page->selectextoption)->name
    

    Returns a string if InputfieldSelect in use and array for InputfieldAsmSelect and InputfieldSelectMultiple.

    • Like 1
  10. adrian,

    many thanks for your interest and help. I pushed Version 1.0.4 on github and a readme.md too. Should work stable now.

    your remarks

    • I forgot to define an array. Its done.
       
    • Your suggestion:
      I disabled a preselection but field defaults of 'Option Value' and 'Option Table' are for both the first column of the selected table even if nothing is selected.
       
    • Yes there is a reason. The Class extends FieldtypeMulti. In the Database Schema of FieldtypeMulti values are defined as type (int). I don't want to change this. One of the intention I had when I started was to store the values as slim as possible. Now it is easy to create any database table with more than 2 columns to process the input in the way you want it. No need to run in problems by changing the database schema.
       
  11. @adrian
    Thanks for your help.

    • Yes it should be 'pages_id'. Anyway it was ment more like a placeholder. Maybe I will leave it out.
    • Yes in general the defaults should work. :)  I will check this.
    • It was a bit tricky to prevent from SQL Error exception, but I solved this with checking against an array of column names.
      And this beautiful API: $this->db->getTables()
    • You receive this SQL Error maybe if you didn't deleted the field where you have set the fieldtype. Since the module extends FieldtypeMulti the DatabaseSchema has changed. You should solve this by creating a new field. Tell me if it is working then.


    @Kongondo
    thanks for your post.

    • Like 1
  12. Get the last version:

    From the first view a simple select dropdown Fieldtype. But what is different?
    Rather than the option field in the modul settings you will find some setting fields to define a source (datatable or field) from where you can pull the options (value and label).

    I found this very useful when I had to put 250 options in a select field (which I provide in frontend too) and needed this connected and congruent to another more complex table. So now I can make changes in the main table and the select field will take over these changes.

    You can define the following in the settings:

    • datatable
    • tablecolumn for (value) should be integer
    • tablecolumn for (label)
    • dependance (value or label)
    • order ascending or descending

    Here we go:
    https://github.com/k...electExtOption/
    (updated 10.03.15 Version 1.0.2 with Multiselect Option)
    (updated 11.03.15 Version 1.0.3 with Select Inputfields in Settings)

    • Like 7
  13. Welcome to the forum celinem01.
    Language alternate field values doesn't exist for fieldtype file (or image) but for Text Fields. Create a simple Textfield of type the textLanguage where you store the name of your language specific image. Name it for example 'langImage'.
    In the template you can use it

    <img src="/path/to/image/{$page->langImage}"/>
    

    If you use the same images in different projects you can do it like this.
    Put a translatable string in your template

    $img_file_name = __('filename.png');
    <img src="/path/to/image/$img_file_name"/>
    
    

    Now you can create a translation for this template file. Description here:

  14. @ Ivan

    Thats not true. Now you cannot use any field of the parent page to generate the name. Only the generation from date function is possible now. Try it out!
    But with my solution you could use all the parent page fields + date + some string in the order you want it. This is obviously more + inclusion what we have.

    About title:
    Now you get, whatever you defined in the setting the title 'untitled' or a title generated from date which you maybe want to overwrite anyway! No other possibilities until now!

    Maybe I understoud you completely wrong, or you my solution. :rolleyes:  Have a look in github.

    • Like 2
  15. @Ivan

    Yes, the title is generated and the name too, as a derivation from the title. (have a look at the system notice on top of the screenshot) Derivation works completely in the same way, if you add a page manually and type in the page title. I think thats what most user would expect.

    You have read the post, where I described, how it is working actually (link in the first post of this topic). This way seems to be unlogical to me.

    • Like 1
  16. As described in this post (https://processwire.com/talk/topic/8551-custom-urls-for-pages/?p=82742) the option 'Name Format Children' under the tab 'Family' in template settings doesn't work properly and also not as expected. I had a look inside the code and made some changes which are working properly, which offers much more options, more consistency and less code too.

    The result is the following. You have 3 Options for generating name and title, which could be combined in endless variations.
    Name is always derived from title, same like creating pages manually.

    • type date: if function detects # character anywhere in the string, conversion will be: deletion of # and string will be used as format parameter for PHP date() function
    • type field: if string is a fieldname of the parent page the value of this field will be used
    • type string: if string doesn't fit to the 2 preceeding it will be taken as it is

    All parts (separated by comma) will be composed in the order of setting. You can use unlimited numbers of parts

    I made a pull request on github: https://github.com/ryancramerdesign/ProcessWire/pull/831

    Example screenshots

    Setting ...
    post-1246-0-98447200-1418822310_thumb.jp

    will result in
    post-1246-0-97471800-1418822297_thumb.jp

     

    • Like 10
×
×
  • Create New...