Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    See this page: http://cfdbplugin.com/?page_id=680

    at the end it describes how to add a hidden field which the filter checks.

    Thread Starter Aleharu

    (@aleharu)

    Thank you so much for your answer Michael. It still doesn’t work. I have added the hidden field x to the form and the short code “&&submit_time>$_POST(x)” to the filter but it is still showing all results. I have version 2.9.4

    Plugin Author Michael Simpson

    (@msimpson)

    Post your short code and form definition

    Thread Starter Aleharu

    (@aleharu)

    Form:

    <form action="" method="POST">Título:
    <input name="f2" type="text" value="Buscar…" />Tipo:
    <select name="f1">
    <option value="Ninguno"></option>
    <option value="Columna">Columna</option>
    <option value="Artículo">Artículo</option>
    <option value="Investigación">Investigación</option>
    <option value="Libro">Libro</option>
    </select>Tema:
    <select name="f3">
    <option value="Ninguno"></option>
    <option value="Arte">Arte</option>
    <option value="Drogas">Drogas</option>
    <option value="Narcotráfico">Narcotráfico y poder</option>
    <option value="Jóvenes">Jóvenes</option>
    <option value="Educación">Educación</option>
    <option value="Participación">Participación</option>
    <option value="Violencia">Violencia</option>
    </select>
    <input name="x" type="hidden" value="1" />
    <input type="submit" value="Buscar" /></form>

    Short code:

    [cfdb-table form=”Biblioteca Web” filter=”Titulo~~/.*$_POST(f2).*/i||Tipo=$_POST(f1)||Tema~~/.*$_POST(f3).*/&&submit_time>$_POST(x)” hide=”Submitted,Submitted Login,Submitted From”]

    Plugin Author Michael Simpson

    (@msimpson)

    The problem is the use of OR (||) in the short code. You need to add the && constraint to each OR clause.

    [cfdb-table form="Biblioteca Web" filter="Titulo~~/.*$_POST(f2).*/i&&submit_time>$_POST(x)||Tipo=$_POST(f1)&&submit_time>$_POST(x)||Tema~~/.*$_POST(f3).*/&&submit_time>$_POST(x)" hide="Submitted,Submitted Login,Submitted From"]

    Thread Starter Aleharu

    (@aleharu)

    Still showing all results. I just used the exactly code you post.

    Plugin Author Michael Simpson

    (@msimpson)

    Let’s add some debug output using debug=”true”

    [cfdb-table form="Biblioteca Web" filter="Titulo~~/.*$_POST(f2).*/i&&submit_time>$_POST(x)||Tipo=$_POST(f1)&&submit_time>$_POST(x)||Tema~~/.*$_POST(f3).*/&&submit_time>$_POST(x)" hide="Submitted,Submitted Login,Submitted From" debug="true"]

    It will print out some text about how it parses the filter. Post that.

    Thread Starter Aleharu

    (@aleharu)

    'Titulo~~/.*.*/i&&submit_time>||Tipo~~/.*.*/i&&submit_time>||Tema~~/.*.*/&&submit_time>'
    Array
    (
        [0] => Array
            (
                [0] => Array
                    (
                        [0] => Titulo
                        [1] => ~~
                        [2] => /.*.*/i
                    )
    
                [1] => Array
                    (
                        [0] => submit_time
                        [1] => >
                        [2] =>
                    )
    
            )
    
        [1] => Array
            (
                [0] => Array
                    (
                        [0] => Tipo
                        [1] => ~~
                        [2] => /.*.*/i
                    )
    
                [1] => Array
                    (
                        [0] => submit_time
                        [1] => >
                        [2] =>
                    )
    
            )
    
        [2] => Array
            (
                [0] => Array
                    (
                        [0] => Tema
                        [1] => ~~
                        [2] => /.*.*/
                    )
    
                [1] => Array
                    (
                        [0] => submit_time
                        [1] => >
                        [2] =>
                    )
    
            )
    
    )

    im new to wordpress. How do I only select certain variables in the database table and add it into a post?
    Like for example a user submits a new form and the details are automatically added to the database and the post itself. Is that possible with this plugin?
    Also can i upload a document in the form?
    HELP PLEASE!

    Plugin Author Michael Simpson

    (@msimpson)

    @farhanasyed88 start a new topic with your question. Look at the short code builder admin page.

    Plugin Author Michael Simpson

    (@msimpson)

    @aleharu

    Try this constraint instead:

    [cfdb-table form="Biblioteca Web" filter="Titulo~~/.*$_POST(f2).*/i&&0<$_POST(x)||Tipo=$_POST(f1)&&0<$_POST(x)||Tema~~/.*$_POST(f3).*/&&0<$_POST(x)" hide="Submitted,Submitted Login,Submitted From" debug="true"]

    That will give you the initial form as empty. But when you submit, if you are not filling out all form fields, you will get all values because you end up with a field ~~/*.*/ which matches all values since you are using OR (||).

    Thread Starter Aleharu

    (@aleharu)

    Yes! It’s working now!!

    Thank you so much for your help!

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Show only filtered table’ is closed to new replies.