Jelix 1.6.40

function.jurlpattern.php

Tags
subpackage

jtpl_plugin

author

Laurent Jouanneau

copyright

2018 Laurent Jouanneau

link
https://jelix.org
licence

GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html

Table of Contents

jtpl_function_html_jurlpattern()  : mixed
function plugin: write the url corresponding to the given jelix action, inserting placeholder name (between two %) for some parameter, so you can generate the url dynamically in JS by replacing placeholders by javascript values.

Functions

jtpl_function_html_jurlpattern()

function plugin: write the url corresponding to the given jelix action, inserting placeholder name (between two %) for some parameter, so you can generate the url dynamically in JS by replacing placeholders by javascript values.

jtpl_function_html_jurlpattern(jTpl $tpl, string $selector[, array<string|int, mixed> $params = array() ][, array<string|int, mixed> $placeholders = array() ]) : mixed

example :

it may produce something like that (depending how the url is configured for the 'jxacl~admin_rightslist' action): index.php/acl/rightslist/%idgroup%/bar?acl=%acl%

Then you can replace placeholders

var urlpattern = document.getElementById("baz").dataset.url; var id_group = 45, acl = 'hello'; var url = urlpattern.replace("%idgroup%", id_group); url = url.replace("%acl%", acl);

Parameters
$tpl : jTpl

template engine

$selector : string

selector action

$params : array<string|int, mixed> = array()

static parameters for the url

$placeholders : array<string|int, mixed> = array()

list of placeholders: key=name of an url parameter, value=a placeholder name you choose

Return values
mixed

Search results