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

    (@msimpson)

    Thread Starter wp5le

    (@wp5le)

    @michael: Many thanks .. i read it before.. but i’m sorry i can’t understand what i have to do. Sorry.

    Let me please explain: this is what i’m doing with your $_GET:

    [cfdb-html form=”TEST” filter=”Field1=$_GET($ID)” filelinks=”img”]${IMAGE}[/cfdb-html]

    I want to filter with the ID in the DB with the form test. I want to display the image from the field IMAGE.

    But it doesn’t works..

    Sorry .. can you help me out?
    What am i doing wrong???

    Plugin Author Michael Simpson

    (@msimpson)

    try it with:
    $_GET(ID)

    assumes you have ?ID=something in your URL

    Thread Starter wp5le

    (@wp5le)

    Sorry .. still not working ..
    The site url is: e.g.: https://example.com/car

    this is working:
    [cfdb-html form=”TEST” filter=”Field1=car” filelinks=”img”]${car}[/cfdb-html]

    this is not working:
    [cfdb-html form=”TEST” filter=”Field1=$_GET(ID)” filelinks=”img”]${car}[/cfdb-html]

    Thread Starter wp5le

    (@wp5le)

    I’m sorry.

    Plugin Author Michael Simpson

    (@msimpson)

    It will not work unless your URL has GET parameters, i.e. https://example.com/car?ID=something

    Thread Starter wp5le

    (@wp5le)

    ahh okay. no the url is always static..
    something like

    https://example.com/car
    https://example.com/bike
    https://example.com/bus

    and i want to do the lookup with a filter like “car” “bike” “bus” .. but as variable.

    Is there a chance to do this?

    Thread Starter wp5le

    (@wp5le)

    The part behind the slash is always the same with the pagename oder permalink.. or %postname%.

    I can’t find a way to use this information for a filter..

    Plugin Author Michael Simpson

    (@msimpson)

    No it doesn’t support that.

    Thread Starter wp5le

    (@wp5le)

    But i have to say many thanks for your support!!

    Maybe there will be a chance to do that one day.

    Thank you Michael

    Plugin Author Michael Simpson

    (@msimpson)

    You can code your own custom filter, if you are up for coding.

    Documentation reference is here: https://cfdbplugin.com/?page_id=1073

    I think this would grab the last item on the URL (car)

    require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBPermittedFunctions.php');
    
    function cfdb_url() {
        $tokens = explode('/', $_SERVER['REQUEST_URI']);
        return $tokens[sizeof($tokens)-1];
    }
    
    cfdb_register_function('cfdb_url');

    then you could use in your short code:

    filter="cfdb_url()=car"

    I haven’t tested this.

    Thread Starter wp5le

    (@wp5le)

    Hi Michael,
    i did the steps above.
    For my understanding won’t be the filter like this syntax:
    filter=”field=cfdb_url()”
    ?

    Plugin Author Michael Simpson

    (@msimpson)

    Yes. I wasn’t clear how you were using it.

    Thread Starter wp5le

    (@wp5le)

    Hi Michael,
    did i pointed out, that i’m not a developer? It takes much time for me to test or do what you tell me ??

    Still it is not working..

    But with the following code i can do an echo, that gives me the filter value, that i need from the url.

    function getLastPathSegment($url) {
    $path = parse_url($url, PHP_URL_PATH);
    $pathTrimmed = trim($path, ‘/’);
    $pathTokens = explode(‘/’, $pathTrimmed);
    if (substr($path, -1) !== ‘/’) {
    array_pop($pathTokens);
    }
    return end($pathTokens);
    }

    echo getLastPathSegment($_SERVER[‘REQUEST_URI’]);

    The Echo is result is perfect!
    How can i get the result into the filter?
    I tried it this way.. but i does’nt works: cfdb_register_function(‘getLastPathSegment();

    Can you please help me to create now the correct function – code?

    Plugin Author Michael Simpson

    (@msimpson)

    cfdb_register_function('getLastPathSegment');
    You have a typo.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘[CFDB plugin] Part of URL as filter’ is closed to new replies.